From the moment you build your own .deb package, you also want to install it. The easiest way to install / uninstall your custom packages is by using dpkg. But using dpkg means the packages need to be present on the host you wish to install them on. Another downside of dpkg is that it won’t install dependencies for you.
If you want a central system, you’ll need to create and APT repository. Thankfully, this is a simple task with the reprepro tool.
A repository can contain packages for multple distributions and architectures. So the first thing you’ll need to do is install the reprepro package:
$ sudo apt-get install reprepro
Once you’ve installed it, you can begin creating the desired directory structure, but first you’ll need to decide through which protocol you wish to make the repository available. The most used options are:
- serving packages through http
- serving packages through ssh
The difference between the two is that when serving your packages using http, your repository will be publicly available for everyone to use. In some cases, you might want to shield access. You can do this with basic authentication, or use ssh as I’ll do.
I’ve created a custom user, so I’ll be creating the directory structure under the users home directory:
sudo mkdir -p /home/<username>/repos/apt/ubuntu/
Now that we have created the proper directory, the next thing we’ll need to do is creating the necessary configuration file. This configuration file will specify which releases the repository will contain as well as the architectures.
So start by creating the distributions under /home//repos/apt/ubuntu/conf which contains the following information:
Origin: <your-name> Label: <your-own-label> Suite: <stable|unstable> Codename: <linux-version-name> Version: <linux-version-number> Architectures: <i386|amd64|all|source> Components: <main|non-free|contrib> Description: <your-description>
In my case, it looks like this
Origin: Michaël Rigart Label: Netronix repository Suite: stable Codename: precise Version: 12.04 Architectures: all Components: main Description: private Netronix repository
So here we’ve defined a repository which only contains packages for stable/precise, which contains packages targeted to all architectures.
Adding / Removing packages
Now adding packages is quite straightforward. This can be achieved by running the following command:
$ sudo reprepro -Vb <repository-root> -C main includedeb <distribution> <package>
Removing a package works similarly
$ sudo reprepro -Vb <repository-root> --ignore=unusedoption remove <distribution> <package>
Using your repository
The only thing left is to add your repository. As described above, you have two ways to interact with the repository. So add one of the following to your /etc/apt/sources.list file:
for http:
deb http://your-repo.com/<repository-root> <distribution> <components>
for ssh
deb ssh://<repo-user>@<repo-host>:<repository-root-path> <distribution> <components>
Of course, when using http, you’ll need to setup a web server.
When using ssh, I would suggest creating a password-less key, so you don’t need to enter the password all the time.