Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c79bc2e

Browse files
committed
Oops, this wrote a hash.txt file to the working dir
1 parent 50fe51f commit c79bc2e

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

testing/get-swift.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
#!/usr/bin/env bash
22
# This is a script used in travis-ci to install swift
3-
set -ex
3+
set -euxo pipefail
44

55
. /etc/lsb-release
66
if [ "$DISTRIB_CODENAME" = "trusty" ]; then
7-
SWIFT_TARBALL="swift-4.0.3-RELEASE-ubuntu14.04.tar.gz"
7+
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'
88
SWIFT_HASH="dddb40ec4956e4f6a3f4532d859691d5d1ba8822f6e8b4ec6c452172dbede5ae"
9-
SWIFT_URL="https://swift.org/builds/swift-4.0.3-release/ubuntu1404/swift-4.0.3-RELEASE/$SWIFT_TARBALL"
109
else
11-
SWIFT_TARBALL="swift-4.0.3-RELEASE-ubuntu16.04.tar.gz"
10+
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'
1211
SWIFT_HASH="9adf64cabc7c02ea2d08f150b449b05e46bd42d6e542bf742b3674f5c37f0dbf"
13-
SWIFT_URL="https://swift.org/builds/swift-4.0.3-release/ubuntu1604/swift-4.0.3-RELEASE/$SWIFT_TARBALL"
1412
fi
1513

16-
mkdir -p "$HOME"/.swift
17-
pushd "$HOME"/.swift
18-
wget -N -c "$SWIFT_URL"
19-
echo "$SWIFT_HASH $SWIFT_TARBALL" > hash.txt
20-
shasum -a 256 -c hash.txt
21-
popd
14+
check() {
15+
echo "$SWIFT_HASH $TGZ" | sha256sum --check
16+
}
17+
18+
TGZ="$HOME/.swift/swift.tar.gz"
19+
mkdir -p "$(dirname "$TGZ")"
20+
if ! check >& /dev/null; then
21+
rm -f "$TGZ"
22+
curl --location --silent --output "$TGZ" "$SWIFT_URL"
23+
check
24+
fi
2225

2326
mkdir -p /tmp/swift
24-
pushd /tmp/swift
25-
tar -xf "$HOME"/.swift/"$SWIFT_TARBALL" --strip 1
26-
popd
27+
tar -xf "$TGZ" --strip 1 --directory /tmp/swift

0 commit comments

Comments
 (0)