Skip to content. Skip to navigation

Ian Lawrence

Personal tools
You are here: Home Blog Setting up a personal debian repository

Setting up a personal debian repository

A Debian repository is a set of Debian packages organized in a special directory tree which also contains a few additional files containing indexes and checksums of the packages.


If a user adds your repository to her /etc/apt/sources.list file, she can easily view and install all the packages available in it.
If your repository is listed in sources.list, apt-get will fetch the Packages.gz index if the binary packages are listed (with the deb keyword) and Sources.gz if the sources are listed (with the deb-src keyword).

Packages.gz contains the name, version, size, the short and the long description, and the dependencies of each package
Sources.gz contains the name, version and the build dependencies (the packages needed to build) of each package

Repositories can offer different packages for each supported distribution and for each of the supported architectures; apt will automatically fetch the right one for a user's machine, without her even having to know about all the different architectures.
It also allows grouping of your packages into components, just as Debian's packages are divided into main, non-free, contrib and so on.
Distributing the packages in many different directories can however become unmanageable.
It is also a waste of space and bandwidth, as there are many packages (for example documentation packages) which are the same for all architectures. In such cases, a possible solution is a pool. A pool is an additional directory under the repository root containing all packages (the binaries for all architectures, distributions, and components, and all the sources).

Set up

Reprepro makes it very easy to set up APT repositories that use a common /pool directory to store all the package files.

Repositories will go under /var/packages/ and it will be set up for the Ubuntu Gutsy distribution.
The directory /var/packages/ubuntu/ is going to be the base of the Ubuntu repository.
root@host:/var# mkdir packages;cd packages
root@host:/var/packages# mkdir ubuntu;cd ubuntu
root@host:/var/packages/ubuntu# mkdir conf;cd conf
root@host:/var/packages/ubuntu/conf# vi distributions
inside this file put:
Origin: Ians
Label: Ians Personal Debs
Codename: gutsy
Architectures: i386 amd64 source lpia
Components: main
Description: Ians Personal Debian Repository
SignWith: yes
DebOverride: override.gutsy
DscOverride: override.gutsy
The Origin, Label and Description field can be filled with whatever you want.
The Codename is the specific distribution/version that this block of settings applies to. In this case it's gutsy.
The Architectures can be any of the 11 debian builds for and the Components can be of your choosing such as main non-free contrib and so on.
SignWith indicates that you want to create a Release.gpg file, creating a signed APT repository.
The DebOverride and DscOverride fields tell reprepro what files to use for the override rules. Override rules can be used to override .deb and .dsc configuration fields. Now create an options file:
root@host:/var/packages/ubuntu/conf# vi options
inside this file put:
basedir .
(ask-passphrase is used if you created a signed repo)
root@host:/var/packages/ubuntu/conf# cd ..
root@host:/var/packages/ubuntu/# mkdir override;cd override
root@host:/var/packages/ubuntu/override# touch gutsy.override
this creates the override file if we need to use it later.

Adding a deb

root@host:/var/packages/ubuntu# $ reprepro includedeb
so for my repo I did:
root@host:/var/packages/ubuntu# $ reprepro includedeb gutsy /home/debs/liferea_1.4.4-0ubuntu4_i386.deb
(notice the full path to the deb itself) More info about adding/removing debs and general repo 'good practice' is here

Setting up Apache

I am running mod_python so I control which urls are served with python or apache using apache's httpd.conf. First of all, make an Alias to the repository
root@host:/var/packages/ubuntu# cd /etc/apache2/sites-enabled/
root@host:/etc/apache2/sites-enabled# vi 000-default
this file should look like (the part below and including Alias /packages/ "/var/packages/" ) :
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#RedirectMatch ^/$ /apache2-default/

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from ::1/128
Alias /packages/ "/var/packages/"
<Directory "/var/packages">
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.html
AllowOverride Options
Order allow,deny
allow from all
<Directory "/var/packages/*/conf">
Order allow,deny
Deny from all
Satisfy all
<Directory "/var/packages/*/db">
Order allow,deny
Deny from all
Satisfy all
then add a SetHandler in httpd.conf to let apache handle the repo and not mod_python
root@host:/etc/apache2/sites-enabled# cd ..
root@host:/etc/apache2# vi httpd.conf

<location "/packages">
SetHandler None
and restart apache (/etc/init.d/apache2 restart)

The repository is browsable at: http://<>/packages/

To check out your debs using apt you need to add:
deb http://<>/packages/ubuntu gutsy main
deb-src http://<>/packages/ubuntu gutsy main
to /etc/apt/sources.list and do an apt-get update
Sunday, December 09, 2007 in CodeWork  | Permalink |  Comments (0)   Digg   Yahoo   Google   Spurl
« August 2020 »
Su Mo Tu We Th Fr Sa
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Borala (4)
Bricolabs (12)
Code (57)
Estudiolivre (12)
Life (26)
MetaReciclagem (9)
Thoughts (16)
Work (41)