guix: make it possible to override gpg binary

For example on Qubes OS one might want to use qubes-gpg-client-wrapper instead
This commit is contained in:
Pavol Rusnak 2022-03-13 20:03:07 +01:00
parent bb0b39ce6f
commit af74e061c0
No known key found for this signature in database
GPG key ID: 91F3B339B9A02A3D

View file

@ -19,8 +19,16 @@ source "$(dirname "${BASH_SOURCE[0]}")/libexec/prelude.bash"
################ ################
check_tools cat env basename mkdir diff sort check_tools cat env basename mkdir diff sort
if [ -z "$NO_SIGN" ]; then if [ -z "$NO_SIGN" ]; then
check_tools gpg # make it possible to override the gpg binary
GPG=${GPG:-gpg}
# $GPG can contain extra arguments passed to the binary
# so let's check only the existence of arg[0]
# shellcheck disable=SC2206
GPG_ARRAY=($GPG)
check_tools "${GPG_ARRAY[0]}"
fi fi
################ ################
@ -90,7 +98,7 @@ if [ -z "${signer_name}" ]; then
signer_name="$gpg_key_name" signer_name="$gpg_key_name"
fi fi
if [ -z "$NO_SIGN" ] && ! gpg --dry-run --list-secret-keys "${gpg_key_name}" >/dev/null 2>&1; then if [ -z "$NO_SIGN" ] && ! ${GPG} --dry-run --list-secret-keys "${gpg_key_name}" >/dev/null 2>&1; then
echo "ERR: GPG can't seem to find any key named '${gpg_key_name}'" echo "ERR: GPG can't seem to find any key named '${gpg_key_name}'"
exit 1 exit 1
fi fi
@ -239,11 +247,11 @@ mkdir -p "$outsigdir"
echo "Signing SHA256SUMS to produce SHA256SUMS.asc" echo "Signing SHA256SUMS to produce SHA256SUMS.asc"
for i in *.SHA256SUMS; do for i in *.SHA256SUMS; do
if [ ! -e "$i".asc ]; then if [ ! -e "$i".asc ]; then
gpg --detach-sign \ ${GPG} --detach-sign \
--digest-algo sha256 \ --digest-algo sha256 \
--local-user "$gpg_key_name" \ --local-user "$gpg_key_name" \
--armor \ --armor \
--output "$i".asc "$i" --output "$i".asc "$i"
else else
echo "Signature already there" echo "Signature already there"
fi fi