From c6c2baee6a3b52b5319bd7b4adb3c149b10d45e9 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Mon, 19 Sep 2022 20:41:45 +0200 Subject: [PATCH] hooks/merged-usr/essential00.sh: avoid chroot in chrootless mode --- hooks/merged-usr/essential00.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/hooks/merged-usr/essential00.sh b/hooks/merged-usr/essential00.sh index 6673a85..ec3c2d0 100755 --- a/hooks/merged-usr/essential00.sh +++ b/hooks/merged-usr/essential00.sh @@ -8,8 +8,20 @@ fi TARGET="$1" -APT_CONFIG=$MMDEBSTRAP_APT_CONFIG apt-get --yes install -oDPkg::Chroot-Directory="$TARGET" usr-is-merged - -chroot "$TARGET" dpkg-query --showformat '${db:Status-Status}\n' --show usr-is-merged | grep -q '^installed$' -chroot "$TARGET" dpkg-query --showformat '${Source}\n' --show usr-is-merged | grep -q '^usrmerge$' -dpkg --compare-versions "1" "lt" "$(chroot "$TARGET" dpkg-query --showformat '${Version}\n' --show usr-is-merged)" +if [ "${MMDEBSTRAP_MODE:-}" = "chrootless" ]; then + APT_CONFIG=$MMDEBSTRAP_APT_CONFIG apt-get --yes install \ + -oDPkg::Options::=--force-not-root \ + -oDPkg::Options::=--force-script-chrootless \ + -oDPkg::Options::=--root="$TARGET" \ + -oDPkg::Options::=--log="$TARGET/var/log/dpkg.log" \ + usr-is-merged + export DPKG_ROOT="$TARGET" + dpkg-query --showformat '${db:Status-Status}\n' --show usr-is-merged | grep -q '^installed$' + dpkg-query --showformat '${Source}\n' --show usr-is-merged | grep -q '^usrmerge$' + dpkg --compare-versions "1" "lt" "$(dpkg-query --showformat '${Version}\n' --show usr-is-merged)" +else + APT_CONFIG=$MMDEBSTRAP_APT_CONFIG apt-get --yes install -oDPkg::Chroot-Directory="$TARGET" usr-is-merged + chroot "$TARGET" dpkg-query --showformat '${db:Status-Status}\n' --show usr-is-merged | grep -q '^installed$' + chroot "$TARGET" dpkg-query --showformat '${Source}\n' --show usr-is-merged | grep -q '^usrmerge$' + dpkg --compare-versions "1" "lt" "$(chroot "$TARGET" dpkg-query --showformat '${Version}\n' --show usr-is-merged)" +fi