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

32 lines
1.3 KiB
Bash
Raw Normal View History

2020-03-24 09:27:15 +03:00
#!/bin/bash
################################################################################
## File: swift.sh
## Desc: Installs Swift
################################################################################
2020-03-25 11:25:36 +03:00
# Source the helpers for use with the script
source $HELPER_SCRIPTS/document.sh
2020-03-27 13:55:47 +03:00
# Install
2020-03-24 09:27:15 +03:00
image_label="$(lsb_release -rs)"
2020-03-27 14:52:12 +03:00
swift_version=$(curl -s https://swift.org/download/ | grep -m1 "id=\"swift-" | awk -F"[ <]" '{print $4}')
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
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-03-24 16:28:01 +03:00
ln -s "$SWIFT_BIN" /usr/local/bin/swift
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
# Document what was added to the image
echo "Lastly, documenting what we added to the metadata file"
2020-03-27 14:12:53 +03:00
DocumentInstalledItem "$(swift --version)"