From ee17e45964b786b48b455959dfe68715971893fb Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 16:14:39 +0200 Subject: Adding upstream version 1.4.3. Signed-off-by: Daniel Baumann --- .../setup00.sh | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 hooks/copy-host-apt-sources-and-preferences/setup00.sh (limited to 'hooks/copy-host-apt-sources-and-preferences/setup00.sh') diff --git a/hooks/copy-host-apt-sources-and-preferences/setup00.sh b/hooks/copy-host-apt-sources-and-preferences/setup00.sh new file mode 100755 index 0000000..07caa78 --- /dev/null +++ b/hooks/copy-host-apt-sources-and-preferences/setup00.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +set -eu + +if [ "${MMDEBSTRAP_VERBOSITY:-1}" -ge 3 ]; then + set -x +fi + +if [ -n "${MMDEBSTRAP_SUITE:-}" ]; then + if [ "${MMDEBSTRAP_VERBOSITY:-1}" -ge 1 ]; then + echo "W: using a non-empty suite name $MMDEBSTRAP_SUITE does not make sense with this hook and might select the wrong Essential:yes package set" >&2 + fi +fi + +rootdir="$1" + +SOURCELIST="/etc/apt/sources.list" +eval "$(apt-config shell SOURCELIST Dir::Etc::SourceList/f)" +SOURCEPARTS="/etc/apt/sources.d/" +eval "$(apt-config shell SOURCEPARTS Dir::Etc::SourceParts/d)" +PREFERENCES="/etc/apt/preferences" +eval "$(apt-config shell PREFERENCES Dir::Etc::Preferences/f)" +PREFERENCESPARTS="/etc/apt/preferences.d/" +eval "$(apt-config shell PREFERENCESPARTS Dir::Etc::PreferencesParts/d)" + +for f in "$SOURCELIST" \ + "$SOURCEPARTS"/*.list \ + "$SOURCEPARTS"/*.sources \ + "$PREFERENCES" \ + "$PREFERENCESPARTS"/*; do + [ -e "$f" ] || continue + mkdir --parents "$(dirname "$rootdir/$f")" + if [ -e "$rootdir/$f" ]; then + if [ "${MMDEBSTRAP_VERBOSITY:-1}" -ge 2 ]; then + echo "I: $f already exists in chroot, appending..." >&2 + fi + # Add extra newline between old content and new content. + # This is required in case of deb822 files. + echo >> "$rootdir/$f" + fi + cat "$f" >> "$rootdir/$f" + if [ "${MMDEBSTRAP_VERBOSITY:-1}" -ge 3 ]; then + echo "D: contents of $f inside the chroot:" >&2 + cat "$rootdir/$f" >&2 + fi +done -- cgit v1.2.3