Files
runner-images/images/linux/scripts/installers/swift.sh
T

34 lines
1.2 KiB
Bash
Raw Normal View History

2020-10-07 13:49:40 +05:00
#!/bin/bash -e
2020-03-24 09:27:15 +03:00
################################################################################
## File: swift.sh
## Desc: Installs Swift
################################################################################
2020-03-27 13:55:47 +03:00
# Install
2020-03-24 09:27:15 +03:00
image_label="$(lsb_release -rs)"
2020-10-07 13:49:40 +05:00
swift_version=$(curl -s -L -N https://swift.org/download|awk -F"[ <]" '/id="swift-/ {print $4; exit}')
2020-03-24 15:56:42 +03:00
wget -P /tmp https://swift.org/builds/swift-$swift_version-release/ubuntu${image_label//./}/swift-$swift_version-RELEASE/swift-$swift_version-RELEASE-ubuntu$image_label.tar.gz
2020-10-07 13:49:40 +05:00
2020-03-24 15:56:42 +03:00
tar xzf /tmp/swift-$swift_version-RELEASE-ubuntu$image_label.tar.gz
2020-03-24 16:28:01 +03:00
mv swift-$swift_version-RELEASE-ubuntu$image_label /usr/share/swift
2020-03-24 15:56:42 +03:00
SWIFT_PATH="/usr/share/swift/usr/bin"
2020-03-25 09:26:22 +03:00
SWIFT_BIN="$SWIFT_PATH/swift"
2020-10-20 11:45:08 +03:00
SWIFTC_BIN="$SWIFT_PATH/swiftc"
2020-03-24 16:28:01 +03:00
ln -s "$SWIFT_BIN" /usr/local/bin/swift
2020-10-20 11:45:08 +03:00
ln -s "$SWIFTC_BIN" /usr/local/bin/swiftc
2020-03-24 16:28:01 +03:00
echo "SWIFT_PATH=$SWIFT_PATH" | tee -a /etc/environment
2020-03-24 09:27:15 +03:00
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v swift; then
echo "Swift was not installed"
exit 1
fi
2020-10-20 11:45:08 +03:00
if ! command -v swiftc; then
echo "Swiftc is not linked to swift binary"
exit 1
fi