-
Notifications
You must be signed in to change notification settings - Fork 37
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
Streamline the swiftly init process #177
Changes from 44 commits
e4efbeb
3b5c404
956256f
375df29
ed68a9e
c745f4c
560236d
ae29e88
ce0d27a
66dd459
2df7357
8976bba
3caab66
31f4327
16caf80
b2aa165
7504dd3
0e7b661
43d620a
2e3c59d
9dd640c
5e615ea
10a0856
6d6050e
883e638
0cc129c
afbd797
d301ef3
393f9d5
6989796
6fc24f0
71df3a6
4d833f8
bc83ee5
be65db1
646b5cb
4e7ca7c
a08faad
65da6d8
970943f
c43fba2
bce8ab6
bbe7277
35a05d0
d732a84
34e4021
55fc274
942c4e4
e7ab371
73a77ea
be095e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,46 @@ | ||
# Getting Started with Swiftly | ||
|
||
To download swiftly and install Swift, run the following in your terminal, then follow the on-screen instructions: | ||
Start using swiftly and swift. | ||
|
||
``` | ||
curl -L https://swiftlang.github.io/swiftly/swiftly-install.sh | bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason we can't offer the script as an alternative? Removing it completely makes install Swiftly and Swift a reasonably amount more complicated as it puts the onus on the user to work out what OS and architecture they're using, which they can get wrong and make it seem like Swift doesn't work. Additionally this makes building tooling on top of Swiftly significantly more complicated and each tool has to do the same logic of working out what system it's running on and going to find the correct binary which is a lot of duplicated work. It would be good to have that centralised in the tool. Finally, this reduces the 'copy and paste this one line' installation for Swift that we have had up to now, making the experience on installing Swift on different systems a step back IMO compared to say rustup. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are number of ways that we're hoping to address these as we can't use a For the regular user install workflow, the website can help to find them the most likely swiftly download candidate for their OS and architecture. More details can be found in the PR here: swiftlang/swift-org-website#830 We can also add a very short guide to help them on the next steps. Feedback is welcome on that PR. The download for macOS brings them to the pkg installer for the easy flow. It can also be invoked headlessly on the command-line either in a system directory or the user's home directory. Details are in the docs. Since swiftly is a Linux binary that can work on a wide variety of Linux distributions, it takes on the responsibility of Linux flavour detection, and configuration. The user needs only to untar it and run For automated systems, there's a document here that goes over how one would automatically install swiftly. Feedback is welcome on this document as part of a separate PR/issue: https://swiftpackageindex.com/swiftlang/swiftly/main/documentation/swiftlydocs/automated-install There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the slightly longer term, there is also the possibility of providing swiftly in system package managers to make this even easier. Swiftly is able to be run from a system location. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that in the near term the website can do much to ease the new user flow to compensate, such as making sure that they have the right executable, escape hatch to the full list of executables. The URL when it's finally decided for the website, can be made to be friendly to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But what's the actual reason "we can't use a |
||
``` | ||
To get started with swiftly you can download it from [swift.org](https://swift.org/download), and extract the package. | ||
|
||
Alternatively, you can download the swiftly binary and install itself like this: | ||
@TabNavigator { | ||
@Tab("Linux") { | ||
If you are using Linux then you can verify and extract the archive like this: | ||
|
||
``` | ||
swiftly init | ||
``` | ||
``` | ||
sha256sum swiftly-x.y.z.tar.gz # Check that the hash matches what's reported on swift.org | ||
tar zxf swiftly-x.y.z.tar.gz | ||
``` | ||
|
||
Once swiftly is installed you can use it to install the latest available swift toolchain like this: | ||
Now run swiftly init to finish the installation: | ||
|
||
``` | ||
$ swiftly install latest | ||
``` | ||
./swiftly init | ||
``` | ||
} | ||
|
||
Fetching the latest stable Swift release... | ||
Installing Swift 5.8.1 | ||
Downloaded 488.5 MiB of 488.5 MiB | ||
Extracting toolchain... | ||
Swift 5.8.1 installed successfully! | ||
@Tab("macOS") { | ||
On macOS you can either run the pkg installer from the command-line like this or just run the package by double-clicking on it (not recommended): | ||
|
||
``` | ||
installer -pkg swift-x.y.z.pkg -target CurrentUserHomeDirectory | ||
``` | ||
|
||
Now run swiftly init to finish the installation: | ||
|
||
``` | ||
$HOME/usr/local/bin/swiftly init | ||
``` | ||
} | ||
} | ||
|
||
Swiftly will install itself and download the latest available Swift toolchain. Follow the prompts for any additional steps. Once everything is done you can begin using swift. | ||
|
||
``` | ||
$ swift --version | ||
|
||
Swift version 5.8.1 (swift-5.8.1-RELEASE) | ||
Swift version 6.0.1 (swift-6.0.1-RELEASE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a few lines down the doc references There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can raise another PR to fresh the version numbers in the documentation, or make them more version independent. Suggestions are welcome on how best to handle this problem of balancing accuracy and maintainability. |
||
Target: x86_64-unknown-linux-gnu | ||
|
||
$ swift build # Build with the latest (5.8.1) toolchain | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ public struct MacOS: Platform { | |
nil | ||
} | ||
|
||
public func install(from tmpFile: URL, version: ToolchainVersion) throws { | ||
public func install(from tmpFile: URL, version: ToolchainVersion, verbose: Bool) throws { | ||
guard tmpFile.fileExists() else { | ||
throw Error(message: "\(tmpFile) doesn't exist") | ||
} | ||
|
@@ -60,23 +60,26 @@ public struct MacOS: Platform { | |
|
||
if SwiftlyCore.mockedHomeDir == nil { | ||
SwiftlyCore.print("Installing package in user home directory...") | ||
try runProgram("installer", "-pkg", tmpFile.path, "-target", "CurrentUserHomeDirectory") | ||
try runProgram("installer", "-verbose", "-pkg", tmpFile.path, "-target", "CurrentUserHomeDirectory", quiet: !verbose) | ||
} else { | ||
// In the case of a mock for testing purposes we won't use the installer, perferring a manual process because | ||
// the installer will not install to an arbitrary path, only a volume or user home directory. | ||
SwiftlyCore.print("Expanding pkg...") | ||
let tmpDir = self.getTempFilePath() | ||
let toolchainDir = self.swiftlyToolchainsDir.appendingPathComponent("\(version.identifier).xctoolchain", isDirectory: true) | ||
if !toolchainDir.fileExists() { | ||
try FileManager.default.createDirectory(at: toolchainDir, withIntermediateDirectories: false) | ||
} | ||
try runProgram("pkgutil", "--expand", tmpFile.path, tmpDir.path) | ||
try runProgram("pkgutil", "--verbose", "--expand", tmpFile.path, tmpDir.path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! This is a good catch. It's only triggered by the automated tests at the moment, where they'll generally set the non-quiet. I'm going to fix this to be consistent. |
||
// There's a slight difference in the location of the special Payload file between official swift packages | ||
// and the ones that are mocked here in the test framework. | ||
var payload = tmpDir.appendingPathComponent("Payload") | ||
if !payload.fileExists() { | ||
payload = tmpDir.appendingPathComponent("\(version.identifier)-osx-package.pkg/Payload") | ||
} | ||
try runProgram("tar", "-C", toolchainDir.path, "-xf", payload.path) | ||
|
||
SwiftlyCore.print("Untarring pkg Payload...") | ||
try runProgram("tar", "-C", toolchainDir.path, "-xvf", payload.path, quiet: !verbose) | ||
} | ||
} | ||
|
||
|
@@ -146,7 +149,7 @@ public struct MacOS: Platform { | |
FileManager.default.temporaryDirectory.appendingPathComponent("swiftly-\(UUID()).pkg") | ||
} | ||
|
||
public func verifySignature(httpClient _: SwiftlyHTTPClient, archiveDownloadURL _: URL, archive _: URL) async throws { | ||
public func verifySignature(httpClient _: SwiftlyHTTPClient, archiveDownloadURL _: URL, archive _: URL, verbose _: Bool) async throws { | ||
// No signature verification is required on macOS since the pkg files have their own signing | ||
// mechanism and the swift.org downloadables are trusted by stock macOS installations. | ||
} | ||
|
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.
Does this exist? 🤔
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.
It will once these website update PR's are merged with a released version of swiftly:
swiftlang/swift-org-website#828
swiftlang/swift-org-website#830