diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2021-09-29 19:55:24 +0200 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2021-09-29 22:24:12 +0200 |
commit | 8370da9ea608b0f59c9da495910bbc3e45236ed6 (patch) | |
tree | f2a6fce8f564926f0446154eeb2c82de979718a8 /.semaphore | |
parent | Merge pull request #20883 from bluca/bpf_header_license (diff) | |
download | systemd-8370da9ea608b0f59c9da495910bbc3e45236ed6.tar.xz systemd-8370da9ea608b0f59c9da495910bbc3e45236ed6.zip |
ci: shellcheck-ify CI scripts
Diffstat (limited to '.semaphore')
-rwxr-xr-x | .semaphore/semaphore-runner.sh | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/.semaphore/semaphore-runner.sh b/.semaphore/semaphore-runner.sh index e7dbcb2ac1..a0a4153cde 100755 --- a/.semaphore/semaphore-runner.sh +++ b/.semaphore/semaphore-runner.sh @@ -1,17 +1,19 @@ #!/bin/bash set -eux +set -o pipefail # default to Debian testing -DISTRO=${DISTRO:-debian} -RELEASE=${RELEASE:-bullseye} -BRANCH=${BRANCH:-upstream-ci} -ARCH=${ARCH:-amd64} -CONTAINER=${RELEASE}-${ARCH} -CACHE_DIR=${SEMAPHORE_CACHE_DIR:=/tmp} +DISTRO="${DISTRO:-debian}" +RELEASE="${RELEASE:-bullseye}" +BRANCH="${BRANCH:-upstream-ci}" +ARCH="${ARCH:-amd64}" +CONTAINER="${RELEASE}-${ARCH}" +CACHE_DIR="${SEMAPHORE_CACHE_DIR:-/tmp}" AUTOPKGTEST_DIR="${CACHE_DIR}/autopkgtest" # semaphore cannot expose these, but useful for interactive/local runs ARTIFACTS_DIR=/tmp/artifacts +# shellcheck disable=SC2206 PHASES=(${@:-SETUP RUN}) UBUNTU_RELEASE="$(lsb_release -cs)" @@ -20,18 +22,18 @@ create_container() { # GPG key from keyserver", so retry a few times with different keyservers. for keyserver in "" "keys.gnupg.net" "keys.openpgp.org" "keyserver.ubuntu.com"; do for retry in {1..5}; do - sudo lxc-create -n $CONTAINER -t download -- -d $DISTRO -r $RELEASE -a $ARCH ${keyserver:+--keyserver "$keyserver"} && break 2 + sudo lxc-create -n "$CONTAINER" -t download -- -d "$DISTRO" -r "$RELEASE" -a "$ARCH" ${keyserver:+--keyserver "$keyserver"} && break 2 sleep $((retry*retry)) done done # unconfine the container, otherwise some tests fail - echo 'lxc.apparmor.profile = unconfined' | sudo tee -a /var/lib/lxc/$CONTAINER/config + echo 'lxc.apparmor.profile = unconfined' | sudo tee -a "/var/lib/lxc/$CONTAINER/config" - sudo lxc-start -n $CONTAINER + sudo lxc-start -n "$CONTAINER" # enable source repositories so that apt-get build-dep works - sudo lxc-attach -n $CONTAINER -- sh -ex <<EOF + sudo lxc-attach -n "$CONTAINER" -- sh -ex <<EOF sed 's/^deb/deb-src/' /etc/apt/sources.list >> /etc/apt/sources.list.d/sources.list # wait until online while [ -z "\$(ip route list 0/0)" ]; do sleep 1; done @@ -44,11 +46,11 @@ apt-get purge --auto-remove -y unattended-upgrades systemctl unmask systemd-networkd systemctl enable systemd-networkd EOF - sudo lxc-stop -n $CONTAINER + sudo lxc-stop -n "$CONTAINER" } for phase in "${PHASES[@]}"; do - case $phase in + case "$phase" in SETUP) # remove semaphore repos, some of them don't work and cause error messages sudo rm -f /etc/apt/sources.list.d/* @@ -59,17 +61,17 @@ for phase in "${PHASES[@]}"; do sudo apt-get install -y -t "$UBUNTU_RELEASE-backports" lxc sudo apt-get install -y python3-debian git dpkg-dev fakeroot python3-jinja2 - [ -d $AUTOPKGTEST_DIR ] || git clone --quiet --depth=1 https://salsa.debian.org/ci-team/autopkgtest.git "$AUTOPKGTEST_DIR" + [ -d "$AUTOPKGTEST_DIR" ] || git clone --quiet --depth=1 https://salsa.debian.org/ci-team/autopkgtest.git "$AUTOPKGTEST_DIR" create_container ;; RUN) # add current debian/ packaging - git fetch --depth=1 https://salsa.debian.org/systemd-team/systemd.git $BRANCH + git fetch --depth=1 https://salsa.debian.org/systemd-team/systemd.git "$BRANCH" git checkout FETCH_HEAD debian # craft changelog - UPSTREAM_VER=$(git describe | sed 's/^v//;s/-/./g') + UPSTREAM_VER="$(git describe | sed 's/^v//;s/-/./g')" cat << EOF > debian/changelog.new systemd (${UPSTREAM_VER}.0) UNRELEASED; urgency=low @@ -78,7 +80,7 @@ systemd (${UPSTREAM_VER}.0) UNRELEASED; urgency=low -- systemd test <pkg-systemd-maintainers@lists.alioth.debian.org> $(date -R) EOF - cat debian/changelog >> debian/changelog.new + cat debian/changelog >>debian/changelog.new mv debian/changelog.new debian/changelog # clean out patches @@ -91,15 +93,15 @@ EOF echo '1.0' > debian/source/format # build source package - dpkg-buildpackage -S -I -I$(basename "$CACHE_DIR") -d -us -uc -nc + dpkg-buildpackage -S -I -I"$(basename "$CACHE_DIR")" -d -us -uc -nc # now build the package and run the tests rm -rf "$ARTIFACTS_DIR" # autopkgtest exits with 2 for "some tests skipped", accept that - $AUTOPKGTEST_DIR/runner/autopkgtest --env DEB_BUILD_OPTIONS=noudeb \ - --env TEST_UPSTREAM=1 ../systemd_*.dsc \ - -o "$ARTIFACTS_DIR" \ - -- lxc -s $CONTAINER \ + "$AUTOPKGTEST_DIR/runner/autopkgtest" --env DEB_BUILD_OPTIONS=noudeb \ + --env TEST_UPSTREAM=1 ../systemd_*.dsc \ + -o "$ARTIFACTS_DIR" \ + -- lxc -s "$CONTAINER" \ || [ $? -eq 2 ] ;; *) |