From ce19d6dadb7420aad1c1e0f7a4e68eb8bed4624f Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Mon, 13 Jul 2020 09:35:08 -0500 Subject: [PATCH] edgexfoundry-snapcraft.sh: use && instead of ; between cmds The previous behavior would not actually fail the build setup if for example the SHA's didn't match, but now if the SHA's don't match, sha512sum will exit non-zero and using && results in the whole command failing. We also should delete the sha512 file as well, it is not needed during the build. Fixes: https://github.com/edgexfoundry/ci-management/issues/517 Signed-off-by: Ian Johnson --- shell/edgexfoundry-snapcraft.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/shell/edgexfoundry-snapcraft.sh b/shell/edgexfoundry-snapcraft.sh index e3706a5f..c1bc7235 100755 --- a/shell/edgexfoundry-snapcraft.sh +++ b/shell/edgexfoundry-snapcraft.sh @@ -128,20 +128,20 @@ ARG ARCH # We do this because we can't easily run snapd (and thus snaps) inside a # docker container without disabling important security protections enabled # for docker containers. -# TODO: add a little bit of error checking for the curl calls in case we ever -# are on a proxy or something and we end up downloading a login page or -# or something like that RUN apt-get update && \ apt-get dist-upgrade --yes && \ apt-get install --yes \ curl sudo jq squashfs-tools && \ for thesnap in core core18 snapcraft; do \ - dlUrl=$(curl -s -H 'X-Ubuntu-Series: 16' -H "X-Ubuntu-Architecture: $ARCH" "https://api.snapcraft.io/api/v1/snaps/details/$thesnap" | jq '.download_url' -r); \ - dlSHA=$(curl -s -H 'X-Ubuntu-Series: 16' -H "X-Ubuntu-Architecture: $ARCH" "https://api.snapcraft.io/api/v1/snaps/details/$thesnap" | jq '.download_sha512' -r); \ - curl -s -L $dlUrl --output $thesnap.snap; \ - echo "$dlSHA $thesnap.snap" > $thesnap.snap.sha512; \ - sha512sum -c $thesnap.snap.sha512; \ - mkdir -p /snap/$thesnap && unsquashfs -n -d /snap/$thesnap/current $thesnap.snap && rm $thesnap.snap; \ + dlUrl=$(curl -s -H 'X-Ubuntu-Series: 16' -H "X-Ubuntu-Architecture: $ARCH" "https://api.snapcraft.io/api/v1/snaps/details/$thesnap" | jq '.download_url' -r) && \ + dlSHA=$(curl -s -H 'X-Ubuntu-Series: 16' -H "X-Ubuntu-Architecture: $ARCH" "https://api.snapcraft.io/api/v1/snaps/details/$thesnap" | jq '.download_sha512' -r) && \ + curl -s -L $dlUrl --output $thesnap.snap && \ + echo "$dlSHA $thesnap.snap" > $thesnap.snap.sha512 && \ + sha512sum -c $thesnap.snap.sha512 && \ + mkdir -p /snap/$thesnap && \ + unsquashfs -n -d /snap/$thesnap/current $thesnap.snap && \ + rm $thesnap.snap.sha512 && \ + rm $thesnap.snap; \ done && \ apt remove --yes --purge curl jq squashfs-tools && \ apt-get autoclean --yes && \