Hi, thanks for your help. Attached three patches to add/enhance hooks to make xenial and trusty building:
mmdebstrap xenial /dev/null http://archive.ubuntu.com/ubuntu --hook-dir=./hooks/xenial/ --hook-dir=./hooks/skip-makedev/ mmdebstrap trusty /dev/null http://archive.ubuntu.com/ubuntu --hook-dir=./hooks/jessie-or-older/ --hook-dir=./hooks/skip-makedev/ What is your opinion to auto-add those hooks when detecting suites that need it? mmdebstrap could gain a parameter to disable that behaviour. -- Benjamin Drung Debian & Ubuntu Developer
From 038e47a1d58c72d11fdc6ae36ea648db81a1cdb1 Mon Sep 17 00:00:00 2001 From: Benjamin Drung <[email protected]> Date: Tue, 24 Nov 2026 16:30:46 +0100 Subject: [PATCH 1/3] hooks/jessie-or-older: also install mawk (for Ubuntu) Ubuntu 14.04 LTS "trusty" needs the jessie-or-older hook. In contrast to Debian jessie, Ubuntu's base-files pre-depends on awk (and mawk provides awk). Otherwise it will fail: ``` $ mmdebstrap trusty /dev/null http://archive.ubuntu.com/ubuntu --hook-dir=/usr/share/mmdebstrap/hooks/jessie-or-older/ [...] Setting up dpkg (1.17.5ubuntu5.8) ... /var/lib/dpkg/info/dpkg.postinst: 79: /var/lib/dpkg/info/dpkg.postinst: awk: not found ``` Bug-Debian: https://bugs.debian.org/1154510 Bug-Ubuntu: https://launchpad.net/bugs/2158250 --- hooks/jessie-or-older/extract01.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hooks/jessie-or-older/extract01.sh b/hooks/jessie-or-older/extract01.sh index 43f1540..9be8ba3 100755 --- a/hooks/jessie-or-older/extract01.sh +++ b/hooks/jessie-or-older/extract01.sh @@ -25,6 +25,7 @@ fi fname_base_passwd= fname_base_files= fname_dpkg= +fname_mawk= for pkg in $MMDEBSTRAP_ESSENTIAL; do pkgname=$(dpkg-deb --show --showformat='${Package}' "$TARGET/$pkg") # shellcheck disable=SC2034 @@ -32,10 +33,11 @@ for pkg in $MMDEBSTRAP_ESSENTIAL; do base-passwd) fname_base_passwd=$pkg;; base-files) fname_base_files=$pkg;; dpkg) fname_dpkg=$pkg;; + mawk) fname_mawk=$pkg;; esac done -for var in base_passwd base_files dpkg; do +for var in mawk base_passwd base_files dpkg; do eval 'val=$fname_'"$var" [ -z "$val" ] && continue chroot "$TARGET" dpkg --install --force-depends "$val" -- 2.53.0
From b4164b188dcdd259f3fc562c4581bd8ff6e36ee1 Mon Sep 17 00:00:00 2001 From: Benjamin Drung <[email protected]> Date: Thu, 26 Nov 2026 17:53:28 +0100 Subject: [PATCH 2/3] hooks: add xenial hook On Ubuntu 16.04 "xenial" mmdebstrap fails: ``` $ mmdebstrap xenial /dev/null http://archive.ubuntu.com/ubuntu [...] Setting up systemd (229-4ubuntu21.31) ... Created symlink /etc/systemd/system/getty.target.wants/[email protected], pointing to /lib/systemd/system/[email protected]. Created symlink /etc/systemd/system/multi-user.target.wants/remote-fs.target, pointing to /lib/systemd/system/remote-fs.target. Created symlink /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service, pointing to /lib/systemd/system/systemd-timesyncd.service. Initializing machine ID from random generator. Adding group `systemd-journal' (GID 101) ... Done. chfn: PAM: Critical error - immediate abort adduser: `/usr/bin/chfn -f systemd Time Synchronization systemd-timesync' returned error code 1. Exiting. dpkg: error processing package systemd (--install): ``` There is this dependency chain (but not pre-depends): systemd -> adduser -> passwd -> libpam-modules Add a xenial hook to install libpam-runtime before everything else. Bug-Debian: https://bugs.debian.org/1154510 Bug-Ubuntu: https://launchpad.net/bugs/2158250 --- hooks/xenial/extract00.sh | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 hooks/xenial/extract00.sh diff --git a/hooks/xenial/extract00.sh b/hooks/xenial/extract00.sh new file mode 100755 index 0000000..bfa9a10 --- /dev/null +++ b/hooks/xenial/extract00.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# +# On Ubuntu 16.04 "xenial" mmdebstrap fails: +# +# Setting up systemd (229-4ubuntu21.31) ... +# Created symlink /etc/systemd/system/getty.target.wants/[email protected], pointing to /lib/systemd/system/[email protected]. +# Created symlink /etc/systemd/system/multi-user.target.wants/remote-fs.target, pointing to /lib/systemd/system/remote-fs.target. +# Created symlink /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service, pointing to /lib/systemd/system/systemd-timesyncd.service. +# Initializing machine ID from random generator. +# Adding group `systemd-journal' (GID 101) ... +# Done. +# chfn: PAM: Critical error - immediate abort +# adduser: `/usr/bin/chfn -f systemd Time Synchronization systemd-timesync' returned error code 1. Exiting. +# dpkg: error processing package systemd (--install): +# +# There is this dependency chain (but not pre-depends): +# systemd -> adduser -> passwd -> libpam-modules + +set -eu + +if [ "${MMDEBSTRAP_VERBOSITY:-1}" -ge 3 ]; then + set -x +fi + +TARGET="$1" + +if [ -z "${MMDEBSTRAP_ESSENTIAL+x}" ]; then + MMDEBSTRAP_ESSENTIAL= + for f in "$TARGET/var/cache/apt/archives/"*.deb; do + [ -f "$f" ] || continue + f="${f#"$TARGET"}" + MMDEBSTRAP_ESSENTIAL="$MMDEBSTRAP_ESSENTIAL $f" + done +fi + +fname_libpam_runtime= +for pkg in $MMDEBSTRAP_ESSENTIAL; do + # shellcheck disable=SC2016 + pkgname=$(dpkg-deb --show --showformat='${Package}' "$TARGET/$pkg") + case $pkgname in + libpam-runtime) fname_libpam_runtime=$pkg;; + esac +done + +if [ -n "$fname_libpam_runtime" ]; then + chroot "$TARGET" dpkg --install --force-depends "$fname_libpam_runtime" +fi -- 2.53.0
From 6ae4967ca33a53c857767dce01694e5e430cf4b7 Mon Sep 17 00:00:00 2001 From: Benjamin Drung <[email protected]> Date: Fri, 27 Nov 2026 00:08:25 +0100 Subject: [PATCH 3/3] hooks: add hook to skip makedev postinst mmdebstrap will fail for Ubuntu releases that install makedev (for example Ubuntu 14.04 "trusty" or Ubuntu 16.04 "xenial"): ``` $ mmdebstrap xenial /dev/null http://archive.ubuntu.com/ubuntu [...] I: installing remaining packages inside the chroot... [...] Setting up makedev (2.3.1-93ubuntu2~ubuntu16.04.1) ... grep: /proc/1/environ: Permission denied mknod: mem-: Operation not permitted makedev mem c 1 1 root kmem 0640: failed mknod: kmem-: Operation not permitted [...] ``` Add a skip-makedev hook to make the makedev postinst script a no-op. Bug-Debian: https://bugs.debian.org/1154510 Bug-Ubuntu: https://launchpad.net/bugs/2158250 --- hooks/skip-makedev/customize00.sh | 6 ++++++ hooks/skip-makedev/essential00.sh | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 hooks/skip-makedev/customize00.sh create mode 100755 hooks/skip-makedev/essential00.sh diff --git a/hooks/skip-makedev/customize00.sh b/hooks/skip-makedev/customize00.sh new file mode 100755 index 0000000..7cb781a --- /dev/null +++ b/hooks/skip-makedev/customize00.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -eu + +# revert changes done in customize00.sh +rm -f "$1/sbin/MAKEDEV" +chroot "$1" dpkg-divert --local --rename --remove /sbin/MAKEDEV diff --git a/hooks/skip-makedev/essential00.sh b/hooks/skip-makedev/essential00.sh new file mode 100755 index 0000000..dfc776f --- /dev/null +++ b/hooks/skip-makedev/essential00.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# +# On Ubuntu 16.04 "xenial" and older mmdebstrap might fails: +# +# $ mmdebstrap xenial /dev/null http://archive.ubuntu.com/ubuntu +# [...] +# I: installing remaining packages inside the chroot... +# [...] +# Setting up makedev (2.3.1-93ubuntu2~ubuntu16.04.1) ... +# grep: /proc/1/environ: Permission denied +# mknod: mem-: Operation not permitted +# makedev mem c 1 1 root kmem 0640: failed +# mknod: kmem-: Operation not permitted +# [...] + +set -eu + +chroot "$1" dpkg-divert --local --rename --add /sbin/MAKEDEV +printf "#!/bin/sh\nexit 0\n" > "$1/sbin/MAKEDEV" +chmod 755 "$1/sbin/MAKEDEV" + +for i in 0 1 2 3 4 5 6 7 8 9; do + touch "$1/dev/tty$i" +done -- 2.53.0

