Debian packaging

From Software Heritage Wiki
Revision as of 14:33, 10 February 2017 by Ardumont (talk | contribs)
Jump to: navigation, search

Creating a package for deployment

swh-environment contains a script, bin/make-package, which generates a Debian package from a given Git repository, and uploads it to our internal repository targeting suites unstable and jessie-backports.

This assumes that the current (HEAD) revision has been tagged with a version v<foo> (e.g. v0.0.4), and that the repository contains the debian metadata. (i.e. debian/{copyright,control,changelog.rules,source/format,compat}).


 $ git tag -as -m 'version 0.0.42' v0.0.42
 $ bin/make-package -b -u swh-core

Package repository

A package repository is available on

Unstable / Testing :

 deb [trusted=yes] unstable main

Stable / Jessie :

 deb [trusted=yes] jessie main

This package repository is handled via reprepro on (base directory : /srv/softwareheritage/repository).

Uploading packages

Packages are added to the repository using reprepro -vb /srv/softwareheritage/repository processincoming incoming.

For packages to be accepted, they need to be :

  1. A changes file uploaded to /srv/softwareheritage/repository/incoming
  2. Targetted at one of the supported distributions (unstable, unstable-swh, jessie, jessie-backports, jessie-backports-swh)
  3. Signed by one of the keys listed in /srv/softwareheritage/repository/conf/uploaders

Build Environment setup

bin/ uses sbuild for package construction. You therefore need to setup sbuild before being able to use it.

sbuild setup

# Install the package
sudo apt-get install sbuild

# Add your user to the sbuild group, to allow him to use the sbuild commands
sudo sbuild-adduser $USER
# You have to logout and log back in

# Prepare chroots
sudo mkdir /srv/chroots
sudo mkdir /srv/chroots/var

# Optionally create a separate filesystem for /srv/chroots and move the sbuild/schroot data to that partition
sudo rsync -avz --delete /var/lib/schroot/ /srv/chroots/var/schroot/
sudo rm -r /var/lib/schroot
sudo ln -sf /srv/chroots/var/schroot /var/lib/schroot

sudo rsync -avz --delete /var/lib/sbuild/ /srv/chroots/var/sbuild/
sudo rm -r /var/lib/sbuild
sudo ln -sf /srv/chroots/var/sbuild /var/lib/sbuild
# end optionally

# Create unstable/sid chroot
sudo sbuild-createchroot sid /srv/chroots/sid

# Create jessie chroot
sudo sbuild-createchroot jessie /srv/chroots/jessie

# Create sbuild autosign gpg key (!! needs entropy, consider installing haveged and not worrying about it again)
sudo sbuild-update --keygen

# If you use /etc/hosts to resolve * hosts
echo hosts >> /etc/schroot/sbuild/nssdatabases

schroot setup

Now that the sbuild base setup is done. You now need to configure schroot to use an overlay filesystem, which will avoid copying the chroots at each build.

In recent (>= 1.6) versions of schroot, you need to update the configuration (in /etc/schroot/chroot.d/*-sbuild-*) with the following directives:


You should also use this opportunity to add "aliases" to your chroot, so that sbuild will directly support the distributions we're using (unstable-swh, jessie-backports-swh):

For unstable:


For jessie:


dependencies cache

Add the following line to schroot's fstab /etc/schroot/sbuild/fstab to permit reuse of existing fetched dependencies:

   /var/cache/apt/archives /var/cache/apt/archives none rw,bind 0 0

environment setup

The Debian tools use a few variables to preset your name and email. Add this to your .<shell>rc

export DEBFULLNAME="Debra Hacker"

Make sure this data matches an uid for your GPG key. Else, you can use the DEBSIGN_KEYID=<yourkeyid> variable.