Building Debian Packages

From Koha Wiki

Jump to: navigation, search
Home > Documentation
Home > Documentation > Installation
Home > Documentation > Installation > Debian Packages
Koha > Technical > Administration
Koha > Technical > Administration


Koha Packaging

This describes creating and deploying packages to These instructions are intended for advanced Debian users, and having some experience with building packages probably wouldn't hurt.

This is something of a mind-dump of unstructured information. This other URL might be more useful to start with:

Build The Packages

I have a VM (that I call debmaker32) specially set up for building packages on. Setting that up is left as an exercise for the reader, and using SSH keys will make things a lot easier. It should have GPG agent configured if you want to sign the packages, along with all the Debian packaging-related tools.

The packages are based on the master branch of the Koha repository (at

I have a script that carries out the entire process of building the packages to a local repository. It'll need to change to suit your environment, but the principles should remain the same. In this, I have /home/robin/catalyst (which is also ., where I run the script from) NFS-mounted as /mnt/catalyst in the VM.

$ cat make-kc-packages 
[ -e koha-build ] && ( 
    mv koha-build koha-build-delete ;
    rm -rf koha-build-delete 
) &
sleep 1
cp -r koha koha-build
rm -rf koha-to-deploy
mkdir koha-to-deploy
cd koha-build
git clean -f -x -d
rm -rf blib
ssh -t debmaker32 <<'EOH'
cd /mnt/catalyst/koha-build
rm -rf /tmp/kohabuild
mkdir /tmp/kohabuild debian/build-git-snapshot /tmp/kohabuild
cp -v /tmp/kohabuild/* /mnt/catalyst/koha-to-deploy
# Necessary to not use GPG_AGENT because of 
# - also, this has to be on 
# its own command or you get strange TTY-related errors with GPG. Debsign seems
# to be sorta broken really.
ssh -t debmaker32 "GPG_AGENT= debsign -kA99CEB6D /mnt/catalyst/koha-to-deploy/*.changes" 
cd ..
dput koha koha-to-deploy/*.changes

The config file for dput, which is on the local machine:

$ cat ~/ 
method = local
incoming = /home/robin/catalyst/repos/koha/incoming
run_dinstall = 0
post_upload_command = reprepro -b /home/robin/catalyst/repos/koha processincoming default

You'll need to enter your GPG password a few times during this process due to annoying bugs with debsign and it not supporting gpg-agent.

It expects to be run from a directory that has a koha subdirectory which contains the checked out version that will be turned into packages. It will create a cleaned copy of that and build it. In the end, the packages will be added to the repository, which in my case lives at ~/catalyst/repos/koha.

build-git-snapshot uses pdebuild to make the packages. To account for the dependencies that are currently not in Debian, creating the pbuilder environment is a bit complex.

Configuring Pbuilder

$ gpg --import /usr/share/keyrings/debian-archive-keyring.gpg
gpg: key F42584E6: public key "Lenny Stable Release Key <>" imported
gpg: key 55BE302B: public key "Debian Archive Automatic Signing Key (5.0/lenny) <>" imported
gpg: key 6D849617: public key "Debian-Volatile Archive Automatic Signing Key (5.0/lenny)" imported
gpg: key B98321F9: public key "Squeeze Stable Release Key <>" imported
gpg: key 473041FA: public key "Debian Archive Automatic Signing Key (6.0/squeeze) <>" imported
gpg: key 46925553: public key "Debian Archive Automatic Signing Key (7.0/wheezy) <>" imported
gpg: key 65FFB764: public key "Wheezy Stable Release Key <>" imported
gpg: Total number processed: 7
gpg:               imported: 7  (RSA: 6)
$ gpg --recv-key A2E41F10
gpg: requesting key A2E41F10 from hkp server
gpg: key A2E41F10: "Koha Debian Package Signing Key <>" imported
gpg: Total number processed: 1
gpg:               imported: 1
$ gpg --recv-key A99CEB6D
gpg: requesting key A99CEB6D from hkp server
gpg: key A99CEB6D: "Robin Sheat <>" imported
gpg: Total number processed: 1
gpg:               imported: 1
# Following list of key IDs is the Debian archive + the koha-community packages
$ gpg --export F42584E6 55BE302B 6D849617 B98321F9 473041FA 46925553 65FFB764 A2E41F10 A99CEB6D > /tmp/debian.gpg

Now create the pbuilder environment, and import the keyring created:

sudo pbuilder create --othermirror 'deb squeeze-dev main' --mirror --distribution squeeze --debootstrapopts "--keyring=/tmp/debian.gpg"

Deploy the Packages

The local repository should then be synced to the repository using a script along these lines (which, if you add -P to when running will tell you how it's going.) This will need to change to work with your repository location. Note: you probably can't do this unless you're the maintainer, but you may want to adapt it to your local environment.)

$ cat publish-koha-apt-repo 
set -e
rsync -a --partial --delete-after "$@" \
    "$HOME/catalyst/repos/koha/." \

More about Debian packaging

Developer handbook

Personal tools