New Swift Package Repository for Ubuntu/Debian Linux Distributions

Hi everybody,
I have set up a new Swift apt package repository for easy install of Swift on Ubuntu/Debian Linux distributions using the apt package manager.

Repository Install and Usage

There are 2 simple steps to use the repository:-

  1. Install the package repository using the quick install script.
    curl -s https://swiftlang.xyz/install.sh | sudo bash

  2. Install Swift
    sudo apt install swiftlang

The repository supports the following distributions and architectures -

  • Ubuntu 18.04 / 20.04 / 21.04 - x86_86 / amd64 / aarch64 / arm64 / armv7
  • Debian 10 / buster - x86_86 / amd64 / aarch64 / arm64 / armv7 / armhf
  • Raspbian buster - aarch64 / arm64 / armv7 / armhf

The Swift .deb packages are created from the following sources -

Swift package versions are as follows -

  • All 64bit versions are Swift 5.4.1-Release
  • All 32bit versions are Swift 5.1.5-Release

The repository uses all the standard Ubuntu/Debian security and digital signing certificates as well as ssl site encryption.

Current packages available are -

/var/www/swiftlang.xyz/public_html/ubuntu ~
swiftlang |   5.4.1-01-ubuntu18.04 |  bionic | amd64
swiftlang |  5.4.1-7-ubuntu-bionic |  bionic | arm64
swiftlang |   5.4.1-01-ubuntu20.04 |   focal | amd64
swiftlang |  5.4.1-15-ubuntu-focal |   focal | arm64
swiftlang | 5.4.1-8-ubuntu-hirsute | hirsute | arm64
~
/var/www/swiftlang.xyz/public_html/debian ~
swiftlang |  5.4.1-8-debian-buster | buster | arm64
swiftlang | 5.1.5-01-debian-buster | buster | armv7
~
/var/www/swiftlang.xyz/public_html/raspbian ~
swiftlang | 5.1.5-01-raspbian-buster | buster | armhf
~

Uninstall Repository

You can remove the repository use if you need to using -
curl -s https://swiftlang.xyz/remove.sh | sudo bash

Testing with Docker

If you wish to test the repository without installing on your main system the easiest way is to use a docker container.

# start a ubuntu 20.04 docker container 
docker run --security-opt seccomp=unconfined -it ubuntu:20.04 /bin/bash 
# inside the container
apt update
apt install curl
curl -s https://swiftlang.xyz/install.sh | bash
apt install swiftlang

Moving Forward

The main motivation behind creating this repository is as a 'proof of concept' for an official Swift.org apt repository. To explore and test the technologies required and provide a real world testing environment.

Please try out the repository and provide feedback on your experiences.

I have included a live Usage Statistics page on the website to track usage and get an idea of what hardware requirements will be needed.

Thanks for your time and I look forward to your feedback.

54 Likes

Cool!

Repository Package Update.

I have rebuilt the .deb packages with uniform naming and iteration numbers. The release versions of the different arch types now align.

/var/www/swiftlang.xyz/public_html/ubuntu ~
swiftlang |        5.4.1-01-ubuntu-bionic |  bionic | amd64, arm64
swiftlang |         5.4.1-01-ubuntu-focal |   focal | amd64, arm64
swiftlang | 5.5-2021-07-09-a-ubuntu-focal |   focal | amd64, arm64
swiftlang |       5.4.1-01-ubuntu-hirsute | hirsute | arm64
~
/var/www/swiftlang.xyz/public_html/debian ~
swiftlang | 5.4.1-01-debian-buster | buster | arm64
swiftlang | 5.1.5-01-debian-buster | buster | armv7
~
/var/www/swiftlang.xyz/public_html/raspbian ~
swiftlang | 5.1.5-01-raspbian-buster | buster | armhf

Developer Snapshots

I have added a 'dev' section to the repository for the latest developer snapshots.
Run the following command to install the 'dev' section -

curl -s https://swiftlang.xyz/install-dev.sh | sudo bash

If you run apt-cache policy swiftlang you will see what versions are available -

apt-cache policy swiftlang

swiftlang:
  Installed: 5.4.1-01-ubuntu-focal
  Candidate: 5.5-2021-07-09-a-ubuntu20.04
  Version table:
     5.5-2021-07-09-a-ubuntu20.04 500
        500 https://swiftlang.xyz/ubuntu focal/dev amd64 Packages
 *** 5.4.1-01-ubuntu-focal 500
        500 https://swiftlang.xyz/ubuntu focal/main amd64 Packages
        100 /var/lib/dpkg/status

Note: Snapshots are only available for ubuntu-focal (20.04) at the moment.

To install the latest version of swift version run the apt install command -

sudo apt install swiftlang

You can also specify which version to install by adding the package version number -

sudo apt install swiftlang=5.4.1-01-ubuntu-focal

To remove the 'dev' section run the standard install script -

curl -s https://swiftlang.xyz/install.sh | sudo bash
6 Likes

Great work !

Repository Update to Swift 5.4.2

I have just pushed Swift version 5.4.2 to the swiftlang.xyz repository.
You can install Swift 5.4.2 using sudo apt update and then sudo apt upgrade.

If you just want to update Swift and not any other packages that might be available, use sudo apt install swiftlang


# check current swift version
ubuntu@ip-172-31-17-153:~$ swift --version
Swift version 5.4.1 (swift-5.4.1-RELEASE)
Target: x86_64-unknown-linux-gnu

# run update
ubuntu@ip-172-31-17-153:~$ sudo apt update
Hit:1 http://us-east-2.ec2.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://us-east-2.ec2.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://us-east-2.ec2.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:5 https://swiftlang.xyz/ubuntu focal InRelease [5156 B]
Get:6 https://swiftlang.xyz/ubuntu focal/main amd64 Packages [523 B]
Fetched 334 kB in 1s (347 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.

# update available
ubuntu@ip-172-31-17-153:~$ apt list --upgradable -a
Listing... Done
swiftlang/release 5.4.2-01-ubuntu-focal amd64 [upgradable from: 5.4.1-01-ubuntu-focal]
swiftlang/now 5.4.1-01-ubuntu-focal amd64 [installed,upgradable to: 5.4.2-01-ubuntu-focal]

# run upgrade
ubuntu@ip-172-31-17-153:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
swiftlang
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 342 MB of archives.
After this operation, 42.0 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 https://swiftlang.xyz/ubuntu focal/main amd64 swiftlang amd64 5.4.2-01-ubuntu-focal [342 MB]
Fetched 342 MB in 38s (8983 kB/s)
(Reading database ... 97764 files and directories currently installed.)
Preparing to unpack .../swiftlang_5.4.2-01-ubuntu-focal_amd64.deb ...
Unpacking swiftlang (5.4.2-01-ubuntu-focal) over (5.4.1-01-ubuntu-focal) ...
Setting up swiftlang (5.4.2-01-ubuntu-focal) ...
Processing triggers for man-db (2.9.1-1) ...

# check new swift version
ubuntu@ip-172-31-17-153:~$ swift --version
Swift version 5.4.2 (swift-5.4.2-RELEASE)
Target: x86_64-unknown-linux-gnu
1 Like

Developer Snapshot Updated to Swift 5.5-2021-07-15-a

I have just pushed the latest Swift developer snapshot to the swiftlang.xyz repository.

If you the developer repository installed (curl -s https://swiftlang.xyz/install-dev.sh | sudo bash) you can install latest snapshot using sudo apt update and then sudo apt upgrade.

# check current swift version
ubuntu@ip-172-31-24-100:~$ swift --version
Swift version 5.5-dev (LLVM d26cc0e18da572f, Swift 6a80196da3cbbb3)
Target: x86_64-unknown-linux-gnu

# run update
ubuntu@ip-172-31-24-100:~$ sudo apt update
Hit:1 http://us-east-2.ec2.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://us-east-2.ec2.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://us-east-2.ec2.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:5 https://swiftlang.xyz/ubuntu focal InRelease [5156 B]
Get:6 https://swiftlang.xyz/ubuntu focal/dev amd64 Packages [528 B]
Fetched 334 kB in 1s (333 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.

# update available
ubuntu@ip-172-31-24-100:~$ apt list --upgradable -a
Listing... Done
swiftlang/release 5.5-2021-07-15-a-ubuntu-focal amd64 [upgradable from: 5.5-2021-07-09-a-ubuntu-focal]
swiftlang/now 5.5-2021-07-09-a-ubuntu-focal amd64 [installed,upgradable to: 5.5-2021-07-15-a-ubuntu-focal]
swiftlang/release 5.4.2-01-ubuntu-focal amd64

# run upgrade
ubuntu@ip-172-31-24-100:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
swiftlang
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 334 MB of archives.
After this operation, 5146 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 https://swiftlang.xyz/ubuntu focal/dev amd64 swiftlang amd64 5.5-2021-07-15-a-ubuntu-focal [334 MB]
Fetched 334 MB in 36s (9389 kB/s)
(Reading database ... 97795 files and directories currently installed.)
Preparing to unpack .../swiftlang_5.5-2021-07-15-a-ubuntu-focal_amd64.deb ...
Unpacking swiftlang (5.5-2021-07-15-a-ubuntu-focal) over (5.5-2021-07-09-a-ubuntu-focal) ...
Setting up swiftlang (5.5-2021-07-15-a-ubuntu-focal) ...
Processing triggers for man-db (2.9.1-1) ...

# check new swift version
ubuntu@ip-172-31-24-100:~$ swift --version
Swift version 5.5-dev (LLVM 473bb9eb9557b06, Swift b14f2b993493ef5)
Target: x86_64-unknown-linux-gnu
2 Likes

The repository did not work for me (Ubuntu Hirsute):

  1. curl ... ok
  2. sudo apt update errors:
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://archive.swiftlang.xyz/ubuntu hirsute InRelease' doesn't support architecture 'i386'
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://swiftlang.xyz/ubuntu hirsute InRelease' doesn't support architecture 'i386'

I had to update /etc/apt/sources.list.d/swiftlang-release.list:

< deb https://archive.swiftlang.xyz/ubuntu/ hirsute  main
< deb https://swiftlang.xyz/ubuntu/ hirsute  main
---
> deb [arch=amd64] https://archive.swiftlang.xyz/ubuntu/ hirsute  main
> deb [arch=amd64] https://swiftlang.xyz/ubuntu/ hirsute  main

The the update was ok:

OK:6 https://archive.swiftlang.xyz/ubuntu hirsute InRelease                                                                      
OK:7 https://swiftlang.xyz/ubuntu hirsute InRelease
  1. But then with "apt install swiftlang" the following error occurs:
E: Unable to locate package swiftlang

P.S.: Also:
https://swiftlang.xyz/ubuntu/dists/hirsute/main/binary-amd64/Packages is 0 bytes
https://swiftlang.xyz/ubuntu/dists/hirsute/main/binary-amd64/ is forbidden
https://swiftlang.xyz/ubuntu/dists/hirsute/main is forbidden
...

Solution: Changing swiftlang-release.list to

deb [arch=amd64] https://archive.swiftlang.xyz/ubuntu/ focal main
deb [arch=amd64] https://swiftlang.xyz/ubuntu/ focal main

worked. I had to manually install libpython3.8 libpython3.8-minimal and libpython3.8-stdlib from groovy.

Update: The installation clashes with package "lld", the LLVM linker from the Ubuntu package repository.

@gonsolo
The error is reporting your system architecture as i386. Is this correct?
Can you post some info on your system?

Also there is only an arm64 release of Swift for Ubuntu/Hirsute at the moment.

No:

>> uname -mpi: x86_64 x86_64 x86_64

The thing is, it is a multiarch system so you should specify the arch in swiftlang-release.list as mentioned above.

I see. Maybe this should be mentioned on swiftlang.xyz and here in the forums. A better error message explaining what is going on would be helpful too.

I did post a list of available packages in an earlier post - New Swift Package Repository for Ubuntu/Debian Linux Distributions - #3 by futurejones

/var/www/swiftlang.xyz/public_html/ubuntu ~
swiftlang |        5.4.1-01-ubuntu-bionic |  bionic | amd64, arm64
swiftlang |         5.4.1-01-ubuntu-focal |   focal | amd64, arm64
swiftlang | 5.5-2021-07-09-a-ubuntu-focal |   focal | amd64, arm64
swiftlang |       5.4.1-01-ubuntu-hirsute | hirsute | arm64
~
/var/www/swiftlang.xyz/public_html/debian ~
swiftlang | 5.4.1-01-debian-buster | buster | arm64
swiftlang | 5.1.5-01-debian-buster | buster | armv7
~
/var/www/swiftlang.xyz/public_html/raspbian ~
swiftlang | 5.1.5-01-raspbian-buster | buster | armhf

The error messages are the standard error messages generated by the apt package manager on your system. They are not anything I can change on the repository side.

Thanks for your feedback, I will look into including the archtype in the sources list.

I didn't see this post, sorry.
And thanks for providing Swift as a deb package.

A few remarks:

  1. The package seem to overwrite my clang, it was version 12, not it is version 10.
  2. As I said, I had to purge lld because of a collision.
    Apart from that, swift runs like a charm. :slight_smile:

Also setting the directories

https://swiftlang.xyz/ubuntu/pool/main/s/swiftlang
https://swiftlang.xyz/ubuntu/pool/main/s
https://swiftlang.xyz/ubuntu/pool/main
https://swiftlang.xyz/ubuntu/pool
https://swiftlang.xyz/ubuntu/dists/
https://swiftlang.xyz/ubuntu/dists/focal
https://swiftlang.xyz/ubuntu/dists/focal/main
https://swiftlang.xyz/ubuntu/dists/focal/main/binary-amd64
...

readable would help to find the right packages.

Another long-term wish would be to build swift with the system clang (12 at the moment) and not include clang in swiftlang. But I guess this has to be sorted out at a higher level.

I agree. From my non-expert perspective that is a great way to increase adoption of Swift on Linux.

You may want to do what @Ron_Olson did with the Fedora package: he put the Swift toolchain in /usr/libexec/swift/ and only symlinked swift, swiftc, and sourcekit-lsp in /usr/bin/. That way, he can install the full Swift toolchain, including its forked LLVM binaries, in a separate directory and not have it collide with system LLVM packages like lld or lldb.

The alternative is to use the system LLVM packages instead, which is what I do with my Termux package that runs natively on Android devices. That means I don't have the Swift REPL with the Swift-forked lldb working though.

1 Like

That is an option but at this point I don't it's the right thing to do for debian/ubuntu packages.

  1. It hides the underlying issue that we have multiple versions of packages conflicting with each other. This needs to be addressed, especially as the swift versions of the packages are now older than default installed versions.
    The best solution is to decouple the packages and supply them as separate install packages.

  2. The second best solution is to use the replaces option in the debian/control file. This can be used to identify and fix any conflicts with existing packages. The replace option in the apt package manager works differently the the equivilent option in redhat's yum packager. In the apt package manager, replaces allows 2 packages to coexist and only addresses the conflicting files.
    In the swift-5.4.2 packages there are currently the following replaces options used - clang, clang-10, libicu, lldb, llvm (The clang versions change depending on default option available for the install target)
    It looks like lld will also have to be added to the list.

1 Like

Repository Update

Repository Mirror

I have added a mirror to the swiftlang repository. The mirror is hosted on a larger system with better network performance.

The mirror can used by adding running the install repository script.

curl -s https://swiftlang.xyz/install.sh | sudo bash

The install script is also available on the mirror.

curl -s https://archive.swiftlang.xyz/install.sh | sudo bash

Browsable Repository Directories

The directories in the repositories are now browsable.
example -
https://swiftlang.xyz/ubuntu/
https://archive.swiftlang.xyz/ubuntu/

Swift 5.4.2 x86_64/amd64 Package for Ubuntu/hirsute.

There is a new install package for ubuntu/hirsute amd64 version.
There is no official hirsute version so I have repackaged the focal version to install on hirsute.
This means that the swiftlang package needs libpython3.8. (hirsute is now on libpython3.9)
Note: To install libpython3.8 on hirsute you will need to add the sources for ubuntu/groovy to the /etc/apt/sources.list file.

# add swiftlang repository
curl -s https://swiftlang.xyz/install.sh | sudo bash

# add groovy sources
echo "deb http://archive.ubuntu.com/ubuntu/ groovy main restricted" | sudo tee -a /etc/apt/sources.list

# run update
sudo apt update

# install swift
sudo apt install swiftlang
3 Likes

I have a POWER9 ppc64le machine running Ubuntu 20.04.
Is it possible to add swift ppcle64 to your apt repo?

@BracketMaster, I don't think Swift is available for ubuntu/20.04/ppc64le, but if somebody can supply a compatible toolchain, I can package it and add it to the repository.

Respostory Update

New Developer Snapshots.

Swift 5.6 has arrived!
The developer snapshots have been updated to 2021-07-30-a

Swift version 5.6-dev (LLVM ba0b85f590c1ba2, Swift b8d2f269cb060ad)
Target: x86_64-unknown-linux-gnu

Fix for lld Conflict

All the 5.4.2 packages have been rebuild with fix for lld conflict.
The new packages have an iteration number of 02 and will be available after running sudo apt update.

# example
# old package
swiftlang_5.4.2-01-ubuntu-focal_amd64.deb

# new package
swiftlang_5.4.2-02-ubuntu-focal_amd64.deb
2 Likes

amd64 for Debian Buster - is it coming back to your repository?