sbuild-setup - sbuild setup procedure
uses chroots to build packages within, to provide a minimal and
consistent build environment. This man page describes the procedure to create
a chroot by hand using debootstrap. These are only guidelines; depending upon
the setup required, several of the steps may be omitted entirely.
Simply running sbuild-createchroot
will perform all the setup steps
described in detail below. See the section “
” below, as well as
This guide sets up a lenny chroot on a powerpc machine. Adjust the names for
other suites and architectures.
# mkdir -p /srv/chroot/lenny
The author has each chroot as a separate LVM logical volume (LV). Create and
mount an LV here if required:
# lvcreate -L 4G -n lenny_chroot -Z y volume-group
Add to /etc/fstab and mount (see next section for full fstab example). Finally,
run debootstrap to create the chroot:
# debootstrap --variant=buildd lenny /srv/chroot/lenny
An example /etc/fstab
If the bind mountpoints don't exist in the chroot, touch them:
# touch /srv/chroot/lenny/etc/resolv.conf
Next, mount them all.
Depending on your kernel version and security considerations, you may wish to do
this part slightly differently. With a Linux kernel, at least version 2.6 is
required for bind mounts, and devpts (CONFIG_UNIX98_PTYS) for /dev/pts
Other guides recommend copying the files, but this method keeps them
up-to-date at no cost.
If using sbuild with schroot, passwd
can be updated automatically at the
start of each build, so no action is required here. schroot can also
automatically mount all of the extra filesystems, so all the other mounts may
To disable networking, don't bind mount /etc/resolv.conf
. This will
prevent APT from working inside the chroot, but prevents package building from
having working network access (no nameservers).
Create or edit /srv/chroot/lenny/etc/apt/sources.list
, and add all the
APT sources required to obtain binary and source packages for your chosen
deb http://security.debian.org/ lenny/updates main
deb-src http://security.debian.org/ lenny/updates main
deb http://httpredir.debian.org/debian/ lenny main
deb-src http://httpredir.debian.org/debian/ lenny main
This is entirely optional, but will make the chroot environment easier to access
For dchroot, add the following line to /etc/dchroot.conf
For schroot, add a group to /etc/schroot/schroot.conf
(or a new file
), for example:
description=Debian lenny (stable)
For sudo, add a symbolic link to the directory /etc/sbuild/chroot
# mkdir -p /etc/sbuild/chroot
# ln -s /srv/chroot/lenny /etc/sbuild/chroot/lenny
# dchroot -c lenny
$ schroot -c lenny -u root
While running as root inside the chroot:
# apt-get update
# apt-get dist-upgrade
# apt-get install debconf
# dpkg-reconfigure -plow debconf
Answer the debconf questions as follows:
- choose 6/Noninteractive
- choose 1/Critical
You only need to run dpkg-reconfigure if you weren't asked the questions during
the debconf install. Next, install the packages required for building
# apt-get install fakeroot build-essential
# apt-get install makedev
# cd /dev/
# /sbin/MAKEDEV generic
# touch /etc/mtab
For some security, we don't bind mount /dev, so it can't access e.g. USB devices
While running as root inside the chroot:
# mkdir /build
# chown root:sbuild /build
# chmod 02775 /build
# mkdir -p /var/lib/sbuild/srcdep-lock
# chown -R root:sbuild /var/lib/sbuild
# chmod -R 02775 /var/lib/sbuild
Note that when using sbuild with schroot, this setup is done at the start of
each build, so is not required here.
Congratulations! You should now have a fully configured and operational chroot.
This script will automatically perform a number of the steps described above,
- Running debootstrap.
- Setting up APT sources in
- Setting up a minimal /etc/passwd
- Setting up /build and /var/lib/sbuild with appropriate
ownership and permissions.
After it has done this, you do still need to do some manual setup, completing
the steps it missed out above, for example.
As root, run:
Alternatively, add the user to the sbuild
group by hand:
Configure the user's ~/.sbuildrc
$ cp /usr/share/doc/sbuild/examples/example.sbuildrc
Edit to set the correct mail address to send log files to, and the correct
maintainer name and/or uploader name.
Create directories to contain packages and log files. (.sbuildrc may have
configured different locations; the default build directory is the current
directory, and the default $log_dir is ~/logs):
$ mkdir ~/logs
This step not required if schroot is used (which is the default, set in
). If using sbuild with sudo (chroot_mode
“split”), sudo needs configuring to give the user permission to
install and remove packages in the chroot, which requires root privileges. Add
the following lines to /etc/sudoers
is the name of the user who will run sbuild.
The user should now be able to run sbuild.
$ sbuild ...
Copyright © 2005-2008 Roger Leigh <email@example.com>
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later