@mishal_shah, setting up something similar to https://swiftlang.xyz on Swift.org would be fairly straight forward but it is not a simple process and there are number of separate items required that are then combined to create the completed repository.
Here is an overview of what is needed.
The Repository Server.
The repository needs a dedicated server, preferably bare metal, running Ubuntu 20.04.
The hardware does not need to be too large or powerful (>2Ghz quad core cpu, 8Gb ram) but it will need ample fast ssd storage and plenty of network bandwidth.
The following software is used to create, run and maintain the repository.
- nginx
- wget
- curl
- gpg
- dpkg-sig
- reprepro
Repository Domain Name
The repository requires a fully qualified domain name and ssl certificate. This is usually a sub-domain of the organization e.g. archive.swift.org
DNS will need changed to point the sub-domain to the repository server.
SSL certificates can be obtained and installed using certbot
and letsencrypt
Creating Signing Keys
gpg
is used to create a repository signing key. The public key then needs to exported and made available in the root of the repository for users to download and install.
Creating the Repository
reprepro
is used to create the repository. This involves setting the required directory structure for each distribution e.g. ubuntu, debian etc. and adding a config file.
Debian Package Creation
This is a whole other area for discussion. Package creation should not be taking place on the repository server.
The main and key point that we need to know for the repository is the package name
.
This needs to be swiftlang
and not swift-lang
.
There has been a registered debian package called swift
for many years, long before Swift the programming language even existed. If we use swift-lang
the hyphen indicates that it is part of the existing swift
package family.
There are many swift-
packages currently available for ubuntu/debian that have nothing to with Swift the programming language. -
- swift
- swift-bench
- swift-doc
- swift-object-expirer
- swift-account
- swift-container
- swift-object
- swift-proxy
I am using fpm
for debian package creation from swift.tar.gz files. It works very well and can be added as build step on the swift ci.
Uploading Packages
First the deb packages need to be uploaded to temp directory on the repository server.
reprepro
is then used to add the package to the repository. reprepro
automatically takes care of all code signing and creates any extras directories may be needed.
Installing and Using the Repository
To use the repository you need to do 2 things -
- add the repository signing key.
- add the repository url to the apt sources list.
This can be done manually or using a simple bash install script
References
https://manpages.ubuntu.com/manpages/focal/man1/gpg.1.html
https://wiki.debian.org/DebianRepository
https://wiki.debian.org/DebianRepository/SetupWithReprepro
https://fpm.readthedocs.io/en/latest/