From d4ce7ca1b7141ecebc27a660f8a34fcb4f9bec35 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Thu, 28 Mar 2024 16:42:07 +0100 Subject: [PATCH] scripts/rsync-generation/update-rsync-master: shellcheck Signed-off-by: Fabian Groffen --- .../rsync-generation/update-rsync-master.sh | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/scripts/rsync-generation/update-rsync-master.sh b/scripts/rsync-generation/update-rsync-master.sh index 6a93207518..304877ac95 100755 --- a/scripts/rsync-generation/update-rsync-master.sh +++ b/scripts/rsync-generation/update-rsync-master.sh @@ -3,7 +3,7 @@ SCRIPTSTARTTIME=$(date +%s) # get keys for ssh and signing -eval $(env SHELL=/bin/bash keychain -q --noask --eval) +eval "$(env SHELL=/bin/bash keychain -q --noask --eval)" BASE_PATH="$(readlink -f "${BASH_SOURCE[0]%/*}")" @@ -20,7 +20,6 @@ PORTAGE_BASE_PATH="${BASE_PATH}/prefix/usr/lib/portage/" PYTHONPATH="${PORTAGE_BASE_PATH}/pym" PORTAGE_CONFIGROOT="${BASE_PATH}/misc/config_root" PORTAGE_DEPCACHEDIR="${BASE_PATH}/depcache" -MANIFEST_CACHE="${BASE_PATH}/manifests" # for .cvsps and gnupg cache mainly HOME="${BASE_PATH}/misc" @@ -34,7 +33,12 @@ echo "(init) PATH=$PATH" #### ---- egencache settings ---- #### -EGENCACHE_OPTS="--jobs=$(nproc) --load-average=$(nproc) --tolerant --update-use-local-desc" +EGENCACHE_OPTS=( + "--jobs=$(nproc)" + "--load-average=$(nproc)" + "--tolerant" + "--update-use-local-desc" +) export PYTHONPATH PORTDIR PORTAGE_BASE_PATH PORTAGE_CONFIGROOT \ ROOT PORTAGE_TMPFS FEATURES HOME @@ -66,8 +70,8 @@ apply_git_mtimes() { git log --pretty=%ct --name-status --reverse "${from}..${to}" echo 999 # end marker to trigger the last block to be done } | \ - while read line ; do - case ${line} in + while read -r line ; do + case "${line}" in [0-9][0-9][0-9]*) if [[ ${ts} -gt 0 ]] ; then [[ ${#files[@]} == 0 ]] || \ @@ -78,11 +82,11 @@ apply_git_mtimes() { ;; [ACMT]*) set -- ${line} - files+=( $2 ) + files+=( "$2" ) ;; [R]*) set -- ${line} - files+=( $3 ) + files+=( "$3" ) ;; [D]*) set -- ${line} @@ -95,8 +99,8 @@ apply_git_mtimes() { # if the entire package was removed, touch the # category level metadata [[ -f ${f%/*}/metadata.xml ]] \ - && files+=( ${f%/*}/metadata.xml ) \ - || files+=( ${f%/*/*}/metadata.xml ) + && files+=( "${f%/*}"/metadata.xml ) \ + || files+=( "${f%/*/*}"/metadata.xml ) fi ;; esac @@ -201,8 +205,8 @@ echo "($(date +"%F %R")) git image updated" echo "($(date +"%F %R")) rsync Prefix tree to rsync-master" for entry in scripts *-*/* ; do # copy it over - [[ -e ${RSYNCDIR}/${entry} ]] || mkdir -p "${RSYNCDIR}"/${entry} - rsync -v --delete -aC "${PREFIXTREEDIR}"/${entry}/ "${RSYNCDIR}"/${entry}/ + [[ -e ${RSYNCDIR}/${entry} ]] || mkdir -p "${RSYNCDIR}/${entry}" + rsync -v --delete -aC "${PREFIXTREEDIR}/${entry}"/ "${RSYNCDIR}/${entry}"/ done # we excluded the eclasses above, because we "overlay" them from gx86 @@ -230,7 +234,7 @@ START=$(date +%s) # generate the metadata echo "($(date +"%F %R")) generating metadata" dolog() { - echo $* + echo "$*" "$@" } dolog "${PORTAGE_BASE_PATH}/bin/egencache" --update --rsync \ @@ -247,7 +251,7 @@ sync-type = rsync sync-uri = rsync://dont-sync auto-sync = no ' \ - ${EGENCACHE_OPTS} \ + "${EGENCACHE_OPTS[@]}" \ || exit 5 STOP=$(date +%s) @@ -281,8 +285,8 @@ sed -e '/^thin-manifests/s/true/false/' \ # Signing is done with our snapshot signing key, and only on the top # level Manifest, for it covers indirectly the entire tree # remember, HOME is set to misc/ so .gnupg keychain lives there -cat "${BASE_PATH}"/autosigner.pwd | \ - qmanifest -g -p -s "0xC6317B3C" "${RSYNCDIR}" || \ +qmanifest -g -p -s "0xC6317B3C" "${RSYNCDIR}" \ + < "${BASE_PATH}"/autosigner.pwd || \ echo "Manifest generation and/or signing failed!" >> /dev/stderr echo "($(date +"%F %R")) Manifest signed"