[[chroot]]
=== chroot

The https://en.wikipedia.org/wiki/Chroot[chroot] for a clean package build environment can be created and managed using the tools described in <<setup>>.
footnote:[The *sbuild* style chroot organization is deployed here.  See https://wiki.debian.org/sbuild .  Be careful since many HOWTOs use different chroot setups.]

Here is a quick summary of available package build commands.  There are many ways to do the same thing.

* *dpkg-buildpackage* = core of package building tool
* *debuild* = *dpkg-buildpackage* + *lintian* (build under the sanitized environment variables)
* *schroot* = core of the Debian chroot environment tool
* *sbuild* = *schroot* + *dpkg-buildpackage* (build in the chroot)
* *gbp* = manage the Debian source under git
* *gbp buildpackge* = *sbuild* + *dpkg-buildpackage* + *gbp* (if configured with *sbuild*)

A clean *unstable* distribution chroot environment can be used as follows.

* The chroot filesystem creation command for the *unstable* distribution
** *sudo sbuild-createchroot --include=auto-apt-proxy  unstable /srv/chroot/unstable-amd64-sbuild http://deb.debian.org/debian*
* The master chroot filesystem path for the *unstable* distribution chroot filesystem
** path: */srv/chroot/unstable-amd64-sbuild*
* The package build command for the *unstable* distribution chroot
** *sbuild*
** *gbp buildpackage*
* The command to update the *unstable* chroot
** *sudo sbuild-update -udcar u*
* The command to login to the *unstable* chroot filesystem to modify it
** *sudo sbuild-shell u*

Here, single "u" is predefined short alias for "unstable".

An arbitrary 'dist' distribution environment can be used as follows.

* The chroot filesystem creation command for the 'dist' distribution
** *sudo sbuild-createchroot --include=auto-apt-proxy* 'dist' */srv/chroot/*'dist'*-amd64-sbuild http://deb.debian.org/debian*
* The master chroot filesystem path for the 'dist' distribution chroot
** path: */srv/chroot/*'dist'*-amd64-sbuild*
* The package build command for the 'dist' distribution chroot
** *sbuild -d* 'dist'
** *gbp buildpackage --git-dist=*'dist'
* The command to update the 'dist' chroot
** *sudo sbuild-update -udcar* 'dist'
* The command to login to the master chroot (*source:*'dist') of the 'dist' distribution environment to modify it persistently
** *sudo sbuild-shell* 'dist'

TIP: For building new experimental packages or for debugging buggy packages without using slow network access, this ``*sudo sbuild-shell* 'dist''' command can be used to pre-loaded some packages.  Make sure to retain the backup of the original minimal chroot since changes are persistent and interfere with the normal test package building with the minimal chroot.

TIP: If your old chroot filesystem is missing packages such as *libeatmydata1*, *ccache*, and *lintian*, you may want to install these with the ``*sudo sbuild-shell* 'dist''' command.

TIP: When the *orig.tar.gz* file needs to be uploaded for a Debian revision other than *0* or *1* (e.g., for a security upload), add the *-sa* option to the end of *dpkg-buildpackage*, *debuild*, and *sbuild* commands.  For the ``*gbp buildpackage*'' command,  temporarily modify the *builder* setting of *~/.gbp.conf*.

NOTE: The description in this section is too terse to be useful for most of the prospective maintainers.  This is the intentional choice of the author.   You are highly encouraged to search and read all the pertinent documents associated with the commands used.




