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"