Skip to content

Instantly share code, notes, and snippets.

@v57
Created May 29, 2017 21:32
Show Gist options
  • Save v57/9379998bf0b87a9f0bb5ff730914e7d4 to your computer and use it in GitHub Desktop.
Save v57/9379998bf0b87a9f0bb5ff730914e7d4 to your computer and use it in GitHub Desktop.
Install Swift 3.1 on Ubuntu 16.10 / 17.04
#!/bin/bash
# Copyright (C) 2017 PerfectlySoft Inc.
# Author: Jonathan Guthrie <[email protected]>
WEBLOC=https://swift.org/builds/swift-3.1.1-release/ubuntu1610/swift-3.1.1-RELEASE/swift-3.1.1-RELEASE-ubuntu16.10.tar.gz
SWIFTNAME=$(basename $WEBLOC)
MYDIR=$(dirname $0)
MYNAME=$(basename $0)
MYSUM=$(md5sum $MYDIR/$MYNAME)
# We want to be self-invoked
if [ "$1" != "--self-invoked" ]; then
# We want to be sure that installation is ok
if [ "$1" != "--sure" ]; then
echo This script will install Swift from: $WEBLOC
echo If you\'re sure about this, re-run the script like this:
echo \ \ $0 --sure
exit 2
fi
echo Invoking self...
exec $MYDIR/$MYNAME --self-invoked
fi
apt-get -y update
apt-get install -y clang pkg-config libicu-dev libpython2.7 libxml2-dev wget git libssl-dev uuid-dev libsqlite3-dev libpq-dev libmysqlclient-dev libbson-dev libmongoc-dev libcurl4-openssl-dev
sed -i -e 's/-fabi-version=2 -fno-omit-frame-pointer//g' /usr/lib/x86_64-linux-gnu/pkgconfig/mysqlclient.pc
ln -s /usr/include/libmongoc-1.0 /usr/local/include/libmongoc-1.0
echo Downloading $WEBLOC ...
wget $WEBLOC
echo Installing Swift...
gunzip < $SWIFTNAME | tar -C / -xv --strip-components 1
echo Cleaning up download...
rm $SWIFTNAME
chmod -R 755 /usr/lib/swift/
# Add to avoid the dreaded "error while loading shared libraries: libswiftCore.so: cannot open shared object file: No such file or directory"
touch /etc/ld.so.conf.d/swift.conf
echo "/usr/lib/swift/linux" >> /etc/ld.so.conf.d/swift.conf
ldconfig
echo All done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment