-
Notifications
You must be signed in to change notification settings - Fork 245
Use a curlbash script for installing swiftly #1133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marcprux
wants to merge
8
commits into
swiftlang:main
Choose a base branch
from
marcprux:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+62
−30
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5689d02
Use a curlbash script for installing swiftly
marcprux e8a5359
Add header to swiftly-install script to satisfy soundness.sh
marcprux f4a9338
Use /bin/sh for maximum portability
marcprux 9b36b3e
Update swiftly-install
marcprux 62c93ee
Update swiftly-install
marcprux 42653b5
Update swiftly-install
marcprux fe5af9d
Update swiftly-install
marcprux 6b83669
Check for existence of curl, ps, and tar before running script
marcprux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/sh | ||
##===----------------------------------------------------------------------===## | ||
## | ||
## This source file is part of the Swift.org open source project | ||
## | ||
## Copyright (c) 2025 Apple Inc. and the Swift.org project authors | ||
## Licensed under Apache License v2.0 | ||
## | ||
## See LICENSE.txt for license information | ||
## See CONTRIBUTORS.txt for the list of Swift.org project authors | ||
## | ||
## SPDX-License-Identifier: Apache-2.0 | ||
## | ||
##===----------------------------------------------------------------------===## | ||
set -eu | ||
# Install script for Swiftly | ||
# Usage: curl -fsSL https://swift.org/swiftly-install | sh | ||
|
||
if ! command -v curl >/dev/null 2>&1 || ! command -v ps >/dev/null 2>&1 || ! command -v tar >/dev/null 2>&1 ; then | ||
echo "Missing one of more of the following programs: curl, ps, tar" >&2 | ||
exit 1 | ||
fi | ||
|
||
OS_NAME=$(uname -s) | ||
OS_ARCH=$(uname -m) | ||
TEMP_DIR=$(mktemp -d) | ||
|
||
cd "${TEMP_DIR}" | ||
|
||
case "$OS_NAME" in | ||
"Linux") | ||
curl -fsSLO "https://download.swift.org/swiftly/linux/swiftly-${OS_ARCH}.tar.gz" | ||
tar zxf "swiftly-${OS_ARCH}.tar.gz" | ||
./swiftly init | ||
SWIFTLY_HOME_DIR=${SWIFTLY_HOME_DIR:-$HOME/.swiftly} | ||
;; | ||
"Darwin") | ||
curl -fsSLO https://download.swift.org/swiftly/darwin/swiftly.pkg | ||
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory | ||
~/.swiftly/bin/swiftly init | ||
SWIFTLY_HOME_DIR=${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly} | ||
;; | ||
*) | ||
echo "Unknown platform: $OS_NAME" | ||
echo "This script supports Linux and Darwin/macOS only" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
echo "Swiftly installed! Run the following command to set up your environment:" | ||
PARENT_SHELL=$(ps -o comm= -p "$PPID") | ||
if [ "$PARENT_SHELL" = "fish" ]; then | ||
echo "source ${SWIFTLY_HOME_DIR}/env.fish" | ||
else | ||
# Not fish: assume sh-compatible (bash/zsh) | ||
echo "source ${SWIFTLY_HOME_DIR}/env.sh" | ||
fi | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Linux, almost no command line tool is guaranteed to be installed. It's worth checking if all of the programs the script needs are installed.
ps
(from a package usually called procps) is not always present.tar
is not always present.mktemp and uname come from coreutils, but those are a bit too fundamental to bother checking for IMO. cd is a shell builtin.
Or, you could detect apt-get and dnf and try to install the relevant packages to ensure they'll be there (without
-y
, so the user is prompted if configured).something like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I think that automatically running their package manager to install the missing utilities is a bit heavy-handed, so I just went with the fail-fast exit when one of the necessary commands is not present.