Deb repo for selfhosting with reprepro
Recently I discovered that reprepro at tool for creating apt/deb repositories has support of archive mode, this feature is not available in stable debian but is available with the reprepro version in "experimental" repository, which means is experimental but good enough for what I need so far.
Because of this, I started to create repo to store my personal builds, often done through cargo deb or similar tools, so
here is a guide on how I setup the repo.
First thing create a folder for the repo:
mkdir deb_repo
Than create a folder for the repropro conf in that folder.
cd deb_repo
mkdir conf
than create in there a distributions file with the configuration of the distribution[s] that you need to support
vi conf/distributions
With the following content:
Codename: trixie
Suite: stable
Architectures: amd64
Components: main
Contents:
SignWith: MYOWNPGPKEYHAS35953DESDGWWER3503DD22QE3E
Origin: myownrepo.example.com
Label:
Limit: 0
Description: Personal repo for self-built self-hosting software
Codename: sid
Suite: unstable
Architectures: amd64
Components: main
Contents:
SignWith: MYOWNPGPKEYHAS35953DESDGWWER3503DD22QE3E
Origin: myownrepo.example.com
Label:
Limit: 0
Description: Personal repo for self-built self-hosting software
Each block represent a supported distribution, let's go through the main settings:
- Codename: The distribution target for this repo
- Suite: The alias of the suite repo
- SighWith: your PGP key id to use to sign the packages in your repo (you should have a GPG key if you do not have one there are some instructions for it here)
- Origin: The name of the repository used as origin in various settings
- Limit : This is what enable the archive mode, value 0 means no limit of versions of the same package, this can be put to a specific value to keep the limit.
- Description: The description of the repo
A more detailed description of these fields can be found here
Created the configuration file, now is just needed to run the commands to create the repo:
reprepro createsymlinks
reprepro export
Done this you will have your empty repository
You can include deb files with
reprepro includedeb trixie mydebfile_1.2.3_amd64.deb
Or remove deb files:
# This will remove the most recent
reprepro remove trixie mydebfile
Done this you can simply expose the generated dists and pool folder through a http server the other files/folders should not be exposed.
I do like to manage the repo from a different machine on where is published, so I simply use rsync to upload everything, I also include some other files to make it
easier to install the repo like the .sources file and the pgp
This is a simple sh script to upload everything
#!/bin/sh
set +x
rsync -avz -e "ssh -C" myownrepo.sources myownrepo.pgp dists pool user@example.com:/var/www/myownrep.example.com/
This is an example source files that can just be downloaded to the right folder with a wget
Types: deb
URIs: http://myownrepo.example.com
Suites: sid
Components: main
Signed-By: /etc/apt/keyrings/mywonrepo.pgp
# wget https://mywonrepo.example.com/myownrepo.sources -O - | sudo tee /etc/apt/sources.list.d/myownrepo.sources
# wget https://mywonrepo.example.com/myownrepo.pgp -O - | sudo tee /etc/apt/keyrings/myownrepo.pgp
Also in some cases you want to change the priority of your repo, or have an experimental repo low priority, to do that you can use the pref file,
this is an example of a pref file for a repo with Codename: experimental and Suite: experimental.
Package: *
Pin: release o=myownrepo.example.com, a=experimental
Pin-Priority: 1
# wget https://mywonrepo.example.com/myownrepo.pref -O - | sudo tee /etc/apt/preferences.d/myownrepo.pref
It is suggested to actually store the public key in "keyring" package, to make sure to have smooth key updates through the same repo, I'm not describing it here, but you can find some details here
Ko-fi