- Package:
- mmdebstrap
- Source:
- mmdebstrap
- Submitter:
- Trent W. Buck
- Date:
- 2026-10-12 21:19:02 UTC
- Severity:
- normal
When debugging an mmdebstrap build, I occasionally want an interactive aptitude GUI.
Using $MMDEBSTRAP_APT_CONFIG, I can do this without bothering to install aptitude inside the built environment.
This works with minor issues:
mmdebstrap forky /dev/null --customize-hook='APT_CONFIG=$MMDEBSTRAP_APT_CONFIG aptitude'
This works with no issues:
mmdebstrap forky /dev/null --customize-hook='APT_CONFIG=$MMDEBSTRAP_APT_CONFIG HOME=$1/root aptitude -oDir::Aptitude::State=var/lib/aptitude' --essential-hook='mkdir -p $1/var/lib/aptitude'
or
mmdebstrap forky /dev/null --customize-hook='APT_CONFIG=$MMDEBSTRAP_APT_CONFIG HOME=$1/root aptitude -oDir::Aptitude::State=var/lib/aptitude' --include=aptitude
Should mmdebstrap set Dir::Aptitude::State "var/lib/aptitude" in MMDEBSTRAP_APT_CONFIG?
mmdebstrap already sets Dir in MMDEBSTRAP_APT_CONFIG.
Should aptitude default Dir::Aptitude::State be relative to Dir (not absolute) by default?
i.e. remove leading / from the path here:
https://sources.debian.org/src/aptitude/0.8.13-8.1/configure.ac?hl=636#L636
You can see an example with relative paths here:
https://sources.debian.org/src/apt/3.3.0/test/libapt/configuration_test.cc?hl=95#L90-L95
Hi, Quoting Trent W. Buck (2026-05-05 04:00:02) did you consider running aptitude inside a --chrooted-customize-hook? THen you don't need neither APT_CONFIG nor Dir::Aptitude::State. The way you are running mmdebstrap above means that you install aptitude inside the chroot but then you are running aptitude from *outside* the chroot. If you have aptitude inside the chroot anyways, why not run that one? It would also be a bit shorter: mmdebstrap forky /dev/null --chrooted-customize-hook=aptitude Thanks! cheers, josch
Hi, Quoting Trent W. Buck (2026-10-12 00:14:59) you know that chdist exists? And chdist even has support for "chdist aptitude". Thanks! cheers, josch
In the other examples, I'm not installing aptitude in the chroot.
My goal is to browse around a different release than my host system,
as quickly as possible (i.e. installing as little as possible).
[Update: I was doing --variant=apt --essential-hook, but while writing
this I realized --variant=extract --extract-hook is even faster.]
This is what I'm currently doing (in my ~/.shrc):
D_aptitude () {
mmdebstrap "$@" /dev/null http://localhost:3142/debian \
--dpkgopt=force-unsafe-io \
--variant=extract \
--components=main,contrib,non-free,non-free-firmware \
'--aptopt=Acquire::Languages "en"' \
--extract-hook='APT_CONFIG=$MMDEBSTRAP_APT_CONFIG HOME=$1/root
aptitude -s -oDir::Aptitude::State=var/lib/aptitude
-oaptitude::UI::Package-Display-Format="%c%a%M%S %p %e %Z %t %v %V";
false';
}
D_aptitude forky
Compared to --include=aptitude --chrooted-customize-hook,
--essential-hook is ~30% faster, and --variant=extract --extract-hook is
~80% faster:
bash5$ time mmdebstrap forky /dev/null http://localhost:3142/debian
--dpkgopt=force-unsafe-io *--variant=extract* '--components=main,cont\
rib,non-free,non-free-firmware' '--aptopt=Acquire::Languages "en"'
*--extract-hook=*'APT_CONFIG=$MMDEBSTRAP_APT_CONFIG HOME=$1/root aptit\
ude -s -oDir::Aptitude::State=var/lib/aptitude
-oaptitude::UI::Package-Display-Format="%c%a%M%S %p %e %Z %t %v %V";
false'
aptitude cannot run in ncurses mode with terminal type "dumb"
real 0m5.536s
user 0m4.557s
sys 0m1.052s
bash5$ time mmdebstrap forky /dev/null http://localhost:3142/debian
--dpkgopt=force-unsafe-io *--variant=apt* '--components=main,contrib,\
non-free,non-free-firmware' '--aptopt=Acquire::Languages "en"'
*--essential-hook=*'APT_CONFIG=$MMDEBSTRAP_APT_CONFIG HOME=$1/root
aptitud\
e -s -oDir::Aptitude::State=var/lib/aptitude
-oaptitude::UI::Package-Display-Format="%c%a%M%S %p %e %Z %t %v %V";
false'
aptitude cannot run in ncurses mode with terminal type "dumb"
real 0m18.913s
user 0m16.201s
sys 0m5.051s
bash5$ time mmdebstrap forky /dev/null http://localhost:3142/debian
--dpkgopt=force-unsafe-io *--variant=apt* '--components=main,contrib,\
non-free,non-free-firmware' '--aptopt=Acquire::Languages "en"'
*--chrooted-customize-hook=*'aptitude -s
-oaptitude::UI::Package-Display-F\
ormat="%c%a%M%S %p %e %Z %t %v %V"; false' *--include=aptitude*
aptitude cannot run in ncurses mode with terminal type "dumb"
real 0m27.016s
user 0m19.160s
sys 0m5.958s
I guess the actual issue here is that Dir::Aptitude::State is not
relative to Dir::State by default.
I can see a case for either way.
When mmdebstrap runs host's aptitude in an unshared hook,
a Dir::Aptitude::State outside the build root (aptitude's default) will
always fail...
hrm, although I guess that is not true for --mode=root.
This has more edge cases than I thought.
I guess if no one else is asking for this, it can go on living in my
~/.shrc instead of in /bin/mmdebstrap.
PS: similar command but for apt-file not aptitude (~40% faster than
--variant=apt --include=apt-file --chrooted-customize-hook, which would
still need the --aptopt to make apt download the Contents.xz files):
mmdebstrap forky /dev/null http://localhost:3142/debian --quiet
--components=main,contrib,non-free,non-free-firmware
--aptopt=/etc/apt/apt.conf.d/50apt-file.conf --variant=custom
--extract-hook='APT_CONFIG=$MMDEBSTRAP_APT_CONFIG apt-file search
bdic | grep -een.AU -een.US -een.GB'
My problem with it is the same problem I had with sbuild/cowdancer: it wants me to create state directories in advance, and then maintain them. So inevitably that ends up consuming 200-300MB of nvram permanently (per release, per arch), and I then forget where I left the state directories, or I get stale answers because I haven't run "apt update" there recently enough, and nothing warns me "hey watch out, last apt update of this chdist was 22 months ago". (I just re-checked and as at chdist=2.26.11~bpo13+1, "chdist forky aptitude -u" wrongly demands root privileges, so it'd have to be "chdist forky apt update && chdist forky aptitude". I think hitting that last time was when I said "I give up, chdist is not for me".) When building OS images, when building debs, and when just looking at aptitude, it is a much better fit for me to say "mmdebstrap, create exactly what I need, ab initio, no stale/old baggage". Usually on a single line of bash history. (And yes I often have an apt-cacher-ng somewhere on the network, but it auto-expires stuff, at its own cadence, and mmdebstrap still works if I omit it.) I could create a wrapper script around chdist to do this, but it'd be uglier and involve more steps than using mmdebstrap.