From 256385d28b01b6242ceb67cc008259cc080527c3 Mon Sep 17 00:00:00 2001 From: Mahdi Bahrami Date: Fri, 7 Apr 2023 20:02:23 +0330 Subject: [PATCH 1/2] Update swiftly-install.sh --- install/swiftly-install.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/install/swiftly-install.sh b/install/swiftly-install.sh index 0b0a274a..38302358 100755 --- a/install/swiftly-install.sh +++ b/install/swiftly-install.sh @@ -32,6 +32,10 @@ read_input_with_default () { fi } +in_path() { + [[ ":$PATH:" == *":$1:"* ]] +} + SWIFTLY_INSTALL_VERSION="0.1.0" for arg in "$@"; do @@ -162,6 +166,11 @@ DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}" DEFAULT_HOME_DIR="$DATA_DIR/swiftly" HOME_DIR="${SWIFTLY_HOME_DIR:-$DEFAULT_HOME_DIR}" DEFAULT_BIN_DIR="$HOME/.local/bin" + +if ! in_path "$HOME/.local/bin" && in_path "/usr/local/bin"; then + DEFAULT_BIN_DIR="/usr/local/bin" +fi + BIN_DIR="${SWIFTLY_BIN_DIR:-$DEFAULT_BIN_DIR}" while [ -z "$DISABLE_CONFIRMATION" ]; do From a2c031bb4dbf2ba4ce3fc6fd50e412c410f379f1 Mon Sep 17 00:00:00 2001 From: Mahdi Bahrami Date: Fri, 7 Apr 2023 22:29:12 +0330 Subject: [PATCH 2/2] bin dir default to `/usr/local/bin ` --- Sources/SwiftlyCore/Platform.swift | 10 ++++------ install/swiftly-install.sh | 13 ++----------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/Sources/SwiftlyCore/Platform.swift b/Sources/SwiftlyCore/Platform.swift index 1c4ee2dd..c54e393a 100644 --- a/Sources/SwiftlyCore/Platform.swift +++ b/Sources/SwiftlyCore/Platform.swift @@ -67,13 +67,11 @@ extension Platform { /// /// If a mocked home directory is set, this will be the "bin" subdirectory of the home directory. /// If not, this will be the SWIFTLY_BIN_DIR environment variable if set. If that's also unset, - /// this will default to ~/.local/bin. + /// this will default to /usr/local/bin. public var swiftlyBinDir: URL { - SwiftlyCore.mockedHomeDir.map { $0.appendingPathComponent("bin", isDirectory: true) } - ?? ProcessInfo.processInfo.environment["SWIFTLY_BIN_DIR"].map { URL(fileURLWithPath: $0) } - ?? FileManager.default.homeDirectoryForCurrentUser - .appendingPathComponent(".local", isDirectory: true) - .appendingPathComponent("bin", isDirectory: true) + SwiftlyCore.mockedHomeDir.map { $0.appendingPathComponent("bin", isDirectory: true) } ?? + ProcessInfo.processInfo.environment["SWIFTLY_BIN_DIR"].map { URL(fileURLWithPath: $0) } ?? + URL(fileURLWithPath: "/usr/local/bin") } /// The "toolchains" subdirectory of swiftly's home directory. Contains the Swift toolchains managed by swiftly. diff --git a/install/swiftly-install.sh b/install/swiftly-install.sh index 38302358..59275a9e 100755 --- a/install/swiftly-install.sh +++ b/install/swiftly-install.sh @@ -4,7 +4,7 @@ # 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. +# to $SWIFTLY_BIN_DIR, or /usr/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, @@ -32,10 +32,6 @@ read_input_with_default () { fi } -in_path() { - [[ ":$PATH:" == *":$1:"* ]] -} - SWIFTLY_INSTALL_VERSION="0.1.0" for arg in "$@"; do @@ -165,12 +161,7 @@ echo "" DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}" DEFAULT_HOME_DIR="$DATA_DIR/swiftly" HOME_DIR="${SWIFTLY_HOME_DIR:-$DEFAULT_HOME_DIR}" -DEFAULT_BIN_DIR="$HOME/.local/bin" - -if ! in_path "$HOME/.local/bin" && in_path "/usr/local/bin"; then - DEFAULT_BIN_DIR="/usr/local/bin" -fi - +DEFAULT_BIN_DIR="/usr/local/bin" BIN_DIR="${SWIFTLY_BIN_DIR:-$DEFAULT_BIN_DIR}" while [ -z "$DISABLE_CONFIRMATION" ]; do