hooks/file-mirror-automount/setup00.sh: use mmdebstrap --hook-helper upload and sync-in instead of cp

This commit is contained in:
Johannes Schauer Marin Rodrigues 2023-03-19 09:01:37 +01:00
parent 4d44b9dbbe
commit af95b4d778
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -14,6 +14,10 @@ env APT_CONFIG="$MMDEBSTRAP_APT_CONFIG" apt-get indextargets --no-release-info -
| sort -u \ | sort -u \
| while read -r path; do | while read -r path; do
mkdir -p "$rootdir/run/mmdebstrap" mkdir -p "$rootdir/run/mmdebstrap"
if [ ! -d "/$path" ]; then
echo "/$path is not an existing directory" >&2
continue
fi
case $MMDEBSTRAP_MODE in case $MMDEBSTRAP_MODE in
root|unshare) root|unshare)
echo "bind-mounting /$path into the chroot" >&2 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 echo "copying /$path into the chroot" >&2
mkdir -p "$rootdir/$(dirname "$path")" mkdir -p "$rootdir/$path"
cp -av "/$path" "$rootdir/$(dirname "$path")" "$MMDEBSTRAP_ARGV0" --hook-helper "$rootdir" "$MMDEBSTRAP_MODE" "$MMDEBSTRAP_HOOK" env "$MMDEBSTRAP_VERBOSITY" sync-in "/$path" "/$path" <&"$MMDEBSTRAP_HOOKSOCK" >&"$MMDEBSTRAP_HOOKSOCK"
;; ;;
esac esac
printf '/%s\0' "$path" >> "$rootdir/run/mmdebstrap/file-mirror-automount" printf '/%s\0' "$path" >> "$rootdir/run/mmdebstrap/file-mirror-automount"
@ -47,6 +51,10 @@ for pkg in $MMDEBSTRAP_INCLUDE; do
fi fi
# make path absolute # make path absolute
pkg="$(realpath "$pkg")" pkg="$(realpath "$pkg")"
case "$pkg" in
/*) : ;;
*) echo "path for $pkg is not absolute" >&2; continue;;
esac
mkdir -p "$rootdir/run/mmdebstrap" mkdir -p "$rootdir/run/mmdebstrap"
mkdir -p "$rootdir/$(dirname "$pkg")" mkdir -p "$rootdir/$(dirname "$pkg")"
case $MMDEBSTRAP_MODE in case $MMDEBSTRAP_MODE in
@ -57,7 +65,7 @@ for pkg in $MMDEBSTRAP_INCLUDE; do
;; ;;
*) *)
echo "copying $pkg into the chroot" >&2 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 esac
printf '/%s\0' "$pkg" >> "$rootdir/run/mmdebstrap/file-mirror-automount" printf '/%s\0' "$pkg" >> "$rootdir/run/mmdebstrap/file-mirror-automount"