simple Debian repository

This tutorial will show how to set-up simple Debian repository. dpkg-scanpackages, dpkg-scansources, apt-ftparchive, gpg and a Makefile will be used. The folder structure is following:

debian-simple-repo
|-- Makefile
|-- Release.conf
`-- unstable    # files here generated
    |-- Packages
    |-- Packages.bz2
    |-- Packages.gz
    |-- Release
    |-- Release.gpg
    |-- Sources
    |-- Sources.bz2
    `-- Sources.gz

Makefile

all: repository

repository:
	dpkg-scanpackages unstable /dev/null > unstable/Packages
	dpkg-scansources  unstable /dev/null > unstable/Sources
	
	bzip2 -c9 unstable/Packages > unstable/Packages.bz2
	gzip -c9 unstable/Packages > unstable/Packages.gz
	bzip2 -c9 unstable/Sources  > unstable/Sources.bz2
	gzip -c9 unstable/Sources  > unstable/Sources.gz
	
	apt-ftparchive -c=Release.conf release unstable > unstable/Release
	-rm unstable/Release.gpg
	gpg -abs -o unstable/Release.gpg unstable/Release

clean:
	rm -f unstable/Packages* unstable/Sources* unstable/Release*

Release.conf

APT::FTPArchive::Release::Origin "your@email";
APT::FTPArchive::Release::Label "Test repository";
APT::FTPArchive::Release::Suite "unstable";
APT::FTPArchive::Release::Architectures "i386 source";
APT::FTPArchive::Release::Components "main";

generation

All *.deb, *.dsc, *.diff.gz, *.changes, *.orig.tar.gz has to be copied to the unstable/ folder and `make` executed. This will generate unstable/Packages*, unstable/Sources*, unstable/Release* files. Then just the whole folder as-is copied to a web/ftp server.

usage

/etc/apt/sources.list file on a Debian machine has to be updated and a gpg key has to be added through `apt-key add`.

sources.list

deb http://your.hostname/some/folder/ unstable/
deb-src http://your.hostname/some/folder/ unstable/

beyond simple

For more advanced and more distribution like repository use reprepro. Setting up your own APT repository with upload support - is a good introduction to it.

7 Jul 2009
Jozef