Differences between revisions 14 and 15
Revision 14 as of 2012-09-18 19:28:32
Size: 3341
Editor: JavierPerez
Comment: use consistent of variable names about article related (SetupBuildServiceForWanna-build) s/arch/architecture/i && s/dist/distribution/i && s/unstable/sid/i
Revision 15 as of 2012-09-21 18:01:36
Size: 3005
Comment: Bug is fiexed, cleaning up the wiki.
Deletions are marked like this. Additions are marked like this.
Line 29: Line 29:
sbuild-createchroot --keyring=/etc/apt/trusted.gpg --arch=$architecture $distribution /srv/chroot/$distribution-$architecture-sbuild $mirror
}}}

IMPORTANT: until the bug [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=673676|673676]] will be solved, use this command (instead of the previous one):

{{{
sbuild-createchroot --keyring="" --arch=$architecture $distribution /srv/chroot/$distribution-$architecture-sbuild $mirror
}}}
{{{
sbuild-createchroot --arch=$architecture $distribution /srv/chroot/$distribution-$architecture-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

apt-get install sbuild

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

sbuild-adduser $user
sbuild-update --keygen

# 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 --arch=$architecture $distribution /srv/chroot/$distribution-$architecture-sbuild $mirror

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

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

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/$distribution-$architecture-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/$distribution-$architecture-sbuild*
cat >>/etc/schroot/chroot.d/$distribution-$architecture-sbuild* <<EOT
btrfs-source-subvolume=/srv/chroot/$distribution-$architecture-sbuild
btrfs-snapshot-directory=/srv/chroot/snapshots
EOT

Usage

To build a package just run

sbuild -A -d sid

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

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

sbuild-update -ugd sid

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