User Tools

Site Tools


projects:package-building

This is an old revision of the document!


Setup an package building environment for Debian/Ubuntu

These are personal notes on how I setup package build environments. When done, I intend to writeup a blog post about it.

Install a Debian or Ubuntu Machine

This step may be a bare-metal, or virtual machine, such as bare http://www.linux-kvm.org/, libvirt, VirtualBox or VMWare.

First, install a minimal system. For Ubuntu, I recommend using the Server CD, and install only the SSH Task. This installer is very similar to the Debian installation media, as both use the software |http://wiki.debian.org/DebianInstaller. This installer comes with extensive documentation here: http://www.debian.org/releases/testing/amd64/

For both, Debian and Ubuntu, I recommend installing in “expert mode”, which can be selected at the boot prompt.

Installing LXC

Ubuntu (I guess the same is true for debian) offers convenient means to create Debian and Ubuntu based LXC containers. Inside the container the network, filesystem, and processes are isolated, but disk space, disk i/o and cpu time is shared. It is also very lightweight as no extra kernel is involved. For details, see https://help.ubuntu.com/lts/serverguide/lxc.html.

I recommend running the root filesystem on btrfs, lxc-create will automatically detect this and create subvolumes as appropriate.

Steps to create a container suitable for package building:

 SUITE=wheezy lxc-create -t debian-build
 echo 'lxc.network.ipv4 = 10.0.3.200' >> /var/lib/lxc/debian-build/config
 ln -s /var/lib/lxc/debian-build/config /etc/lxc/auto/debian-build.conf

Preparing the environment

Install packages that are relevant for packaging. Note that I prefer ''sbuild'' over pbuilder for two reasons: First, this is the software that runs on the official buildds in both Debian and Ubuntu. Second, the packaged version extensively uses schroot for chroot management, which makes it very easy to setup and maintain separate build environments (such as squeeze + squeeze-backports or quantal + some-extra-ppa).

The following command gets you started:

sudo apt-get install packaging-dev pbuilder- sbuild ubuntu-dev-tools

The ubuntu-dev-tools package is available in all relevant versions of Ubuntu, and in Debian since debian/wheezy

Setup the build chroot and keeping it up-to-date

This step needs to be repeated for every build environment you want to use:

mk-sbuild --eatmydata unstable

Replace unstable with the distribution you want to base this on. On Intel 64bit installations, this will create unstable-amd64 as schroot managed “chroot”. Adjust to your environment as necessary.

Note that in this setup, your user needs to be in the group sbuild. The mk-sbuild tool takes care about that, that is, it adds your user to the group via adduser, and asks you to relogin.

Now enter the chroot and edit the package sources in /etc/apt/sources.list and /etc/apt/sources.list.d/*.list:

sudo schroot -c source:unstable-amd64 -u root
sensible-editor /etc/apt/sources.list

To install the latest update in that environment, use:

sudo schroot-update -ud unstable-amd64

This runs unattendedly and could also be run via cron.

Building a package

To build a package, use:

sbuild -A -d unstable hello.dsc
projects/package-building.1373702030.txt.gz · Last modified: 2013/07/13 07:53 by siretart