From 012b37d32903c637cce7cbe66eb68f1e62724958 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Thu, 29 Jun 2023 12:55:52 +0200 Subject: added get-source-info for pkginfo caching --- bin/get-source-info | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 bin/get-source-info 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 +# 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 [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}" -- cgit v1.2.3-54-g00ecf