This setup was guided by the following page:

http://wiki.debian.org/sbuild?rev=19

(Since then, that Debian wiki page evolved, update my be need on our side…)

Install sbuild + initial setup

apt-get install sbuild
 
user=neyron
 
sbuild-adduser $user
 
# this needs "entropy"... Do weird things and think different, waiting for it to complete...
sbuild-update --keygen
 
# share the deb archives among schroots...
echo /var/cache/apt/archives /var/cache/apt/archives none rw,bind 0 0 >>/etc/schroot/sbuild/fstab
 
# create a fake disk and format it as btrfs (btrfs is still experimental...)
dd if=/dev/zero of=/home/schroot-btrfs bs=1M count=1 seek=$((20 * 1024 -1 ))
losetup /dev/loop0 schroot-btrfs
mkfs.btrfs /dev/loop0
losetup -d /dev/loop0
 
# setup the mount of our btrfs disk in /src/chroot 
mkdir -p /srv/chroot
cat <<EOF >>/etc/fstab
/home/schroot-btrfs	/srv/chroot	btrfs	defaults	0	0
EOF
mount /src/chroot

Create a schroot

# set the Debian distribution: sid, wheezy, squeeze...
distribution=sid
# set the architecture: amd64, i386...
architecture=amd64
# set the debian mirror to use
mirror=http://ftp2.fr.debian.org/debian
 
# create the sub-volume for this schroot
btrfs subvolume create /srv/chroot/$distribution-$architecture-sbuild
 
# create the schroot
sbuild-createchroot --arch=$architecture $distribution /srv/chroot/$distribution-$architecture-sbuild $mirror
 
# modify the schroot config to say it's btrfs !
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
 
# example of result:
cat /etc/schroot/chroot.d/sid-amd64-sbuild-9MUbaK 
[sid-amd64-sbuild]
type=btrfs-snapshot
description=Debian sid/amd64 autobuilder
groups=root,sbuild
root-groups=root,sbuild
profile=sbuild
btrfs-source-subvolume=/srv/chroot/sid-amd64-sbuild
btrfs-snapshot-directory=/srv/chroot/snapshots
source-root-groups=root,sbuild,admin

Create a schroot for crossbuilding for another arch

First install the latest version of qemu_user_static (e.g. from sid).

# set the Debian distribution: buster (sid does not work)
distribution=buster
# set the architecture: amd64, i386...
architecture=arm64 #or ppc64el
# set the debian mirror to use
mirror=http://ftp2.fr.debian.org/debian
# create the sub-volume for this schroot
btrfs subvolume create /srv/chroot/$distribution-$architecture-sbuild
 
sbuild-createchroot --debootstrap=qemu-debootstrap --arch=$architecture $distribution /srv/chroot/$distribution-$architecture-sbuild $mirror

Then see above to finish (switch to btrfs…).

In case of problems, hopefully this page may help:

Using the schroots!

See your schroot:

schroot -c <TAB>
chroot:centos5-amd64                   source:centos5-amd64
chroot:centos6-amd64                   source:centos6-amd64
chroot:sid-amd64-sbuild                source:sid-amd64-sbuild
chroot:sid-i386-sbuild                 source:sid-i386-sbuild
chroot:squeeze-amd64-sbuild            source:squeeze-amd64-sbuild
chroot:squeeze-backports-amd64-sbuild  source:squeeze-backports-amd64-sbuild
chroot:squeeze-backports-i386-sbuild   source:squeeze-backports-i386-sbuild
chroot:squeeze-i386-sbuild             source:squeeze-i386-sbuild
chroot:wheezy-amd64-sbuild             source:wheezy-amd64-sbuild
chroot:wheezy-backports-amd64-sbuild   source:wheezy-backports-amd64-sbuild
chroot:wheezy-backports-i386-sbuild    source:wheezy-backports-i386-sbuild
chroot:wheezy-i386-sbuild              source:wheezy-i386-sbuild
  • chroot:* are stateless chroot, everything is lost once a session is ended
  • source:* are the bases for the chroot, modification (upgrades, etc) are persistant

see schroot manual

Using sbuild

sbuild is to build Debian packages. See debian packaging.

Examples:

# build a package in a schroot
sbuild -As -d sid --arch amd64 oar_2.5.3-1.dsc
 
# upgrade a schroot
sbuild-update -ugd sid

More info: see sbuild manual

wiki/sbuild-debian.txt · Last modified: 2020/09/28 13:30 by neyron
Recent changes RSS feed GNU Free Documentation License 1.3 Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki