logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

sbuild-setup - sbuild setup procedure

Authors

Roger Leigh.

Chroot Setup

This guide sets up a lenny chroot on a powerpc machine. Adjust the names for other suites and architectures. 1.Rundebootstraptocreatethechroot # 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-L4G-nlenny_chroot-Zyvolume-group Add to /etc/fstab and mount (see next section for full fstab example). Finally, run debootstrap to create the chroot: # debootstrap--variant=builddlenny/srv/chroot/lennyhttp://deb.debian.org/debian/2.Setupadditionalmounts 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 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, shadow, group, gshadow and resolv.conf 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 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). 3.Editsources.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.Configuredchrootorschroot This is entirely optional, but will make the chroot environment easier to access and administer. 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 For sudo, add a symbolic link to the directory /etc/sbuild/chroot, for example: # mkdir-p/etc/sbuild/chroot # ln-s/srv/chroot/lenny/etc/sbuild/chroot/lenny5.Logintochroot # dchroot-clenny or $ schroot-clenny-uroot6.Setuppackagesforsbuild While running as root inside the chroot: # apt-getupdate # apt-getdist-upgrade # apt-getinstalldebconf # dpkg-reconfigure-plowdebconf Answer the debconf questions as follows: interface choose 6/Noninteractivepriority 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 packages: # apt-getinstallfakerootbuild-essential # apt-getinstallmakedev # cd/dev/ # /sbin/MAKEDEVgeneric # touch/etc/mtab For some security, we don't bind mount /dev, so it can't access e.g. USB devices 7.sbuildsetup While running as root inside the chroot: # mkdir/build # chownroot:sbuild/build # chmod02775/build # mkdir-p/var/lib/sbuild/srcdep-lock # chown-Rroot:sbuild/var/lib/sbuild # chmod-R02775/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.

Description

sbuild 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.

Name

sbuild-setup - sbuild setup procedure

Quick Start

Simply running sbuild-createchroot will perform all the setup steps described in detail below. See the section “sbuild-createchroot” below, as well as sbuild-createchroot(8).

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 /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.

See Also

debootstrap(1), sbuild(1), sbuild-adduser(8), sbuild-createchroot(8). Version 0.88.3ubuntu3 02 May 2025 SBUILD-SETUP(7)

User Setup

1.Groupmembership As root, run: # sbuild-adduseruser Alternatively, add the user to the sbuild group by hand: # adduserusersbuild2.~/.sbuildrc Configure the user's ~/.sbuildrc: $ cp/usr/share/doc/sbuild/examples/example.sbuildrc~user/.sbuildrc Edit to set the correct mail address to send log files to, and the correct maintainer name and/or uploader name. 3.Builddirectories 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~/logs4.sudosetup This step not required if schroot is used (which is the default, set in sbuild.conf). 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: username ALL=NOPASSWD: ALL Defaults:username env_keep+="APT_CONFIG DEBIAN_FRONTEND SHELL" where username is the name of the user who will run sbuild. 5.Finished The user should now be able to run sbuild. $ sbuild...

See Also