From 6416ce96c9db538702a8c3ebf932f56b3b78bca1 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Tue, 6 Sep 2022 14:22:03 +0200 Subject: [PATCH] hooks/file-mirror-automount/setup00.sh: also parse MMDEBSTRAP_INCLUDE and make it available --- hooks/file-mirror-automount/setup00.sh | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/hooks/file-mirror-automount/setup00.sh b/hooks/file-mirror-automount/setup00.sh index 06fcbad..9ad35d2 100755 --- a/hooks/file-mirror-automount/setup00.sh +++ b/hooks/file-mirror-automount/setup00.sh @@ -8,6 +8,7 @@ fi rootdir="$1" +# process all configured apt repositories env APT_CONFIG=$MMDEBSTRAP_APT_CONFIG apt-get indextargets --no-release-info --format '$(REPO_URI)' \ | sed -ne 's/^file:\/\+//p' \ | sort -u \ @@ -27,3 +28,38 @@ env APT_CONFIG=$MMDEBSTRAP_APT_CONFIG apt-get indextargets --no-release-info --f esac printf '/%s\0' "$path" >> "$rootdir/run/mmdebstrap/file-mirror-automount" done + +# process all files given via --include +set -f # turn off pathname expansion +IFS=',' # split by comma +for pkg in $MMDEBSTRAP_INCLUDE; do + set +f; unset IFS + case $pkg in + ./*|../*|/*) : ;; # we are interested in this case + *) continue ;; # not a file + esac + # undo escaping + pkg="$(printf '%s' "$pkg" | sed 's/%2C/,/g; s/%25/%/g')" + # check for existance + if [ ! -f "$pkg" ]; then + echo "$pkg does not exist" >&2 + continue + fi + # make path absolute + pkg="$(realpath "$pkg")" + mkdir -p "$rootdir/run/mmdebstrap" + mkdir -p "$rootdir/$(dirname "$pkg")" + case $MMDEBSTRAP_MODE in + root|unshare) + echo "bind-mounting $pkg into the chroot" >&2 + touch "$rootdir/$pkg" + mount -o bind "$pkg" "$rootdir/$pkg" + ;; + *) + echo "copying $pkg into the chroot" >&2 + cp -av "$pkg" "$rootdir/$pkg" + ;; + esac + printf '/%s\0' "$pkg" >> "$rootdir/run/mmdebstrap/file-mirror-automount" +done +set +f; unset IFS