Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/get-source-info83
1 files changed, 83 insertions, 0 deletions
diff --git a/bin/get-source-info b/bin/get-source-info
new file mode 100755
index 0000000..4b59b85
--- /dev/null
+++ b/bin/get-source-info
@@ -0,0 +1,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}"