From bde397199126e0aa49f5162ace370e55f6ab2a51 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sun, 25 Apr 2021 16:48:35 +0200 Subject: Fix shellcheck complains in CI scripts .gitlab/ci/build-host.sh: Change the readonly TMPDIR variable to a global tmpdir variable and set it in the `init()` function. .gitlab/ci/build-inside-vm.sh: Change assigning the readonly tmpdir variable directly to assigning it after declaring it. Change `cleanup()` and `create_zsync_delta()` to use bash-style statements and also check whether SUDO_GID is set before using it. --- .gitlab/ci/build-inside-vm.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to '.gitlab/ci/build-inside-vm.sh') diff --git a/.gitlab/ci/build-inside-vm.sh b/.gitlab/ci/build-inside-vm.sh index 151cc13..8e433b1 100755 --- a/.gitlab/ci/build-inside-vm.sh +++ b/.gitlab/ci/build-inside-vm.sh @@ -6,7 +6,8 @@ readonly orig_pwd="${PWD}" readonly output="${orig_pwd}/output" -readonly tmpdir="$(mktemp --dry-run --directory --tmpdir="${orig_pwd}/tmp")" +tmpdir="" +tmpdir="$(mktemp --dry-run --directory --tmpdir="${orig_pwd}/tmp")" cleanup() { # clean up temporary directories @@ -21,7 +22,7 @@ create_checksums() { sha256sum "${1}" >"${1}.sha256" sha512sum "${1}" >"${1}.sha512" b2sum "${1}" >"${1}.b2" - if [ -n "${SUDO_UID:-}" ]; then + if [[ -n "${SUDO_UID:-}" ]] && [[ -n "${SUDO_GID:-}" ]]; then chown "${SUDO_UID}:${SUDO_GID}" "${1}"{,.b2,.sha{256,512}} fi } @@ -30,7 +31,7 @@ create_zsync_delta() { # create a zsync control file for a file # $1: a file zsyncmake -C -u "${1##*/}" -o "${1}".zsync "${1}" - if [ -n "${SUDO_UID:-}" ]; then + if [[ -n "${SUDO_UID:-}" ]] && [[ -n "${SUDO_GID:-}" ]]; then chown "${SUDO_UID}:${SUDO_GID}" "${1}".zsync fi } -- cgit v1.2.3-70-g09d2