|
1 |
| -# Install Swiftly Automatically |
| 1 | +# Install swiftly automatically |
2 | 2 |
|
3 | 3 | Automatically install swiftly and Swift toolchains.
|
4 | 4 |
|
5 | 5 | This guide helps you to automate the installation of swiftly and toolchains so that it can run unattended, for example in build or continous integration systems.
|
6 |
| -We assume that you have working understanding of your build system. The examples are based on a typical Unix environment. |
| 6 | +This guide assumes that you have working understanding of your build system. |
| 7 | +The examples are based on a typical Unix environment. |
7 | 8 |
|
8 |
| -First, download the swiftly binary from swift.org for your operating system (e.g. Linux) and processor architecture (e.g. arm64, or x86_64). Here's an example using the popular curl command. |
| 9 | +### Download the binary |
| 10 | + |
| 11 | +First, download the swiftly binary from swift.org for your operating system (for example, Linux) and processor architecture (for example `arm64` or `x86_64`). |
| 12 | +Here's an example using the popular curl command. |
9 | 13 |
|
10 | 14 | ```
|
11 |
| -curl -L <location_of_swiftly_swift_org> > swiftly.tar.gz |
| 15 | +curl -L https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz > swiftly.tar.gz |
12 | 16 | tar zxf swiftly.tar.gz
|
13 | 17 | ```
|
14 | 18 |
|
15 |
| -On macOS you can download the pkg file and extract it like this from the command-line: |
| 19 | +On macOS, download the pkg file and extract it like this from the command-line: |
16 | 20 |
|
17 | 21 | ```
|
18 |
| -curl -L <location_of_swiftly_swift_org> > swiftly.pkg |
| 22 | +curl -L https://download.swift.org/swiftly/darwin/swiftly.pkg > swiftly.pkg |
19 | 23 | installer -pkg swiftly.pkg -target CurrentUserHomeDirectory
|
20 | 24 | ```
|
21 | 25 |
|
22 |
| -> Tip: If you are using Linux you will need the "ca-certificates" package for the root certificate authorities that will establish the trust that swiftly needs to make API requests that it needs. This package is frequently pre-installed on end-user environments, but may not be present in more minimal installations. |
| 26 | +> Tip: If you are using Linux you will need GPG and the "ca-certificates" package for the root certificate authorities that will establish the trust that swiftly needs to make API requests that it needs. This package is frequently pre-installed on end-user environments, but may not be present in more minimal installations. |
| 27 | +
|
| 28 | +### Install swiftly |
23 | 29 |
|
24 |
| -Once swiftly is downloaded you can run the init subcommand to finish the installation. This command will print verbose outputs, assume yes for all prompts, and skip the automatic installation of the latest swift toolchain: |
| 30 | +Once swiftly is downloaded, run the `init` subcommand to finish the installation. |
| 31 | +The following example command prints verbose outputs, assume yes for all prompts, and skips the automatic installation of the latest swift toolchain: |
25 | 32 |
|
26 | 33 | ```
|
27 | 34 | ./swiftly init --verbose --assume-yes --skip-install # the swiftly binary is extracted to ~/local/bin/swiftly on macOS
|
28 | 35 | ```
|
29 | 36 |
|
30 |
| -Swiftly is installed, but the current shell may not yet be updated with the new environment variables, such as the PATH. The init command prints instructions on how to update the current shell environment without opening a new shell. This is an example of the output taken from Linux, but the details might be different for other OSes, username, or shell. |
| 37 | +Swiftly is installed, but the current shell may not yet be updated with the new environment variables, such as `PATH`. |
| 38 | +The `init` command prints instructions on how to update the current shell environment without opening a new shell. |
| 39 | +The following output is an example from Linux, the details might be different for other OSes, username, or shell: |
31 | 40 |
|
32 | 41 | ```
|
33 | 42 | To begin using installed swiftly from your current shell, first run the following command:
|
34 | 43 |
|
35 | 44 | . "/root/.local/share/swiftly/env.sh"
|
36 | 45 | ```
|
37 | 46 |
|
38 |
| -> Note: on macOS systems you may need to run 'hash -r' to recalculate the zsh PATH cache when installing swiftly and toolchains. |
| 47 | +> Note: on macOS, run 'hash -r' to recalculate the zsh PATH cache when installing swiftly and toolchains. |
| 48 | +
|
| 49 | +You can go ahead and add this command to the list of commands in your build script so that the build can proceed to call swiftly from the path. |
| 50 | + |
| 51 | +### Install a toolchain |
39 | 52 |
|
40 |
| -You can go ahead and add this command to the list of commands in your build script so that the build can proceed to call swiftly from the path. The usual next step is to install a specific swift toolchain like this: |
| 53 | +The usual next step is to install a specific swift toolchain using the `install` command with the `--post-install-file` option: |
41 | 54 |
|
42 | 55 | ```
|
43 | 56 | swiftly install 5.10.1 --post-install-file=post-install.sh
|
44 | 57 | ```
|
45 | 58 |
|
46 |
| -It's possible that there will be some post-installation steps to prepare the build system for using the swift toolchain. The `post-install-file` option gives a file, post-install.sh, that is created if there are post installation steps for this toolchain. You can check if the file exists and run it to perform those final steps. If the build runs as the root user you can check it and run it like this in a typical Unix shell: |
| 59 | +It's possible that there will be some post-installation steps to prepare the system for using the swift toolchain. |
| 60 | +If additional post-install steps are needed to use the toolchain they are written to the file you specified; `post-install.sh` in the example above. |
| 61 | +You can check if the file exists and run it to perform those final steps. |
| 62 | +If the build runs as the root user you can check it and run it like this in a typical Unix shell: |
47 | 63 |
|
48 | 64 | ```
|
49 | 65 | if [ -f post-install.sh ]; then
|
50 | 66 | . post-install.sh
|
51 | 67 | fi
|
52 | 68 | ```
|
53 | 69 |
|
54 |
| -> Note: If the build system runs your script as a regular user then you will need to take this into account by either pre-installing the toolchain's system dependencies or running the `post-install.sh` script in a secure manner as the administrative user. |
| 70 | +> Note: If the system runs your script as a regular user then you will need to take this into account by either pre-installing the toolchain's system dependencies or running the `post-install.sh` script in a secure manner as the administrative user. |
| 71 | +
|
| 72 | +### Customize the installation |
55 | 73 |
|
56 | 74 | If you want to install swiftly, or the binaries that it manages into different locations these can be customized using environment variables before running `swiftly init`.
|
57 | 75 |
|
58 |
| -``` |
59 |
| -SWIFTLY_HOME_DIR - The location of the swiftly configuration files, and environment scripts |
60 |
| -SWIFTLY_BIN_DIR - The location of the swiftly binary and toolchain symbolic links (e.g. swift, swiftc, etc.) |
61 |
| -``` |
| 76 | +- term `SWIFTLY_HOME_DIR`: The location of the swiftly configuration files, and environment scripts |
| 77 | +- term `SWIFTLY_BIN_DIR`: The location of the swiftly binary and toolchain symbolic links (for example swift, swiftc, and so on) |
62 | 78 |
|
63 |
| -Sometimes the build system platform can't be automatically detected, or isn't supported by swift. You can provide the platform as an option to the swiftly init subcommand: |
| 79 | +Sometimes swiftly can't automatically detect the system platform, or isn't supported by swift. |
| 80 | +You can provide the platform as an option to the `swiftly init` subcommand: |
64 | 81 |
|
65 | 82 | ```
|
66 | 83 | swiftly init --platform=<platform_name>
|
67 | 84 | ```
|
68 | 85 |
|
69 |
| -There are other customizable options, such as overwrite. For more details about the available options, check the help: |
| 86 | +There are other customizable options, such as overwrite. |
| 87 | +For more details about the available options, check the help: |
70 | 88 |
|
71 | 89 | ```
|
72 | 90 | swiftly init --help
|
73 | 91 | ```
|
74 | 92 |
|
75 |
| -In summary, swiftly can be installed and install toolchains unattended on build and CI-style systems. This HOWTO guide has outlined the process to script the process covering some of the different options available to you. |
| 93 | +In summary, swiftly can be installed and install toolchains unattended on build and CI-style systems. |
| 94 | +This guide has outlined the process to script the process covering some of the different options available to you. |
0 commit comments