Skip to content

Instantly share code, notes, and snippets.

@daltonclaybrook
Created April 7, 2024 04:26
Show Gist options
  • Save daltonclaybrook/3c51ec4cc5435b9a4e1c68925f112d16 to your computer and use it in GitHub Desktop.
Save daltonclaybrook/3c51ec4cc5435b9a4e1c68925f112d16 to your computer and use it in GitHub Desktop.
Gist for installing Swift on Fedora
#!/bin/bash
yum -y install \
git \
gcc-c++ \
libcurl-devel \
libedit-devel \
libuuid-devel \
libxml2-devel \
ncurses-devel \
python3-devel \
python3.9 \
rsync \
sqlite-devel \
unzip \
zip
export SWIFT_SIGNING_KEY=A62AE125BBBFBB96A6E042EC925CC1CCED3D1561
export SWIFT_PLATFORM=ubi9
export SWIFT_BRANCH=swift-5.10-release
export SWIFT_VERSION=swift-5.10-RELEASE
export SWIFT_WEBROOT=https://download.swift.org
set -e;
ARCH_NAME="$(rpm --eval '%{_arch}')";
url=;
case "${ARCH_NAME##*-}" in
'x86_64')
OS_ARCH_SUFFIX='';
;;
'aarch64')
OS_ARCH_SUFFIX='-aarch64';
;;
*) echo >&2 "error: unsupported architecture: '$ARCH_NAME'"; exit 1 ;;
esac;
SWIFT_WEBDIR="$SWIFT_WEBROOT/$SWIFT_BRANCH/$(echo $SWIFT_PLATFORM | tr -d .)$OS_ARCH_SUFFIX"
SWIFT_BIN_URL="$SWIFT_WEBDIR/$SWIFT_VERSION/$SWIFT_VERSION-$SWIFT_PLATFORM$OS_ARCH_SUFFIX.tar.gz"
SWIFT_SIG_URL="$SWIFT_BIN_URL.sig"
echo $SWIFT_BIN_URL
# - Download the GPG keys, Swift toolchain, and toolchain signature, and verify.
export GNUPGHOME="$(mktemp -d)"
curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_SIG_URL" -o swift.tar.gz.sig
gpg --batch --quiet --keyserver keyserver.ubuntu.com --recv-keys "$SWIFT_SIGNING_KEY"
gpg --batch --verify swift.tar.gz.sig swift.tar.gz
# - Unpack the toolchain, set libs permissions, and clean up.
tar -xzf swift.tar.gz --directory / --strip-components=1
chmod -R o+r /usr/lib/swift
rm -rf "$GNUPGHOME" swift.tar.gz.sig swift.tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment