Your Own Debian Repository

During my apprenticeship as Linux Admin, i got the problem that i had to install a selfbuild package on many servers.

A neat way to install a selfbuild package on many servers, without copying it to to every server by scp,  is to create your own repository, so you can use apt to install your package. 🙂

As first we need to install the dpgk-dev package to gain access to the needed tools.


apt-get install dpkg-dev lighttpd

Now we create the folders where we want to store our packages

mkdir -r /srv/repository/i386
mkdir -r /srv/repository/amd64

In my oppinion it’s easier to have the different architectures in different folders, but it should also work to put them in one (haven’t tried it yet).

In the next step we configure lighttpd to show our repository 🙂


#/etc/lighttpd/lighttpd.conf

...
server.document-root    /srv/repository/;
...

lighttpd

When you now point your favourite webbrowser to your server’s ip oder domain you should see someting like this

Now you can place your packages in the directories. 🙂

Now we need one more small thing to make these directories apt compatible.

Apt need a file called “Packages.gz” which contains all informations about your packages you offer in your repository. To generate this file, we have installed dpkg-dev which brings the tool dpkg-scanpackages.

Simply go to your direktory an let dpkg-scanpackages generate the Packages.gz


cd /srv/repository/
dpkg-scanpackages i386 /dev/null | gzip -9c > 386/Packages.gz
dpkg-scanpackages amd64 /dev/null | gzip -9c > amd64/Packages.gz

## For a repository of sources use
dpkg-scansources source /dev/null | gzip -9c > source/Sources.gz

Concluding you have to add the following lines to your apt sources.list:

deb http://yourserver.example.com/ i386/
deb http://yourserver.example.com/ amd64/

And now have fun with your own debian repository. 🙂