-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInstallSwiftOnLinux.sh
More file actions
53 lines (44 loc) · 1.28 KB
/
Copy pathInstallSwiftOnLinux.sh
File metadata and controls
53 lines (44 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
dependencies=(
"binutils"
"git"
"libc6-dev"
"libedit2"
"libpython2.7"
"libsqlite3-0"
"libxml2"
"pkg-config"
"tzdata"
"wget"
"zlib1g-dev")
sudo apt-get update
sudo apt-get install -y git
sudo apt-get install -y lsb-core
version=$(lsb_release -rs | cut -c1-2)
case "$version" in
16) dependencies+=("libcurl3" "libgcc-5-dev" "libstdc++-5-dev")
;;
18) dependencies+=("libcurl4" "libgcc-5-dev" "libstdc++-5-dev")
;;
20) dependencies+=("gnupg2" "libcurl4" "libgcc-9-dev" "libstdc++-9-dev" "libz3-dev")
;;
*) echo "Supported OS versions are Ubuntu 16.x, 18.x and 20.x"
exit
;;
esac
echo "Installing dependencies:"
sudo apt-get update
for dep in ${dependencies[*]}; do
sudo apt-get install $dep
done
echo "Downloading Swift:"
swift_link="https://swift.org/builds/swift-5.3.3-release/ubuntu"$version"04/swift-5.3.3-RELEASE/swift-5.3.3-RELEASE-ubuntu"$version".04.tar.gz"
wget -c -O "swift.tar.gz" "$swift_link"
mkdir "swift"
tar -C "swift" -xvf "swift.tar.gz" --strip-components 1
rm -f swift.tar.gz
sudo mv ./swift /usr/share/swift
printf "\nexport PATH=\"/usr/share/swift/usr/bin:\$PATH\"\n" >> ~/.bashrc
echo "Swift is installed at /usr/share/swift!"
echo "Run 'swift --version' to check if Swift is installed correctly"
echo "Close and reopen terminal to continue..."