summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2023-01-12 08:05:32 +0100
committerHelmut Grohne <helmut@subdivi.de>2023-01-12 08:05:32 +0100
commit3fde9f313c991aa19fbcedc38a4531de9e838f8d (patch)
treee00ccdfda5e09a2fcfe7bc1ed3ed968337544f59
parentc751e229a1f8118787954d26bab4c300d114300e (diff)
downloaddebvm-3fde9f313c991aa19fbcedc38a4531de9e838f8d.tar.gz
debvm-create: also move dpkg's available database to a hook file
-rwxr-xr-xbin/debvm-create4
-rwxr-xr-xshare/customize-dpkgavailable.sh12
2 files changed, 13 insertions, 3 deletions
diff --git a/bin/debvm-create b/bin/debvm-create
index 9d637b1..981b450 100755
--- a/bin/debvm-create
+++ b/bin/debvm-create
@@ -291,9 +291,7 @@ if test -n "$SSHKEY"; then
fi
set -- --skip=cleanup/apt/lists "$@"
-
-# We need /var/lib/dpkg/available for dpkg --set-selections to work.
-set -- '--customize-hook=chroot "$1" apt-cache dumpavail | chroot "$1" dpkg --update-avail' "$@"
+set -- "--customize-hook=$SHARE_DIR/customize-dpkgavailable.sh" "$@"
if test "$DEBVER" -le 8; then
# Use obsolete and expired keys.
diff --git a/share/customize-dpkgavailable.sh b/share/customize-dpkgavailable.sh
new file mode 100755
index 0000000..f35b81f
--- /dev/null
+++ b/share/customize-dpkgavailable.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright 2022 Helmut Grohne <helmut@subdivi.de>
+# SPDX-License-Identifier: MIT
+#
+# This is a mmdebstrap customize hook that initializes dpkg's available
+# database from an updated apt package list cache.
+#
+# Without the available database, dpkg --set-selections won't work.
+
+set -eu
+
+APT_CONFIG=$MMDEBSTRAP_APT_CONFIG apt-cache dumpavail | dpkg --root "$1" --update-avail