This tutorial will go through the steps needed to set up an apt repository, used in Debian and Debian-based distributions.
Setting up an apt repository is very easy, no advanced Linux skills are needed for this. You’ll need however the approrpriate rights to install software and edit apache 2 (or the webserver of your choice) config files.
First, create the directory where you want the repository to be located. We’ll be using the /var directory in this tutorial. Adjust all directories with your directory of choice, if you chose to use a different path
mkdir /var/apt-repo mkdir /var/apt-repo/conf
Change directory to the newly created /var/apt-repo/conf, and create a file inside called
Edit this file and insert the needed data for the repository:
Origin: Your Name Label: Your label Codename: Version release name Architectures: i386 amd64 source Components: main non-free contrib Description: A description
You can add more repositories in the file, e.g.:
Origin: Your Name Label: Your label Codename: Version release name (e.g. "lenny", "squeeze" for debian, "karmic","lucid" for Ubuntu, etc.) Architectures: i386 amd64 source Components: main non-free contrib Description: A description Origin: Your Name Label: Your label Codename: Version release name Architectures: i386 amd64 source Components: main non-free contrib Description: A description
Further options you can add per repo are
suite: stable|testing|sid version: 5.0|6.0 Signwith: yes
“suite” indicates the debian suite you’re targetting, whereas the version number indicates just that.
Add the “Signwith” option if you want to create a signed repository.
Now install the package reprepro by executing
sudo apt-get update sudo apt-get install reprepro
Once installed, navigate, if you have left, back to /var/apt-repo, and execute
reprepro -Vb . includedeb squeeze /path/to/your/current/debfile/location.deb
You may have to run beforehand
incase reprepro complains about vanished distributions.
This will now create your debian repository and its needed config files.
Next step is to create a simple apache 2 config file.
Navigate to /etc/apache2/sites-available and create a file called apt-repo.
<VirtualHost *:80> ServerName apt.example.com DocumentRoot /var/apt-repo/ <Directory /var/apt-repo/> Options Indexes </Directory> ErrorLog /var/log/apache2/apt-repo_error.log CustomLog /var/log/apache2/apt-repo_access.log combined </VirtualHost>
Sym-link this file to /etc/apache2/sites-enabled, restart apache, then add following to /etc/apt/sources.list
deb http://apt.example.com/ lenny main contrib non-free deb-src http://apt.example.com/ lenny main contrib non-free deb http://apt.example.com/ squeeze main contrib non-free deb-src http://apt.example.com/ squeeze main contrib non-free
If you prefer to secure your repository against public accessibility, set up http auth for your web directory, and adjust your sources.list accordingly
deb http://username:firstname.lastname@example.org/ lenny main contrib non-free
sudo apt-get clean sudo apt-get update sudo apt-cache search
Your apt-repository is now set up to use.
If you want to remove a package from the repository, execute a similar command as to include a package:
reprepro -Vb . remove squeeze package_name
Note: Adding a newer version of a package to the repository does not require to remove the previous version by hand. This is done automatically by the tool.
In another tutorial we’ll go into creating deb files which you can use in your repository.