Running Your Own Ubuntu Package Repository

A step-by-step guide to creating your own package repository so you have somewhere to distribute your own packages.

Prerequisites

Give the package repository somewhere to live

You'll need to store all your packages somewhere on your virtual machine.

mkdir -p /var/packages/xeriom/{hardy,gutsy}

Set up the packages subdomain

Add an A record to the DNS zone for your domain pointing to your virtual machines IP address. You can use any subdomain you like - I use packages.xeriom.net.

Install Apache and add a virtual host for the subdomain pointing to your packages root.

sudo apt-get install apache
nano -w /etc/apache2/sites-available/packages.xeriom.net

Add the following configuration

<VirtualHost *>
        ServerAdmin support@xeriom.net
        ServerName packages.xeriom.net
        DocumentRoot /var/packages
        ServerSignature Email

        <Directory /var/packages>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

Then enable the site and reload the Apache configuration.

sudo a2ensite packages.xeriom.net
sudo /etc/init.d/apache force-reload

Repository generation

Next we add a Package.gz generation command to the root crontab so it's trivial to add new packages.

sudo crontab -e -u root

*/5 * * * * cd /var/packages/xeriom && /usr/bin/dpkg-scanpackages . /dev/null |gzip -9c > /var/packages/xeriom/hardy/Packages.gz
*/5 * * * * cd /var/packages/xeriom && /usr/bin/dpkg-scanpackages . /dev/null |gzip -9c > /var/packages/xeriom/gutsy/Packages.gz

Adding a package

Move the package to the correct directory under your package repository and wait for the Package.gz generation task to run.

sudo mv ~/packages/debs/xeriom-quux-0.0-1.deb /var/packages/xeriom/hardy

Local configuration

Configure your local apt sources to use the new repository by editing /etc/apt/sources.list to include the following lines.

deb file:///var/packages/xeriom hardy

If you're using Gutsy replace "hardy" in the above lines with "gutsy".

Now try installing from the repository.

sudo apt-get update
sudo apt-get install your-package

Using your repository

To use your shiny new repository on a remote box edit sources.list to include the following line.

deb http://packages.xeriom.net/xeriom hardy/

Of course, replace packages.xeriom.net with your chosen subdomain and /xeriom with the path to your repository from the package VirtualHost document root. Note that the trailing slash on hardy/ is necessary.

Now just update your apt cache and install away.

sudo apt-get update
sudo apt-get install xeriom-god

XeriomWiki: RunningYourOwnUbuntuPackageRepository (last edited 2008-05-31 20:34:57 by CraigWebster)