From b0b1043aa1ba23e3b18b49cebcbe3655743cdaad Mon Sep 17 00:00:00 2001 From: Patrick Freed Date: Sun, 20 Aug 2023 16:28:58 -0400 Subject: [PATCH 01/11] 0.1.0 release of swiftly-install.sh --- swiftly-install.sh | 480 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 480 insertions(+) create mode 100755 swiftly-install.sh diff --git a/swiftly-install.sh b/swiftly-install.sh new file mode 100755 index 00000000..9e97c990 --- /dev/null +++ b/swiftly-install.sh @@ -0,0 +1,480 @@ +#!/usr/bin/env bash + +# swiftly-install +# Script used to install and configure swiftly. +# +# This script will download the latest released swiftly executable and install it +# to $SWIFTLY_BIN_DIR, or ~/.local/bin if that variable isn't specified. +# +# This script will also create a directory at $SWIFTLY_HOME_DIR, or +# $XDG_DATA_HOME/swiftly if that variable isn't specified. If XDG_DATA_HOME is also unset, +# ~/.local/share/swiftly will be used as a default instead. swiftly will use this directory +# to store platform information, downloaded toolchains, and other state required to manage +# the toolchains. +# +# After installation, the script will create $SWIFTLY_HOME_DIR/env.sh, which can be sourced +# to properly set up the environment variables required to run swiftly. Unless --no-modify-profile +# was specified, the script will also update ~/.profile, ~/.bash_profile, ~/.bash_login, or ~/.zprofile, +# depending on the value of $SHELL and the existence of the files, to source the env.sh file on login. +# This will ensure that future logins will automatically configure SWIFTLY_HOME_DIR, SWIFTLY_BIN_DIR, +# and PATH. +# +# Unless the --disable-confirmation flag is set, this script will allow the runner to +# configure either of those two directory paths. +# +# Unless the --no-install-system-deps flag is set, this script will attempt to install Swift's +# system dependencies using the system package manager. +# +# curl is required to run this script. + +set -o errexit +shopt -s extglob + +has_command () { + command -v "$1" > /dev/null +} + +read_input_with_default () { + echo -n "> " + # The installer script is usually run by "curl ... | bash", which means that + # stdin is not a tty but the script content itself. In that case, "read" builtin + # command receives EOF immediately. To avoid that, we use /dev/tty as stdin explicitly. + # SWIFTLY_READ_FROM_STDIN is used for testing interactive input + if [[ -t 0 ]] || [[ ${SWIFTLY_READ_FROM_STDIN+set} == "set" ]]; then + read READ_INPUT_RETURN + else + read READ_INPUT_RETURN < /dev/tty + fi + + if [ -z "$READ_INPUT_RETURN" ]; then + READ_INPUT_RETURN="$1" + fi +} + +yn_prompt () { + if [[ "$1" == "true" ]]; then + echo "(Y/n)" + else + echo "(y/N)" + fi +} + +# Read a y/n input. +# First argument is the default value (must be "true" or "false"). +# +# Sets READ_INPUT_RETURN to "true" for an input of "y" or "Y", "false" for an input +# of "n" or "N", or the default value for a blank input +# +# For all other inputs, a message is printed and the user is prompted again. +read_yn_input () { + while [[ true ]]; do + read_input_with_default "$1" + + case "$READ_INPUT_RETURN" in + "y" | "Y") + READ_INPUT_RETURN="true" + return + ;; + + "n" | "N") + READ_INPUT_RETURN="false" + return + ;; + + "$1") + return + ;; + + *) + echo "Please input either \"y\" or \"n\", or press ENTER to use the default." + ;; + esac + done +} + +# Replaces the actual path to $HOME at the beginning of the provided string argument with +# the string "$HOME". This is used when printing to stdout. +# e.g. "home/user/.local/bin" => "$HOME/.local/bin" +replace_home_path () { + if [[ "$1" =~ ^"$HOME"(/|$) ]]; then + echo "\$HOME${1#$HOME}" + else + echo "$1" + fi +} + +# Replaces the string "$HOME" or "~" in the argument with the actual value of $HOME. +# e.g. "$HOME/.local/bin" => "/home/user/.local/bin" +# e.g. "~/.local/bin" => "/home/user/.local/bin" +expand_home_path () { + echo "${1/#@(~|\$HOME)/$HOME}" +} + +# Prints the provided argument using the terminal's bold text effect. +bold () { + echo "$(tput bold)$1$(tput sgr0)" +} + +# Fetch the list of required system dependencies from the apple/swift-docker +# repository and attempt to install them using the system's package manager. +# +# $docker_platform_name, $docker_platform_version, and $package manager need +# to be set before calling this function. +install_system_deps () { + if [[ "$(id --user)" != "0" ]] && ! has_command sudo ; then + echo "Warning: sudo not installed and current user is not root, skipping system dependency installation." + return + elif ! has_command "$package_manager" ; then + echo "Warning: package manager \"$package_manager\" not found, skipping system dependency installation." + return + fi + + dockerfile_url="https://raw.githubusercontent.com/apple/swift-docker/main/nightly-main/$docker_platform_name/$docker_platform_version/Dockerfile" + dockerfile="$(curl --silent --retry 3 --location --fail $dockerfile_url)" + if [[ "$?" -ne 0 ]]; then + echo "Error enumerating system dependencies, skipping installation of system dependencies." + fi + + # Find the line number of the RUN command associated with installing system dependencies. + beg_line_num=$(printf "$dockerfile" | grep -n --max-count=1 "$package_manager.*install" | cut -d ":" -f1) + + # Starting from there, find the first line that starts with an & or doesn't end in a backslash. + relative_end_line_num=$(printf "$dockerfile" | + tail --lines=+"$((beg_line_num + 1))" | + grep -n --max-count=1 --invert-match '[[:space:]]*[^&].*\\$' | cut -d ":" -f1) + end_line_num=$((beg_line_num + relative_end_line_num)) + + # Read the lines between those two, deleting any spaces and backslashes. + readarray -t package_list < <(printf "$dockerfile" | sed -n "$((beg_line_num + 1)),${end_line_num}p" | sed -r 's/[\ ]//g') + + # If the installation command from the Dockerfile included some cleanup as part of a second command, drop that. + if [[ "${package_list[-1]}" =~ ^\&\& ]]; then + unset 'package_list[-1]' + fi + + install_args=(--quiet) + if [[ "$DISABLE_CONFIRMATION" == "true" ]]; then + install_args+=(-y) + fi + + # Disable errexit since failing to install system dependencies is not swiftly installation-fatal. + set +o errexit + if [[ "$(id --user)" == "0" ]]; then + "$package_manager" install "${install_args[@]}" "${package_list[@]}" + else + sudo "$package_manager" install "${install_args[@]}" "${package_list[@]}" + fi + if [[ "$?" -ne 0 ]]; then + echo "System dependency installation failed." + if [[ "$package_manager" == "apt-get" ]]; then + echo "You may need to run apt-get update before installing system dependencies." + fi + fi + set -o errexit +} + +SWIFTLY_INSTALL_VERSION="0.1.0" + +MODIFY_PROFILE="true" +SWIFTLY_INSTALL_SYSTEM_DEPS="true" + +for arg in "$@"; do + case "$arg" in + "--help" | "-h") + cat < "$HOME_DIR/config.json" + +# Verify the downloaded executable works. The script will exit if this fails due to errexit. +SWIFTLY_HOME_DIR="$HOME_DIR" SWIFTLY_BIN_DIR="$BIN_DIR" "$BIN_DIR/swiftly" --version > /dev/null + +ENV_OUT=$(cat < "$HOME_DIR/env.sh" + +if [[ "$MODIFY_PROFILE" == "true" ]]; then + SOURCE_LINE=". $(replace_home_path $HOME_DIR)/env.sh" + + # Only append the line if it isn't in .profile already. + if [[ ! -f "$PROFILE_FILE" ]] || [[ ! "$(cat $PROFILE_FILE)" =~ "$SOURCE_LINE" ]]; then + echo "$SOURCE_LINE" >> "$PROFILE_FILE" + fi +fi + +if [[ "$SWIFTLY_INSTALL_SYSTEM_DEPS" != "false" ]]; then + echo "" + echo "Installing Swift's system dependencies via $package_manager (note: this may require root access)..." + install_system_deps +fi + +echo "" +echo "swiftly has been succesfully installed!" +echo "" + +if ! has_command "swiftly" || [[ "$HOME_DIR" != "$DEFAULT_HOME_DIR" || "$BIN_DIR" != "$DEFAULT_BIN_DIR" ]] ; then + echo "Once you log in again, swiftly should be accessible from your PATH." + echo "To begin using swiftly from your current shell, first run the following command:" + echo "" + echo " . $(replace_home_path $HOME_DIR)/env.sh" + echo "" + echo "Then to install the latest version of Swift, run 'swiftly install latest'" +else + echo "To install the latest version of Swift, run 'swiftly install latest'" +fi From 7cc491d67f501bccf6cf574feaa68b28fcd47feb Mon Sep 17 00:00:00 2001 From: Patrick Freed Date: Sun, 20 Aug 2023 22:24:01 -0400 Subject: [PATCH 02/11] cherry-pick system dep installation confirmation changes (0.1.0) --- swiftly-install.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/swiftly-install.sh b/swiftly-install.sh index 9e97c990..d2eb3a32 100755 --- a/swiftly-install.sh +++ b/swiftly-install.sh @@ -152,10 +152,7 @@ install_system_deps () { unset 'package_list[-1]' fi - install_args=(--quiet) - if [[ "$DISABLE_CONFIRMATION" == "true" ]]; then - install_args+=(-y) - fi + install_args=(--quiet -y) # Disable errexit since failing to install system dependencies is not swiftly installation-fatal. set +o errexit @@ -250,6 +247,7 @@ case "$ID" in "ubuntu") docker_platform_name="ubuntu" package_manager="apt-get" + export DEBIAN_FRONTEND=noninteractive case "$UBUNTU_CODENAME" in "jammy") PLATFORM_NAME="ubuntu2204" From da28053f0144346ed9e56954b4fa16f59ad2c4b4 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Fri, 25 Aug 2023 22:18:23 +0100 Subject: [PATCH 03/11] Add installation website (#57) --- css/font.css | 32 +++++++++++++++ favicon.ico | Bin 0 -> 34494 bytes images/swift_logo_color.png | Bin 0 -> 10719 bytes index.html | 78 ++++++++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 css/font.css create mode 100644 favicon.ico create mode 100644 images/swift_logo_color.png create mode 100644 index.html diff --git a/css/font.css b/css/font.css new file mode 100644 index 00000000..ffd70fc1 --- /dev/null +++ b/css/font.css @@ -0,0 +1,32 @@ +body { + font-family: -apple-system, BlinkMacSystemFont, "SF Hello", "Helvetica Neue", Helvetica, Arial, Verdana, sans-serif; + font-size: 18px; + line-height: 1.5; + font-weight: 300; + + pre, code { + font-family: "SF Mono", Menlo, Consolas, Monaco, "Courier New", monospace, serif; + } +} + +.terminal { + white-space: nowrap; + overflow: scroll; +} + +.left { + display: inline-block; + max-width: calc(100% - 60px); +} +.right { + display: inline-block; + max-width: 50px; +} +#copy-button:active { + color: #888; +} +#gh-link { + display:flex; + align-items:center; + justify-content:center; +} \ No newline at end of file diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..51b4365a98a8842151d14a36a27abc93c3cc6fc4 GIT binary patch literal 34494 zcmeI5MUZ4S5zk1qsDWY2N1*ud@N@b?hrP7~De<>}qOiBD1rCtAAD$OgE zO3N-=j-T?^QfZN-&6rV+-z@po`dg{A{PLCfKT4%v|6VH1o?VVFw_2%m(Hf=Fa#Dw6 zl^VzUL(FmHEY@1!*Pv(K@8uBUG@Ja4==T9Z%vZhiVPI$A9Y z9&lfOKi;tXK_~aQp`i))YuC8z?VoVRpV#l6du7CzfBVDw?eBOubkN+g6(T&(5{=?|Qhv^T@DUp~<;If3%(H<_8yr9Eq$m zvQ(91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qN zlo(T|u97!vn4(ZQ@p~qb%qO^2byB4!lTa8;B%H*I_4w?4lsKJ+S3P%fM1bgI1gvbAq|~E_ zt_f#0Yz}M+olc&EM(Q&mPZ-c{7qjKZIy!r6>Yr&nCSD*}84QZQ=NC&U`@Mn?-%96M zn3s1?{_E{eS!%??zU+ecYIxddZt*uL4h1PBaAN42o?m`bw2e&S#l-i-u2>GY;;6Gf z&D#tZ*e=d4SJ&uzSz;`ck??hAP<|_)-ufaT4Hj$(5~oV?94$1#3jw&yYI3r-j9QGmM*5OMTGV3hwwF1n{A@`eWe%O y#@69wwHm9us~3EVxRIYEqf7g58I0{-0{l*fllI!{u&#fDsG_K;P%d{b + + + + + Codestin Search App + + + + + +
+
+ +

swiftly

+

+ A Swift toolchain installer and manager, written in Swift. +

+
+
+
+
+
+ To install swiftly, run the following command in your terminal. +
+
+
+
+ $ curl -L https://swift-server.github.io/swiftly/swiftly-install.sh | bash +
+ +
+
+
+
+
+
+
+
+

+ Swiftly is a Swift Server Working Group project. +

+ + + +
+
+
+ + + + + + + + + + + + + + From e7f58d892d40d2b13dab1676fce0a16356f915e4 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Thu, 31 Aug 2023 18:19:04 +0100 Subject: [PATCH 04/11] Add only available for Linux text (#59) --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index f9fdd1d0..18f6fadf 100644 --- a/index.html +++ b/index.html @@ -34,6 +34,7 @@

swiftly

+

Swiftly is currently only available for Linux.

From 623631c47261d44aa4f82e6fbfaa9e32ad1dd8f0 Mon Sep 17 00:00:00 2001 From: Patrick Freed Date: Sat, 23 Sep 2023 20:09:29 -0400 Subject: [PATCH 05/11] Deploy swiftly-install 0.2.0 This includes support for auto-detecting derived platforms (e.g. Linux Mint) and for allowing users to manually specify the platform they want to download toolchains from, either interactively if a platform cannot be detected or manually via a command line option. --- swiftly-install.sh | 307 ++++++++++++++++++++++++++++++++------------- 1 file changed, 221 insertions(+), 86 deletions(-) diff --git a/swiftly-install.sh b/swiftly-install.sh index d2eb3a32..086047bb 100755 --- a/swiftly-install.sh +++ b/swiftly-install.sh @@ -25,10 +25,7 @@ # Unless the --no-install-system-deps flag is set, this script will attempt to install Swift's # system dependencies using the system package manager. # -# curl is required to run this script. - -set -o errexit -shopt -s extglob +# curl and getopt (from the util-linux package) are required to run this script. has_command () { command -v "$1" > /dev/null @@ -170,26 +167,198 @@ install_system_deps () { set -o errexit } -SWIFTLY_INSTALL_VERSION="0.1.0" +set_platform_ubuntu () { + docker_platform_name="ubuntu" + package_manager="apt-get" + export DEBIAN_FRONTEND=noninteractive + + PLATFORM_NAME="ubuntu$1$2" + PLATFORM_NAME_FULL="ubuntu$1.$2" + docker_platform_version="$1.$2" + + if [[ -z "$PLATFORM_NAME_PRETTY" ]]; then + PLATFORM_NAME_PRETTY="Ubuntu $1.$2" + fi +} + +set_platform_amazonlinux () { + PLATFORM_NAME="amazonlinux$1" + PLATFORM_NAME_FULL="amazonlinux$1" + docker_platform_name="amazonlinux" + docker_platform_version="$1" + package_manager="yum" + + if [[ -z "$PLATFORM_NAME_PRETTY" ]]; then + PLATFORM_NAME_PRETTY="Amazon Linux $1" + fi +} + +set_platform_rhel () { + PLATFORM_NAME="ubi$1" + PLATFORM_NAME_FULL="ubi$1" + docker_platform_name="rhel-ubi" + docker_platform_version="$1" + package_manager="yum" + + if [[ -z "$PLATFORM_NAME_PRETTY" ]]; then + PLATFORM_NAME_PRETTY="RHEL 9" + fi +} + +detect_platform () { + if [[ -f "/etc/os-release" ]]; then + OS_RELEASE="/etc/os-release" + elif [[ -f "/usr/lib/os-release" ]]; then + OS_RELEASE="/usr/lib/os-release" + else + manually_select_platform + fi + + source "$OS_RELEASE" + PLATFORM_NAME_PRETTY="$PRETTY_NAME" + + case "$ID$ID_LIKE" in + *"amzn"*) + if [[ "$VERSION_ID" != "2" ]]; then + manually_select_platform + else + set_platform_amazonlinux "2" + fi + ;; + + *"ubuntu"*) + case "$UBUNTU_CODENAME" in + "jammy") + set_platform_ubuntu "22" "04" + ;; + + "focal") + set_platform_ubuntu "20" "04" + ;; + + "bionic") + set_platform_ubuntu "18" "04" + ;; + + *) + manually_select_platform + ;; + esac + ;; + + *"rhel"*) + if [[ "$VERSION_ID" != 9* ]]; then + manually_select_platform + else + set_platform_rhel "9" + fi + ;; + + *) + manually_select_platform + ;; + esac +} + +manually_select_platform () { + if [[ "$DISABLE_CONFIRMATION" == "true" ]]; then + echo "Error: Unsupported platform: $PRETTY_NAME" + exit 1 + fi + echo "$PLATFORM_NAME_PRETTY is not an officially supported platform, but the toolchains for another platform may still work on it." + echo "" + echo "Please select the platform to use for toolchain downloads:" + + echo "0) Cancel" + echo "1) Ubuntu 22.04" + echo "2) Ubuntu 20.04" + echo "3) Ubuntu 18.04" + echo "4) RHEL 9" + echo "5) Amazon Linux 2" + + read_input_with_default "0" + case "$READ_INPUT_RETURN" in + "1" | "1)") + set_platform_ubuntu "22" "04" + ;; + + "2" | "2)") + set_platform_ubuntu "20" "04" + ;; + + "3" | "3)") + set_platform_ubuntu "18" "04" + ;; + + "4" | "4)") + set_platform_rhel "9" + ;; + + "5" | "5)") + set_platform_amazonlinux "2" + ;; + + *) + echo "Cancelling installation." + exit 0 + ;; + esac +} + +verify_getopt_install () { + if ! has_command "getopt" ; then + return 1 + fi + + getopt --test + # getopt --test exiting with status code 4 implies getopt from util-linux is being used, which we need. + [[ "$?" -eq 4 ]] + return "$?" +} + +SWIFTLY_INSTALL_VERSION="0.2.0" MODIFY_PROFILE="true" SWIFTLY_INSTALL_SYSTEM_DEPS="true" -for arg in "$@"; do - case "$arg" in +if ! has_command "curl" ; then + echo "Error: curl must be installed to download swiftly" + exit 1 +fi + +if ! verify_getopt_install ; then + echo "Error: getopt must be installed from the util-linux package to run swiftly-install" + exit 1 +fi + +set -o errexit +shopt -s extglob + +short_options='yhvp:' +long_options='disable-confirmation,no-modify-profile,no-install-system-deps,help,version,platform:' + +args=$(getopt --options "$short_options" --longoptions "$long_options" --name "swiftly-install" -- "${@}") +eval "set -- ${args}" + +while [ true ]; do + case "$1" in "--help" | "-h") cat < Specifies which platform's toolchains swiftly will download. If + unspecified, the platform will be automatically detected. Available + options are "ubuntu22.04", "ubuntu20.04", "ubuntu18.04", "rhel9", and + "amazonlinux2". -h, --help Prints help information. --version Prints version information. EOF @@ -198,14 +367,17 @@ EOF "--disable-confirmation" | "-y") DISABLE_CONFIRMATION="true" + shift ;; "--no-modify-profile") MODIFY_PROFILE="false" + shift ;; "--no-install-system-deps") SWIFTLY_INSTALL_SYSTEM_DEPS="false" + shift ;; "--version") @@ -213,85 +385,52 @@ EOF exit 0 ;; + "--platform" | "-p") + case "$2" in + "ubuntu22.04") + set_platform_ubuntu "22" "04" + ;; + + "ubuntu20.04") + set_platform_ubuntu "20" "04" + ;; + + "ubuntu18.04") + set_platform_ubuntu "18" "04" + ;; + + "amazonlinux2") + set_platform_amazonlinux "2" + ;; + + "rhel9") + set_platform_rhel "9" + ;; + + *) + echo "Error: unrecognized platform $2" + exit 1 + ;; + esac + shift 2 + ;; + + --) + shift + break + ;; + *) - echo "Error: unrecognized flag \"$arg\"" + echo "Error: unrecognized option \"$arg\"" exit 1 ;; esac done -if [[ -f "/etc/os-release" ]]; then - OS_RELEASE="/etc/os-release" -elif [[ -f "/usr/lib/os-release" ]]; then - OS_RELEASE="/usr/lib/os-release" -else - echo "Error: could not detect OS information" - exit 1 +if [[ -z "$PLATFORM_NAME" ]]; then + detect_platform fi -source "$OS_RELEASE" - -case "$ID" in - "amzn") - if [[ "$VERSION_ID" != "2" ]]; then - echo "Error: Unsupported Amazon Linux version: $PRETTY_NAME" - exit 1 - fi - PLATFORM_NAME="amazonlinux2" - PLATFORM_NAME_FULL="amazonlinux2" - docker_platform_name="amazonlinux" - docker_platform_version="2" - package_manager="yum" - ;; - - "ubuntu") - docker_platform_name="ubuntu" - package_manager="apt-get" - export DEBIAN_FRONTEND=noninteractive - case "$UBUNTU_CODENAME" in - "jammy") - PLATFORM_NAME="ubuntu2204" - PLATFORM_NAME_FULL="ubuntu22.04" - docker_platform_version="22.04" - ;; - - "focal") - PLATFORM_NAME="ubuntu2004" - PLATFORM_NAME_FULL="ubuntu20.04" - docker_platform_version="20.04" - ;; - - "bionic") - PLATFORM_NAME="ubuntu1804" - PLATFORM_NAME_FULL="ubuntu18.04" - docker_platform_version="18.04" - ;; - - *) - echo "Error: Unsupported Ubuntu version: $PRETTY_NAME" - exit 1 - ;; - esac - ;; - - "rhel") - if [[ "$VERSION_ID" != 9* ]]; then - echo "Error: Unsupported RHEL version: $PRETTY_NAME" - exit 1 - fi - PLATFORM_NAME="ubi9" - PLATFORM_NAME_FULL="ubi9" - docker_platform_name="rhel-ubi" - docker_platform_version="9" - package_manager="yum" - ;; - - *) - echo "Error: Unsupported platform: $PRETTY_NAME" - exit 1 - ;; -esac - RAW_ARCH="$(uname -m)" case "$RAW_ARCH" in "x86_64") @@ -306,20 +445,16 @@ case "$RAW_ARCH" in *) echo "Error: Unsupported CPU architecture: $RAW_ARCH" + exit 1 ;; esac -if ! has_command "curl" ; then - echo "Error: curl must be installed to download swiftly" - exit 1 -fi - JSON_OUT=$(cat < Date: Mon, 25 Dec 2023 14:14:00 -0500 Subject: [PATCH 06/11] Deploy swiftly-install 0.3.0 This release modifies swiftly-install's default behavior when encountering an existing installation of swiftly to updating only the swiftly binary rather than performing a clean installation, which was the previous default. The previous behavior can be achived by passing in the --overwrite flag. This release also fixes a bug where swiftly-install would not clean up any existing symlinks when overwriting an existing swiftly installation. --- swiftly-install.sh | 66 +++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/swiftly-install.sh b/swiftly-install.sh index 086047bb..6df8285f 100755 --- a/swiftly-install.sh +++ b/swiftly-install.sh @@ -316,7 +316,7 @@ verify_getopt_install () { return "$?" } -SWIFTLY_INSTALL_VERSION="0.2.0" +SWIFTLY_INSTALL_VERSION="0.3.0" MODIFY_PROFILE="true" SWIFTLY_INSTALL_SYSTEM_DEPS="true" @@ -335,7 +335,7 @@ set -o errexit shopt -s extglob short_options='yhvp:' -long_options='disable-confirmation,no-modify-profile,no-install-system-deps,help,version,platform:' +long_options='disable-confirmation,no-modify-profile,no-install-system-deps,help,version,platform:,overwrite' args=$(getopt --options "$short_options" --longoptions "$long_options" --name "swiftly-install" -- "${@}") eval "set -- ${args}" @@ -351,7 +351,7 @@ USAGE: swiftly-install [options] OPTIONS: - -y, --disable-confirmation Disable confirmation prompt. + -y, --disable-confirmation Disable confirmation prompts. --no-modify-profile Do not attempt to modify the profile file to set environment variables (e.g. PATH) on login. --no-install-system-deps Do not attempt to install Swift's required system dependencies. @@ -359,6 +359,10 @@ OPTIONS: unspecified, the platform will be automatically detected. Available options are "ubuntu22.04", "ubuntu20.04", "ubuntu18.04", "rhel9", and "amazonlinux2". + --overwrite Overwrite the existing swiftly installation found at the configured + SWIFTLY_HOME, if any. If this option is unspecified and an existing + installation is found, the swiftly executable will be updated, but + the rest of the installation will not be modified. -h, --help Prints help information. --version Prints version information. EOF @@ -415,6 +419,11 @@ EOF shift 2 ;; + "--overwrite") + overwrite_existing_intallation="true" + shift + ;; + --) shift break @@ -534,20 +543,15 @@ while [ -z "$DISABLE_CONFIRMATION" ]; do esac done -if [[ -d "$HOME_DIR" ]]; then - if [[ "$DISABLE_CONFIRMATION" == "true" ]]; then +if [[ -f "$HOME_DIR/config.json" ]]; then + detected_existing_installation="true" + if [[ "$overwrite_existing_intallation" == "true" ]]; then echo "Overwriting existing swiftly installation at $(replace_home_path $HOME_DIR)" + find $BIN_DIR -lname "$HOME_DIR/toolchains/**/bin/*" -delete + rm -r $HOME_DIR else - echo "Existing swiftly installation detected at $(replace_home_path $HOME_DIR), overwrite? (Y/n)" - - read_yn_input "true" - if [[ "$READ_INPUT_RETURN" == "false" ]]; then - echo "Cancelling installation." - exit 0 - fi + echo "Updating existing swiftly installation at $(replace_home_path $HOME_DIR)" fi - - rm -r $HOME_DIR fi mkdir -p $HOME_DIR/toolchains @@ -566,35 +570,37 @@ curl \ chmod +x "$BIN_DIR/swiftly" -echo "$JSON_OUT" > "$HOME_DIR/config.json" +if [[ "$detected_existing_installation" != "true" || "$overwrite_existing_intallation" == "true" ]]; then + echo "$JSON_OUT" > "$HOME_DIR/config.json" -# Verify the downloaded executable works. The script will exit if this fails due to errexit. -SWIFTLY_HOME_DIR="$HOME_DIR" SWIFTLY_BIN_DIR="$BIN_DIR" "$BIN_DIR/swiftly" --version > /dev/null + # Verify the downloaded executable works. The script will exit if this fails due to errexit. + SWIFTLY_HOME_DIR="$HOME_DIR" SWIFTLY_BIN_DIR="$BIN_DIR" "$BIN_DIR/swiftly" --version > /dev/null -ENV_OUT=$(cat < "$HOME_DIR/env.sh" + echo "$ENV_OUT" > "$HOME_DIR/env.sh" -if [[ "$MODIFY_PROFILE" == "true" ]]; then - SOURCE_LINE=". $(replace_home_path $HOME_DIR)/env.sh" + if [[ "$MODIFY_PROFILE" == "true" ]]; then + SOURCE_LINE=". $(replace_home_path $HOME_DIR)/env.sh" - # Only append the line if it isn't in .profile already. - if [[ ! -f "$PROFILE_FILE" ]] || [[ ! "$(cat $PROFILE_FILE)" =~ "$SOURCE_LINE" ]]; then - echo "$SOURCE_LINE" >> "$PROFILE_FILE" + # Only append the line if it isn't in .profile already. + if [[ ! -f "$PROFILE_FILE" ]] || [[ ! "$(cat $PROFILE_FILE)" =~ "$SOURCE_LINE" ]]; then + echo "$SOURCE_LINE" >> "$PROFILE_FILE" + fi fi -fi -if [[ "$SWIFTLY_INSTALL_SYSTEM_DEPS" != "false" ]]; then - echo "" - echo "Installing Swift's system dependencies via $package_manager (note: this may require root access)..." - install_system_deps + if [[ "$SWIFTLY_INSTALL_SYSTEM_DEPS" != "false" ]]; then + echo "" + echo "Installing Swift's system dependencies via $package_manager (note: this may require root access)..." + install_system_deps + fi fi echo "" From fce2ce77e534677f1fff1b039943f7e3ae904019 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Tue, 7 May 2024 17:09:25 +0100 Subject: [PATCH 07/11] swiftly-install v0.4.0 --- swiftly-install.sh | 94 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 74 insertions(+), 20 deletions(-) diff --git a/swiftly-install.sh b/swiftly-install.sh index 6df8285f..4faf694e 100755 --- a/swiftly-install.sh +++ b/swiftly-install.sh @@ -12,10 +12,11 @@ # to store platform information, downloaded toolchains, and other state required to manage # the toolchains. # -# After installation, the script will create $SWIFTLY_HOME_DIR/env.sh, which can be sourced +# After installation, the script will create $SWIFTLY_HOME_DIR/env.{sh,fish}, which can be sourced # to properly set up the environment variables required to run swiftly. Unless --no-modify-profile -# was specified, the script will also update ~/.profile, ~/.bash_profile, ~/.bash_login, or ~/.zprofile, -# depending on the value of $SHELL and the existence of the files, to source the env.sh file on login. +# was specified, the script will also update ~/.profile, ~/.bash_profile, ~/.bash_login, ~/.zprofile, +# $XDG_CONFIG_HOME/fish/conf.d/swiftly.fish, or ~/.config/fish/conf.d/swiftly.fish depending on +# the value of $SHELL and the existence of the files, to source the env.{sh,fish} file on login. # This will ensure that future logins will automatically configure SWIFTLY_HOME_DIR, SWIFTLY_BIN_DIR, # and PATH. # @@ -149,6 +150,9 @@ install_system_deps () { unset 'package_list[-1]' fi + # Always install gpg, since swiftly itself needs it for signature verification. + package_list+=("gpg") + install_args=(--quiet -y) # Disable errexit since failing to install system dependencies is not swiftly installation-fatal. @@ -316,7 +320,7 @@ verify_getopt_install () { return "$?" } -SWIFTLY_INSTALL_VERSION="0.3.0" +SWIFTLY_INSTALL_VERSION="0.4.0" MODIFY_PROFILE="true" SWIFTLY_INSTALL_SYSTEM_DEPS="true" @@ -355,6 +359,7 @@ OPTIONS: --no-modify-profile Do not attempt to modify the profile file to set environment variables (e.g. PATH) on login. --no-install-system-deps Do not attempt to install Swift's required system dependencies. + --no-import-pgp-keys Do not attempt to import Swift's PGP keys. -p, --platform Specifies which platform's toolchains swiftly will download. If unspecified, the platform will be automatically detected. Available options are "ubuntu22.04", "ubuntu20.04", "ubuntu18.04", "rhel9", and @@ -384,6 +389,11 @@ EOF shift ;; + "--no-import-pgp-keys") + swiftly_import_pgp_keys="false" + shift + ;; + "--version") echo "$SWIFTLY_INSTALL_VERSION" exit 0 @@ -486,6 +496,15 @@ case "$SHELL" in PROFILE_FILE="$HOME/.bash_login" fi ;; + *"fish") + # $XDG_CONFIG_HOME/fish/conf.d/swiftly.fish or ~/.config/fish/conf.d/swiftly.fish + # https://github.com/fish-shell/fish-shell/issues/3170#issuecomment-228311857 + if [ -n "$XDG_CONFIG_HOME" ]; then + PROFILE_FILE="$XDG_CONFIG_HOME/fish/conf.d/swiftly.fish" + else + PROFILE_FILE="$HOME/.config/fish/conf.d/swiftly.fish" + fi + ;; *) esac @@ -570,50 +589,85 @@ curl \ chmod +x "$BIN_DIR/swiftly" -if [[ "$detected_existing_installation" != "true" || "$overwrite_existing_intallation" == "true" ]]; then - echo "$JSON_OUT" > "$HOME_DIR/config.json" - - # Verify the downloaded executable works. The script will exit if this fails due to errexit. - SWIFTLY_HOME_DIR="$HOME_DIR" SWIFTLY_BIN_DIR="$BIN_DIR" "$BIN_DIR/swiftly" --version > /dev/null - - ENV_OUT=$(cat < "$HOME_DIR/env.sh" +if [[ "$detected_existing_installation" != "true" || "$overwrite_existing_intallation" == "true" ]]; then + echo "$JSON_OUT" > "$HOME_DIR/config.json" + + # Verify the downloaded executable works. The script will exit if this fails due to errexit. + SWIFTLY_HOME_DIR="$HOME_DIR" SWIFTLY_BIN_DIR="$BIN_DIR" "$BIN_DIR/swiftly" --version > /dev/null + + echo "$ENV_OUT" > "$HOME_DIR/$ENV_FILE" if [[ "$MODIFY_PROFILE" == "true" ]]; then - SOURCE_LINE=". $(replace_home_path $HOME_DIR)/env.sh" + SOURCE_LINE=". $(replace_home_path $HOME_DIR)/$ENV_FILE" # Only append the line if it isn't in .profile already. if [[ ! -f "$PROFILE_FILE" ]] || [[ ! "$(cat $PROFILE_FILE)" =~ "$SOURCE_LINE" ]]; then echo "$SOURCE_LINE" >> "$PROFILE_FILE" fi fi +fi - if [[ "$SWIFTLY_INSTALL_SYSTEM_DEPS" != "false" ]]; then +if [[ "$SWIFTLY_INSTALL_SYSTEM_DEPS" != "false" ]]; then + echo "" + echo "Installing Swift's system dependencies via $package_manager (note: this may require root access)..." + install_system_deps +fi + +if [[ "$swiftly_import_pgp_keys" != "false" ]]; then + if has_command gpg ; then echo "" - echo "Installing Swift's system dependencies via $package_manager (note: this may require root access)..." - install_system_deps + echo "Importing Swift's PGP keys..." + curl --silent --retry 3 --location --fail https://swift.org/keys/all-keys.asc | gpg --import - + else + echo "gpg not installed, skipping import of Swift's PGP keys." fi fi echo "" -echo "swiftly has been succesfully installed!" +echo "swiftly has been successfully installed!" echo "" if ! has_command "swiftly" || [[ "$HOME_DIR" != "$DEFAULT_HOME_DIR" || "$BIN_DIR" != "$DEFAULT_BIN_DIR" ]] ; then - echo "Once you log in again, swiftly should be accessible from your PATH." + if [[ "$MODIFY_PROFILE" == "true" ]]; then + echo "Once you log in again, swiftly should be accessible from your PATH." + fi echo "To begin using swiftly from your current shell, first run the following command:" echo "" - echo " . $(replace_home_path $HOME_DIR)/env.sh" + echo " . $(replace_home_path $HOME_DIR)/$ENV_FILE" echo "" echo "Then to install the latest version of Swift, run 'swiftly install latest'" else echo "To install the latest version of Swift, run 'swiftly install latest'" fi + +if has_command "swift" ; then + echo "" + echo "Warning: existing installation of Swift detected at $(command -v swift)" + echo "To ensure swiftly-installed toolchains can be found by the shell, uninstall any existing Swift installation(s)." + echo "To ensure the current shell can find swiftly-installed toolchains, you may also need to run 'hash -r'." +fi From 7386eb9e8302d95d98896fd7859acbacb61a527f Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Tue, 11 Jun 2024 16:25:48 +0100 Subject: [PATCH 08/11] Update website --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 18f6fadf..a3c5076f 100644 --- a/index.html +++ b/index.html @@ -26,7 +26,7 @@

swiftly


- $ curl -L https://swift-server.github.io/swiftly/swiftly-install.sh | bash + $ curl -L https://swiftlang.github.io/swiftly/swiftly-install.sh | bash
-

Swiftly is currently only available for Linux.

@@ -43,9 +45,9 @@

swiftly