SBUILD-SETUP(7)
π SBUILD-SETUP(7) β the setup glow-up guide β¨
okay bestie, so this is sbuild-setup(7) from the Debian sbuild manual, and it's literally the whole "how do I even set up sbuild" lore. grab a snack, we're going in π
πΈ NAME πΈ
sbuild-setup β the sbuild setup procedure, i.e. the step-by-step of getting your build situation cute and functional.
π¦ DESCRIPTION π¦
so the whole vibe of sbuild is that it builds packages inside chroots, which gives you a minimal and consistent build environment β no chaotic "works on my machine" energy, periodt. This man page walks you through creating a chroot by hand using debootstrap.
Heads up bestie: these are only guidelines π depending on what setup you actually need, several of the steps may be omitted entirely. So don't stress if you skip some.
β‘ QUICK START β‘
The absolute shortcut era: just run sbuild-createchroot and it'll do all the setup steps described in detail below. Peep the βsbuild-createchrootβ section further down, plus sbuild-createchroot(8) while you're at it. iykyk π«Ά
π CHROOT SETUP π
This guide sets up a lenny chroot on a powerpc machine β adjust the names for other suites and architectures, obviously. π
1οΈβ£ Run debootstrap to create the chroot
# mkdir -p /srv/chroot/lenny
The author has each chroot as a separate LVM logical volume (LV) β main character storage energy. Create and mount an LV here if required:
# lvcreate -L 4G -n lenny_chroot -Z y volume-group
Add it to /etc/fstab and mount it (the next section has the full fstab example). Finally, run debootstrap to create the chroot:
# debootstrap --variant=buildd lenny /srv/chroot/lenny
http://deb.debian.org/debian/
2οΈβ£ Set up additional mounts
An example /etc/fstab:
/dev/volume-group/lenny_chroot \
/srv/chroot/lenny ext3 defaults 0 2
/dev/pts /srv/chroot/lenny/dev/pts none rw,bind 0 0
tmpfs /srv/chroot/lenny/dev/shm tmpfs defaults 0 0
proc /srv/chroot/lenny/proc proc defaults 0 0
/dev/volume-group/home \
/srv/chroot/lenny/home ext3 quota 0 0
/tmp /srv/chroot/lenny/tmp none rw,bind 0 0
/etc/passwd /srv/chroot/lenny/etc/passwd none ro,bind 0 0
/etc/shadow /srv/chroot/lenny/etc/shadow none ro,bind 0 0
/etc/group /srv/chroot/lenny/etc/group none ro,bind 0 0
/etc/gshadow /srv/chroot/lenny/etc/gshadow none ro,bind 0 0
/etc/resolv.conf \
/srv/chroot/lenny/etc/resolv.conf \
none ro,bind 0 0
If the bind mountpoints don't exist inside the chroot, touch them into existence:
# touch /srv/chroot/lenny/etc/resolv.conf
Next, mount them all. π§
Depending on your kernel version and your 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 β lowkey iconic honestly.
If you're using sbuild withschroot,passwd,shadow,group,gshadowandresolv.confcan be updated automatically at the start of each build, so no action is required here.schrootcan also automatically mount all of the extra filesystems, so all the other mounts may be omitted. β¨
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). fr fr, that's the tradeoff.
3οΈβ£ Edit sources.list
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 distribution:
deb http://security.debian.org/ lenny/updates main
deb-src http://security.debian.org/ lenny/updates main
deb http://deb.debian.org/debian/ lenny main
deb-src http://deb.debian.org/debian/ lenny main
4οΈβ£ Configure dchroot or schroot
This is entirely optional, but it'll make the chroot environment easier to access and administer. do it for the convenience π
For dchroot, add the following line to /etc/dchroot.conf:
lenny /srv/chroot/lenny
For schroot, add a group to /etc/schroot/schroot.conf (or a new file /etc/schroot/chroot.d/lenny), for example:
[lenny]
type=directory
description=Debian lenny (stable)
location=/srv/chroot/lenny
priority=2
groups=root,sbuild
root-groups=sbuild
aliases=stable
run-setup-scripts=true
run-session-scripts=true
5οΈβ£ Log into chroot
# dchroot -c lenny
or
$ schroot -c lenny -u root
6οΈβ£ Set up packages for sbuild
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:
interfaceβ choose6/Noninteractivepriorityβ choose1/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 packages:
# 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. π«Ά
7οΈβ£ sbuild setup
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.
8οΈβ£ Finished
Congratulations! π You should now have a fully configured and operational chroot. she ate. π
π SBUILD-CREATECHROOT π
This script will automatically perform a number of the steps described above, including:
- Running
debootstrap. - Setting up APT sources in
/etc/apt/sources.list. - Setting up a minimal
/etc/passwd - Setting up
/buildand/var/lib/sbuildwith 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. no cap, it doesn't do everything.
π USER SETUP π
1οΈβ£ Group membership
As root, run:
# sbuild-adduser user
Alternatively, add the user to the sbuild group by hand:
# adduser user sbuild
2οΈβ£ ~/.sbuildrc
Configure the user's ~/.sbuildrc:
$ cp /usr/share/doc/sbuild/examples/example.sbuildrc ~user/.sbuildrc
Edit it to set the correct mail address to send log files to, and the correct maintainer name and/or uploader name. π¬
3οΈβ£ Build directories
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
4οΈβ£ Finished
The user should now be able to run sbuild. slay. β¨
$ sbuild ...
π«Ά AUTHORS π«Ά
Roger Leigh. (yes, just the one legend.)
π COPYRIGHT π
Copyright Β© 2005-2008 Roger Leigh <rleigh@debian.org>
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 version.
π SEE ALSO π
debootstrap(1), sbuild(1), sbuild-adduser(8), sbuild-createchroot(8).
that's the whole guide bestie π go forth and build packages in a cute little chroot, you've got this
this page was brought to you by Version 0.89.3+deb13u4, dated 28 December 2025 β mwah, and good luck out there π¦π
π¦ where this page comes from
- debian trixie: sbuild 0.89.3+deb13u4 Β· GPL-2.0-or-later
- Copyright Β© 2005-2008 Roger Leigh <rleigh@debian.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms