Differences between revisions 4 and 5
Revision 4 as of 2011-06-13 20:35:07
Size: 2810
Editor: ?ansgar
Comment:
Revision 5 as of 2011-06-16 19:02:23
Size: 2823
Editor: ?ansgar
Comment: sbuild-createchroot: use --arch=$arch
Deletions are marked like this. Additions are marked like this.
Line 27: Line 27:
sbuild-createchroot --keyring=/etc/apt/trusted.gpg $dist /srv/chroot/$dist-$arch-sbuild $mirror sbuild-createchroot --keyring=/etc/apt/trusted.gpg --arch=$arch $dist /srv/chroot/$dist-$arch-sbuild $mirror

sbuild

sbuild is used on the official buildd network to build binary packages for all supported architectures. It can also be used by individuals to prepare packages. Alternatives to sbuild are cowbuilder and pbuilder.

This page is intended as a short guide to sbuild. It documents how to set up sbuild and build packages with it, but intentionally does not document all possible options to keep it short and simple.

Setup

As root run

user=user
dist=unstable
# default to host architecture. you can also use i386 on amd64 or vice versa
arch=$(dpkg --print-architecture)
mirror=http://cdn.debian.net/debian

apt-get install sbuild
sbuild-adduser $user

# optional, but recommended if not using a local mirror:
echo /var/cache/apt/archives /var/cache/apt/archives none rw,bind 0 0 >>/etc/schroot/sbuild/fstab

mkdir -p /srv/chroot
sbuild-createchroot --keyring=/etc/apt/trusted.gpg --arch=$arch $dist /srv/chroot/$dist-$arch-sbuild $mirror

# optional, but recommended:
cd /; schroot -c $dist-$arch-sbuild apt-get install eatmydata
# or, when using btrfs-snapshots (see below):
# cd /; schroot -c source:$dist-$arch-sbuild apt-get install eatmydata
echo command-prefix=eatmydata >>/etc/schroot/chroot.d/$dist-$arch-sbuild*

You can create additional chroots for different suites and architectures by starting from sbuild-createchroot with appropriate values for dist and arch.

Setup, with using btrfs snapshots

Using snapshots for the chroot environment allows to skip removing installed build dependencies and cleaning the build directory. One filesystem supporting this is btrfs, but it is also possible to use LVM snapshots or aufs/unionfs (see schroot.conf(5) for these).

To use btrfs snapshots with the above setup, make sure /srv/chroot is located on a btrfs filesystem and run

btrfs subvolume create /srv/chroot/$dist-$arch-sbuild

before sbuild-createchroot. After sbuild-createchroot run

mkdir -p /srv/chroot/snapshots
sed -i "s,type=directory,type=btrfs-snapshot,; /directory=/ d" /etc/schroot/chroot.d/$dist-$arch-sbuild*
cat >>/etc/schroot/chroot.d/$dist-$arch-sbuild* <<EOT
btrfs-source-subvolume=/srv/chroot/$dist-$arch-sbuild
btrfs-snapshot-directory=/srv/chroot/snapshots
EOT

Usage

To build a package just run

sbuild -A -d unstable

in the source directory. You can also specify a different architecture with --arch=$arch or pass a .dsc file.

The chroot environment should be updated from time to time. Just run

sbuild-update -ugd unstable

Again, use --arch=$arch for a chroot environment for a architecture that differs from the host architecture.