2022-05-25 14:02:09 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
export LC_ALL=C.UTF-8
|
|
|
|
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
2023-02-02 06:57:58 +00:00
|
|
|
|
|
|
|
trap "rm -f /tmp/debian-chroot-{{ MODE }}.{{ FORMAT }} /tmp/debian-chroot-root.{{ FORMAT }}" EXIT INT TERM
|
|
|
|
|
|
|
|
[ "$(id -u)" -eq 0 ]
|
|
|
|
|
|
|
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
|
|
|
if [ ! -e /mmdebstrap-testenv ]; then
|
|
|
|
echo "this test modifies the system and should only be run inside a container" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
|
|
|
fi
|
|
|
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
|
|
|
|
2022-05-25 14:02:09 +00:00
|
|
|
{{ CMD }} --mode=root --variant={{ VARIANT }} {{ DIST }} /tmp/debian-chroot-root.{{ FORMAT }} {{ MIRROR }}
|
|
|
|
if [ "{{ FORMAT }}" = tar ]; then
|
|
|
|
printf 'ustar ' | cmp --bytes=6 --ignore-initial=257:0 /tmp/debian-chroot-root.tar -
|
|
|
|
elif [ "{{ FORMAT }}" = squashfs ]; then
|
|
|
|
printf 'hsqs' | cmp --bytes=4 /tmp/debian-chroot-root.squashfs -
|
|
|
|
elif [ "{{ FORMAT }}" = ext2 ]; then
|
|
|
|
printf '\123\357' | cmp --bytes=2 --ignore-initial=1080:0 /tmp/debian-chroot-root.ext2 -
|
|
|
|
else
|
|
|
|
echo "unknown format: {{ FORMAT }}" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-02-02 06:57:58 +00:00
|
|
|
|
|
|
|
$prefix {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} {{ DIST }} /tmp/debian-chroot-{{ MODE }}.{{ FORMAT }} {{ MIRROR }}
|
|
|
|
cmp /tmp/debian-chroot-root.{{ FORMAT }} /tmp/debian-chroot-{{ MODE }}.{{ FORMAT }} \
|
|
|
|
|| diffoscope /tmp/debian-chroot-root.{{ FORMAT }} /tmp/debian-chroot-{{ MODE }}.{{ FORMAT }}
|
|
|
|
|
2022-10-18 08:22:19 +00:00
|
|
|
# we cannot test chrootless mode here, because mmdebstrap relies on the
|
|
|
|
# usrmerge package to set up merged-/usr and that doesn't work in chrootless
|
|
|
|
# mode
|