No description
Find a file
Johannes Schauer Marin Rodrigues 9cea818727
set DPkg::Chroot-Directory in APT_CONFIG
This is so that users calling apt-get install from a hook only need to
have APT_CONFIG=$MMDEBSTRAP_APT_CONFIG set and do not also have to pass
-oDPkg::Chroot-Directory="$1".

This breaks users running apt-get with
DPkg::Options::=--force-script-chrootless or with Dpkg::Pre-Install-Pkgs
from within a hook with APT_CONFIG=$MMDEBSTRAP_APT_CONFIG.

In those situations, DPkg::Chroot-Directory has to be set to the empty
string explicitly with -o to overwrite the APT_CONFIG setting.

Thanks: Helmut Grohne
2023-03-22 09:37:07 +01:00
examples/twb finalize mmdebstrap-autopkgtest-build-qemu 2022-03-06 10:16:11 +01:00
hooks set DPkg::Chroot-Directory in APT_CONFIG 2023-03-22 09:37:07 +01:00
tests set DPkg::Chroot-Directory in APT_CONFIG 2023-03-22 09:37:07 +01:00
.gitignore Instead of requiring root, use qemu 2018-11-21 00:21:43 +01:00
.mailmap .mailmap: add botched email due to https://salsa.debian.org/debian/devscripts/-/merge_requests/323 2023-02-01 18:39:26 +01:00
.perltidyrc format code with perltidy 2020-01-08 17:46:41 +01:00
caching_proxy.py caching_proxy.py: only take .deb and by-hash artifacts from the old path 2023-03-05 15:25:42 +01:00
CHANGELOG.md release 1.3.5 2023-03-20 06:26:51 +01:00
coverage.py Use an caching apt proxy instead of copying /var/cache/apt/archives/*.deb 2023-03-03 08:34:39 +01:00
coverage.sh coverage.sh: pass any cli args on to coverage.py 2023-03-13 13:20:05 +01:00
coverage.txt tests/include-deb-file: run in all modes 2023-03-19 09:03:19 +01:00
gpgvnoexpkeysig add my name to several scripts 2021-09-16 16:24:16 +02:00
ldconfig.fakechroot ldconfig.fakechroot: do not ignore it, if ldconfig was already called with -r 2023-01-23 07:20:13 +01:00
make_mirror.sh make_mirror.sh: clean up more things left over by USE_HOST_APT_CONFIG=yes 2023-03-13 13:22:22 +01:00
mmdebstrap set DPkg::Chroot-Directory in APT_CONFIG 2023-03-22 09:37:07 +01:00
mmdebstrap-autopkgtest-build-qemu mmdebstrap-autopkgtest-build-qemu: fix i386 grub target i386-efi -> i386-pc 2022-11-14 14:35:12 +01:00
proxysolver add my name to several scripts 2021-09-16 16:24:16 +02:00
README.md README.md: update list of contributors 2023-03-17 08:03:19 +01:00
run_null.sh run_null.sh: use file descriptors instead of temporary files to get the exit status of the first part of a pipeline 2023-01-16 23:16:11 +01:00
run_qemu.sh run_qemu.sh: output log while test is running with tail -f 2023-01-16 12:06:20 +01:00
tarfilter tarfilter, coverage.py: changes for black 23.1.0 2023-02-12 14:05:09 +01:00

mmdebstrap

An alternative to debootstrap which uses apt internally and is thus able to use more than one mirror and resolve more complex dependencies.

Usage

Use like debootstrap:

sudo mmdebstrap unstable ./unstable-chroot

Without superuser privileges:

mmdebstrap unstable unstable-chroot.tar

With complex apt options:

cat /etc/apt/sources.list | mmdebstrap > unstable-chroot.tar

For the full documentation use:

pod2man ./mmdebstrap | man -l -

The sales pitch in comparison to debootstrap

Summary:

  • more than one mirror possible
  • security and updates mirror included for Debian stable chroots
  • twice as fast
  • chroot with apt in 11 seconds
  • gzipped tarball with apt is 27M small
  • bit-by-bit reproducible output
  • unprivileged operation using Linux user namespaces or fakechroot
  • can operate on filesystems mounted with nodev
  • foreign architecture chroots with qemu-user
  • variant installing only Essential:yes packages and dependencies
  • temporary chroots by redirecting to /dev/null
  • chroots without apt inside (for chroot from buildinfo file with debootsnap)

The author believes that a chroot of a Debian stable release should include the latest packages including security fixes by default. This has been a wontfix with debootstrap since 2009 (See #543819 and #762222). Since mmdebstrap uses apt internally, support for multiple mirrors comes for free and stable or oldstable chroots will include security and updates mirrors.

A side-effect of using apt is being twice as fast as debootstrap. The timings were carried out on a laptop with an Intel Core i5-5200U, using a mirror on localhost and a tmpfs.

variant mmdebstrap debootstrap
essential 9.52 s n.a
apt 10.98 s n.a
minbase 13.54 s 26.37 s
buildd 21.31 s 34.85 s
- 23.01 s 48.83 s

Apt considers itself an Essential: yes package. This feature allows one to create a chroot containing just the Essential: yes packages and apt (and their hard dependencies) in just 11 seconds.

If desired, a most minimal chroot with just the Essential: yes packages and their hard dependencies can be created with a gzipped tarball size of just 34M. By using dpkg's --path-exclude option to exclude documentation, even smaller gzipped tarballs of 21M in size are possible. If apt is included, the result is a gzipped tarball of only 27M.

These small sizes are also achieved because apt caches and other cruft is stripped from the chroot. This also makes the result bit-by-bit reproducible if the $SOURCE_DATE_EPOCH environment variable is set.

The author believes, that it should not be necessary to have superuser privileges to create a file (the chroot tarball) in one's home directory. Thus, mmdebstrap provides multiple options to create a chroot tarball with the right permissions without superuser privileges. This avoids a whole class of bugs like #921815. Depending on what is available, it uses either Linux user namespaces or fakechroot. Debootstrap supports fakechroot but will not create a tarball with the right permissions by itself. Support for Linux user namespaces is missing (see #829134).

When creating a chroot tarball with debootstrap, the temporary chroot directory cannot be on a filesystem that has been mounted with nodev. In unprivileged mode, mknod is never used, which means that /tmp can be used as a temporary directory location even if if it's mounted with nodev as a security measure.

If the chroot architecture cannot be executed by the current machine, qemu-user is used to allow one to create a foreign architecture chroot.

Limitations in comparison to debootstrap

Debootstrap supports creating a Debian chroot on non-Debian systems but mmdebstrap requires apt and is thus limited to Debian and derivatives. This means that mmdebstrap can never fully replace debootstrap and debootstrap will continue to be relevant in situations where you want to create a Debian chroot from a platform without apt and dpkg.

There is no SCRIPT argument.

The following options, don't exist: --second-stage, --exclude, --resolve-deps, --force-check-gpg, --merged-usr and --no-merged-usr.

The quirks from debootstrap are needed to create chroots of Debian unstable from snapshot.d.o before timestamp 20141107T220431Z or Debian 8 (Jessie) or later.

Tests

The script coverage.sh runs mmdebstrap in all kind of scenarios to execute all code paths of the script. It verifies its output in each scenario and displays the results gathered with Devel::Cover. It also compares the output of mmdebstrap with debootstrap in several scenarios. To run the testsuite, run:

./make_mirror.sh
CMD=./mmdebstrap ./coverage.sh

To also generate perl Devel::Cover data, omit the CMD environment variable. But that will also take a lot longer.

The make_mirror.sh script will be a no-op if nothing changed in Debian unstable. You don't need to run make_mirror.sh before every invocation of coverage.sh. When you make changes to make_mirror.sh and want to regenerate the cache, run:

touch -d yesterday shared/cache/debian/dists/unstable/Release

The script coverage.sh does not need an active internet connection by default. An online connection is only needed by the make_mirror.sh script which fills a local cache with a few minimal Debian mirror copies.

By default, coverage.sh will skip running a single test which tries creating a Ubuntu Focal chroot. To not skip that test, run coverage.sh with the environment variable ONLINE=yes.

If a test fails you can run individual tests by executing coverage.py with the test name and optionally limit it to a specific distribution like so:

CMD=./mmdebstrap ./coverage.py --dist unstable check-against-debootstrap-dist

Bugs

mmdebstrap has bugs. Report them here: https://gitlab.mister-muffin.de/josch/mmdebstrap/issues

Contributors

  • Johannes Schauer Marin Rodrigues (main author)
  • Helmut Grohne
  • Gioele Barabucci
  • Benjamin Drung
  • Jochen Sprickerhof
  • Josh Triplett
  • Konstantin Demin
  • David Kalnischkies
  • Jakub Wilk
  • Joe Groocock
  • Nicolas Vigier
  • Raul Tambre
  • Steve Dodd
  • Trent W. Buck
  • Vagrant Cascadian