Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/.gitlab/ci
diff options
context:
space:
mode:
authorDavid Runge <dvzrv@archlinux.org>2021-04-25 16:48:35 +0200
committerDavid Runge <dvzrv@archlinux.org>2021-04-30 17:51:27 +0200
commitbde397199126e0aa49f5162ace370e55f6ab2a51 (patch)
tree346342b040165a90252d6bd311c30f69938f0de5 /.gitlab/ci
parent1a9710963996e476790d7a351b57b090866c9b71 (diff)
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.
Diffstat (limited to '.gitlab/ci')
-rwxr-xr-x.gitlab/ci/build-host.sh12
-rwxr-xr-x.gitlab/ci/build-inside-vm.sh7
2 files changed, 11 insertions, 8 deletions
diff --git a/.gitlab/ci/build-host.sh b/.gitlab/ci/build-host.sh
index 1849420..be688bb 100755
--- a/.gitlab/ci/build-host.sh
+++ b/.gitlab/ci/build-host.sh
@@ -6,18 +6,20 @@
set -o nounset -o errexit
readonly MIRROR="https://mirror.pkgbuild.com"
+tmpdir=""
+
function init() {
readonly ORIG_PWD="${PWD}"
readonly OUTPUT="${PWD}/output"
- readonly TMPDIR="$(mktemp --dry-run --directory --tmpdir="${PWD}/tmp")"
- mkdir -p "${OUTPUT}" "${TMPDIR}"
+ tmpdir="$(mktemp --dry-run --directory --tmpdir="${PWD}/tmp")"
+ mkdir -p "${OUTPUT}" "${tmpdir}"
- cd "${TMPDIR}"
+ cd "${tmpdir}"
}
# Do some cleanup when the script exits
function cleanup() {
- rm -rf -- "${TMPDIR}"
+ rm -rf -- "${tmpdir}"
jobs -p | xargs --no-run-if-empty kill
}
trap cleanup EXIT
@@ -146,7 +148,7 @@ function main() {
## Start build and copy output to local disk
send "bash -x ./.gitlab/ci/build-inside-vm.sh ${PROFILE}\n "
expect "# " 2400 # mksquashfs can take a very long time
- send "cp -r --preserve=mode,timestamps -- output /mnt/project/tmp/$(basename "${TMPDIR}")/\n"
+ send "cp -r --preserve=mode,timestamps -- output /mnt/project/tmp/$(basename "${tmpdir}")/\n"
expect "# " 60
mv output/* "${OUTPUT}/"
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
}