From 3ba97580ec752e2f1f9fc136ac60f12d194a2050 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Mon, 16 Jan 2023 07:18:13 +0100 Subject: [PATCH] hooks/jessie-or-older: split into two individual hook files --- hooks/jessie-or-older/extract00.sh | 34 +-------------------- hooks/jessie-or-older/extract01.sh | 47 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 33 deletions(-) create mode 100755 hooks/jessie-or-older/extract01.sh diff --git a/hooks/jessie-or-older/extract00.sh b/hooks/jessie-or-older/extract00.sh index cb43648..f327052 100755 --- a/hooks/jessie-or-older/extract00.sh +++ b/hooks/jessie-or-older/extract00.sh @@ -8,41 +8,9 @@ fi TARGET="$1" +# not needed since dpkg 1.17.11 for f in available diversions cmethopt; do if [ ! -e "$TARGET/var/lib/dpkg/$f" ]; then touch "$TARGET/var/lib/dpkg/$f" fi done - -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_base_passwd= -fname_base_files= -fname_dpkg= -for pkg in $MMDEBSTRAP_ESSENTIAL; do - pkgname=$(dpkg-deb --show --showformat='${Package}' "$TARGET/$pkg") - # shellcheck disable=SC2034 - case $pkgname in - base-passwd) fname_base_passwd=$pkg;; - base-files) fname_base_files=$pkg;; - dpkg) fname_dpkg=$pkg;; - esac -done - -for var in base_passwd base_files dpkg; do - eval 'val=$fname_'"$var" - [ -z "$val" ] && continue - chroot "$TARGET" dpkg --install --force-depends "$val" -done - -# shellcheck disable=SC2086 -chroot "$TARGET" dpkg --unpack --force-depends $MMDEBSTRAP_ESSENTIAL - -chroot "$TARGET" dpkg --configure --pending diff --git a/hooks/jessie-or-older/extract01.sh b/hooks/jessie-or-older/extract01.sh new file mode 100755 index 0000000..43f1540 --- /dev/null +++ b/hooks/jessie-or-older/extract01.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# +# needed until init 1.33 which pre-depends on systemd-sysv +# starting with init 1.34, init is not Essential:yes anymore +# +# jessie has init 1.22 + +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_base_passwd= +fname_base_files= +fname_dpkg= +for pkg in $MMDEBSTRAP_ESSENTIAL; do + pkgname=$(dpkg-deb --show --showformat='${Package}' "$TARGET/$pkg") + # shellcheck disable=SC2034 + case $pkgname in + base-passwd) fname_base_passwd=$pkg;; + base-files) fname_base_files=$pkg;; + dpkg) fname_dpkg=$pkg;; + esac +done + +for var in base_passwd base_files dpkg; do + eval 'val=$fname_'"$var" + [ -z "$val" ] && continue + chroot "$TARGET" dpkg --install --force-depends "$val" +done + +# shellcheck disable=SC2086 +chroot "$TARGET" dpkg --unpack --force-depends $MMDEBSTRAP_ESSENTIAL + +chroot "$TARGET" dpkg --configure --pending