From c79bc2eb8eedae6c023fd691469c13b89f719ad4 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 4 Jul 2018 15:27:23 -0700 Subject: [PATCH] Oops, this wrote a hash.txt file to the working dir --- testing/get-swift.sh | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/testing/get-swift.sh b/testing/get-swift.sh index 54a37e58..28986a5f 100755 --- a/testing/get-swift.sh +++ b/testing/get-swift.sh @@ -1,26 +1,27 @@ #!/usr/bin/env bash # This is a script used in travis-ci to install swift -set -ex +set -euxo pipefail . /etc/lsb-release if [ "$DISTRIB_CODENAME" = "trusty" ]; then - SWIFT_TARBALL="swift-4.0.3-RELEASE-ubuntu14.04.tar.gz" + SWIFT_URL='https://swift.org/builds/swift-4.0.3-release/ubuntu1404/swift-4.0.3-RELEASE/swift-4.0.3-RELEASE-ubuntu14.04.tar.gz' SWIFT_HASH="dddb40ec4956e4f6a3f4532d859691d5d1ba8822f6e8b4ec6c452172dbede5ae" - SWIFT_URL="https://swift.org/builds/swift-4.0.3-release/ubuntu1404/swift-4.0.3-RELEASE/$SWIFT_TARBALL" else - SWIFT_TARBALL="swift-4.0.3-RELEASE-ubuntu16.04.tar.gz" + SWIFT_URL='https://swift.org/builds/swift-4.0.3-release/ubuntu1604/swift-4.0.3-RELEASE/swift-4.0.3-RELEASE-ubuntu16.04.tar.gz' SWIFT_HASH="9adf64cabc7c02ea2d08f150b449b05e46bd42d6e542bf742b3674f5c37f0dbf" - SWIFT_URL="https://swift.org/builds/swift-4.0.3-release/ubuntu1604/swift-4.0.3-RELEASE/$SWIFT_TARBALL" fi -mkdir -p "$HOME"/.swift -pushd "$HOME"/.swift - wget -N -c "$SWIFT_URL" - echo "$SWIFT_HASH $SWIFT_TARBALL" > hash.txt - shasum -a 256 -c hash.txt -popd +check() { + echo "$SWIFT_HASH $TGZ" | sha256sum --check +} + +TGZ="$HOME/.swift/swift.tar.gz" +mkdir -p "$(dirname "$TGZ")" +if ! check >& /dev/null; then + rm -f "$TGZ" + curl --location --silent --output "$TGZ" "$SWIFT_URL" + check +fi mkdir -p /tmp/swift -pushd /tmp/swift - tar -xf "$HOME"/.swift/"$SWIFT_TARBALL" --strip 1 -popd +tar -xf "$TGZ" --strip 1 --directory /tmp/swift