From 11f2e445889e064c0b7f26428c650ba89d661cf4 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Thu, 12 Oct 2023 08:51:07 -0700 Subject: sign-autobuilds: shellcheck fixes Signed-off-by: Robin H. Johnson --- sign-autobuilds.sh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/sign-autobuilds.sh b/sign-autobuilds.sh index b70ba42..5d40fd0 100755 --- a/sign-autobuilds.sh +++ b/sign-autobuilds.sh @@ -10,15 +10,15 @@ ARCHES=${ARCHES:-${_ARCHES}} RELEASES=/var/tmp/gmirror-releases/releases/ [[ $HOSTNAME == TODO ]] && RELEASES=/var/tmp/gmirror/releases/ -: ${DEBUG:=''} -: ${VERBOSE=''} -GPG='gpg --homedir /home/gmirror/.gnupg-releng/ --batch --no-tty' +: "${DEBUG:=''}" +: "${VERBOSE=''}" +GPG=(gpg --homedir /home/gmirror/.gnupg-releng/ --batch --no-tty) # Do not change DEBUGP= VERBOSEP=false -[ -n "$DEBUG" ] && DEBUGP=echo -[ -n "$VERBOSE" ] && VERBOSEP= +[ -n "$DEBUG" ] && DEBUGP='echo' +[ -n "$VERBOSE" ] && VERBOSEP='' [ -n "$DEBUG" ] && RSYNC_OPTS="${RSYNC_OPTS} -n" [ -n "$VERBOSE" ] && RSYNC_OPTS="${RSYNC_OPTS} -v" @@ -27,16 +27,16 @@ VERBOSEP=false signone() { f="$1" - $DEBUGP ${GPG} --armor --detach-sign "${f}" + $DEBUGP "${GPG[@]}" --armor --detach-sign "${f}" } signone_clearsign() { # only for text files! f="$1" - d="${1}.asc.tmp" + d=".${1}.asc.tmp" rm -f "$d" # Clearsign aborts if the destfile exists - $DEBUGP ${GPG} --armor --clearsign --output "$d" "${f}" + $DEBUGP "${GPG[@]}" --armor --clearsign --output "$d" "${f}" $DEBUGP mv "${d}" "${f}" } @@ -52,17 +52,18 @@ cleanup() { find autobuilds \ -type f \ -name 'latest*txt.asc' \ - -exec grep -L -e '^-----BEGIN PGP SIGNED MESSAGE-----$' \{} \+ \ - | xargs --no-run-if-empty rm -f + -exec grep -L -e '^-----BEGIN PGP SIGNED MESSAGE-----$' \{\} \+ \ + | tr '\n' '\0' \ + | xargs -0 --no-run-if-empty rm -f } gpgconf --kill all for a in $ARCHES ; do -pushd $RELEASES/$a >/dev/null || continue +cd "$RELEASES/$a" >/dev/null || continue -[[ -d autobuilds ]] || exit +[[ -d autobuilds ]] || continue #echo "Release files:" @@ -109,7 +110,7 @@ find_unsigned_helper_cmd=( # marker files to declare latest builds. -or -name 'latest*txt' \) - -exec grep -L -e '^-----BEGIN PGP SIGNED MESSAGE-----$' \{} \+ + -exec grep -L -e '^-----BEGIN PGP SIGNED MESSAGE-----$' \{\} \+ ) files="$( "${find_files_cmd[@]}" )" @@ -144,6 +145,4 @@ done cleanup -popd >/dev/null - done -- cgit v1.2.3-65-gdbad