blob: 73dc504cb2051ae66ee777d3f6f59aee61168cb8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#!/bin/sh
# shellcheck disable=SC2119,SC2120
# get-source-info <package> <repository> <git_revision> <mod_git_revision>
# create .SRCINFO from PKGBUILD within git repositories, output to stdout,
# cache it on https://mirror.archlinux32.org/pkginfo
# build .SRCINFO if necessary, fetch it from cache when already computed,
#
# this can be used to cache srcinfo (especially for blacklisted packages)
# as it uses quite some time to compute
# shellcheck source=../lib/load-configuration
. "${0%/*}/../lib/load-configuration"
# shellcheck disable=SC2016
usage() {
>&2 echo ''
>&2 echo 'get-source-info <package> <repository> <git_revision> <mod_git_revision> [options]:'
>&2 echo ' get package srcinfo'
>&2 echo ''
>&2 echo 'possible options:'
>&2 echo ' -c|--cache:'
>&2 echo ' Respect the cache when fetching pkginfo'
>&2 echo ' -h|--help:'
>&2 echo ' Show this help and exit.'
[ -z "$1" ] && exit 1 || exit "$1"
}
eval set -- "$(
getopt -o hc \
--long help \
--long cache \
-n "$(basename "$0")" -- "$@" || \
echo usage
)"
respect_cache=0
while true
do
case "$1" in
-h|--help)
usage 0
;;
-c|--cache)
respect_cache=1
;;
--)
shift
break
;;
*)
>&2 printf 'Whoops, forgot to implement option "%s" internally.\n' \
"$1"
exit 42
;;
esac
shift
done
if [ $# -ne 4 ]; then
usage 1
fi
tmp_dir=$(mktemp -d "${work_dir}/tmp.get-source-info.XXXXXX")
trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT
PACKAGE="$1"
REPOSITORY="$2"
GIT_REVISION="$3"
MOD_GIT_REVISION="$4"
SRCINFO="${tmp_dir}/SRCINFO"
if [ "${respect_cache}" = 1 ]; then
curl -LSs "https://buildmaster.archlinux32.org/pkginfo/${PACKAGE}=${REPOSITORY}=${GIT_REVISION}=${MOD_GIT_REVISION}" \
>"${SRCINFO}"
else
make_source_info "${PACKAGE}" "${REPOSITORY}" "${GIT_REVISION}" "${MOD_GIT_REVISION}" "${SRCINFO}"
fi
cat "${SRCINFO}"
|