file-mirror-automount hook now supports modes that cannot mount (like fakechroot) by copying the repo into the chroot
This commit is contained in:
parent
c1c6297db7
commit
d96e85fddd
4 changed files with 40 additions and 7 deletions
|
@ -127,6 +127,7 @@ Test: file-mirror
|
||||||
Needs-QEMU: true
|
Needs-QEMU: true
|
||||||
|
|
||||||
Test: file-mirror-automount-hook
|
Test: file-mirror-automount-hook
|
||||||
|
Modes: root unshare fakechroot
|
||||||
Needs-QEMU: true
|
Needs-QEMU: true
|
||||||
|
|
||||||
Test: mirror-is-deb
|
Test: mirror-is-deb
|
||||||
|
|
|
@ -14,13 +14,26 @@ fi
|
||||||
|
|
||||||
xargsopts="--null --no-run-if-empty -I {} --max-args=1"
|
xargsopts="--null --no-run-if-empty -I {} --max-args=1"
|
||||||
|
|
||||||
echo "unmounting the following mountpoints:" >&2
|
case $MMDEBSTRAP_MODE in
|
||||||
|
root|unshare)
|
||||||
|
echo "unmounting the following mountpoints:" >&2 ;;
|
||||||
|
*)
|
||||||
|
echo "removing the following directories:" >&2 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
|
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
|
||||||
| xargs $xargsopts echo " $rootdir/{}"
|
| xargs $xargsopts echo " $rootdir/{}"
|
||||||
|
|
||||||
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
|
case $MMDEBSTRAP_MODE in
|
||||||
| xargs $xargsopts umount "$rootdir/{}"
|
root|unshare)
|
||||||
|
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
|
||||||
|
| xargs $xargsopts umount "$rootdir/{}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
cat "$rootdir/run/mmdebstrap/file-mirror-automount" \
|
||||||
|
| xargs $xargsopts rm -r "$rootdir/{}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
rm "$rootdir/run/mmdebstrap/file-mirror-automount"
|
rm "$rootdir/run/mmdebstrap/file-mirror-automount"
|
||||||
rmdir --ignore-fail-on-non-empty "$rootdir/run/mmdebstrap"
|
rmdir --ignore-fail-on-non-empty "$rootdir/run/mmdebstrap"
|
||||||
|
|
|
@ -12,9 +12,18 @@ env APT_CONFIG=$MMDEBSTRAP_APT_CONFIG apt-get indextargets --no-release-info \
|
||||||
| sed -ne 's/^Repo-URI: file:\/\+//p' \
|
| sed -ne 's/^Repo-URI: file:\/\+//p' \
|
||||||
| sort -u \
|
| sort -u \
|
||||||
| while read path; do
|
| while read path; do
|
||||||
echo "bind-mounting /$path into the chroot" >&2
|
|
||||||
mkdir -p "$rootdir/run/mmdebstrap"
|
mkdir -p "$rootdir/run/mmdebstrap"
|
||||||
mkdir -p "$rootdir/$path"
|
case $MMDEBSTRAP_MODE in
|
||||||
mount -o ro,bind "/$path" "$rootdir/$path"
|
root|unshare)
|
||||||
|
echo "bind-mounting /$path into the chroot" >&2
|
||||||
|
mkdir -p "$rootdir/$path"
|
||||||
|
mount -o ro,bind "/$path" "$rootdir/$path"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "copying /$path into the chroot" >&2
|
||||||
|
mkdir -p "$rootdir/$(dirname $path)"
|
||||||
|
cp -av "/$path" "$rootdir/$(dirname $path)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
printf '/%s\0' "$path" >> "$rootdir/run/mmdebstrap/file-mirror-automount"
|
printf '/%s\0' "$path" >> "$rootdir/run/mmdebstrap/file-mirror-automount"
|
||||||
done
|
done
|
||||||
|
|
|
@ -5,6 +5,16 @@ if [ ! -e /mmdebstrap-testenv ]; then
|
||||||
echo "this test requires the cache directory to be mounted on /mnt and should only be run inside a container" >&2
|
echo "this test requires the cache directory to be mounted on /mnt and should only be run inside a container" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
{{ CMD }} --mode={{ MODE }} --variant=apt --hook-dir=./hooks/file-mirror-automount --customize-hook='rmdir "$1"/mnt/cache/debian/ "$1"/mnt/cache' {{ DIST }} /tmp/debian-chroot.tar "deb file:///mnt/cache/debian {{ DIST }} main"
|
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
||||||
|
adduser --gecos user --disabled-password user
|
||||||
|
fi
|
||||||
|
prefix=
|
||||||
|
[ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && prefix="runuser -u user --"
|
||||||
|
[ "{{ MODE }}" = "fakechroot" ] && prefix="$prefix fakechroot fakeroot"
|
||||||
|
$prefix {{ CMD }} --mode={{ MODE }} --variant=apt \
|
||||||
|
--hook-dir=./hooks/file-mirror-automount \
|
||||||
|
--customize-hook='[ ! -e "$1"/mnt/cache/debian/ ] || rmdir "$1"/mnt/cache/debian/' \
|
||||||
|
--customize-hook='rmdir "$1"/mnt/cache' \
|
||||||
|
{{ DIST }} /tmp/debian-chroot.tar "deb file:///mnt/cache/debian {{ DIST }} main"
|
||||||
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
||||||
rm /tmp/debian-chroot.tar
|
rm /tmp/debian-chroot.tar
|
||||||
|
|
Loading…
Reference in a new issue