From af95b4d77855c83b7d95097cf0aacb2e635dac7d Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Sun, 19 Mar 2023 09:01:37 +0100 Subject: [PATCH] hooks/file-mirror-automount/setup00.sh: use mmdebstrap --hook-helper upload and sync-in instead of cp --- hooks/file-mirror-automount/setup00.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hooks/file-mirror-automount/setup00.sh b/hooks/file-mirror-automount/setup00.sh index 354b661..61f60f2 100755 --- a/hooks/file-mirror-automount/setup00.sh +++ b/hooks/file-mirror-automount/setup00.sh @@ -14,6 +14,10 @@ env APT_CONFIG="$MMDEBSTRAP_APT_CONFIG" apt-get indextargets --no-release-info - | sort -u \ | while read -r path; do mkdir -p "$rootdir/run/mmdebstrap" + if [ ! -d "/$path" ]; then + echo "/$path is not an existing directory" >&2 + continue + fi case $MMDEBSTRAP_MODE in root|unshare) echo "bind-mounting /$path into the chroot" >&2 @@ -22,8 +26,8 @@ env APT_CONFIG="$MMDEBSTRAP_APT_CONFIG" apt-get indextargets --no-release-info - ;; *) echo "copying /$path into the chroot" >&2 - mkdir -p "$rootdir/$(dirname "$path")" - cp -av "/$path" "$rootdir/$(dirname "$path")" + mkdir -p "$rootdir/$path" + "$MMDEBSTRAP_ARGV0" --hook-helper "$rootdir" "$MMDEBSTRAP_MODE" "$MMDEBSTRAP_HOOK" env "$MMDEBSTRAP_VERBOSITY" sync-in "/$path" "/$path" <&"$MMDEBSTRAP_HOOKSOCK" >&"$MMDEBSTRAP_HOOKSOCK" ;; esac printf '/%s\0' "$path" >> "$rootdir/run/mmdebstrap/file-mirror-automount" @@ -47,6 +51,10 @@ for pkg in $MMDEBSTRAP_INCLUDE; do fi # make path absolute pkg="$(realpath "$pkg")" + case "$pkg" in + /*) : ;; + *) echo "path for $pkg is not absolute" >&2; continue;; + esac mkdir -p "$rootdir/run/mmdebstrap" mkdir -p "$rootdir/$(dirname "$pkg")" case $MMDEBSTRAP_MODE in @@ -57,7 +65,7 @@ for pkg in $MMDEBSTRAP_INCLUDE; do ;; *) echo "copying $pkg into the chroot" >&2 - cp -av "$pkg" "$rootdir/$pkg" + "$MMDEBSTRAP_ARGV0" --hook-helper "$rootdir" "$MMDEBSTRAP_MODE" "$MMDEBSTRAP_HOOK" env "$MMDEBSTRAP_VERBOSITY" upload "$pkg" "$pkg" <&"$MMDEBSTRAP_HOOKSOCK" >&"$MMDEBSTRAP_HOOKSOCK" ;; esac printf '/%s\0' "$pkg" >> "$rootdir/run/mmdebstrap/file-mirror-automount"