2023-03-05 10:08:21 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
export LC_ALL=C.UTF-8
|
|
|
|
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
|
|
|
|
|
|
|
[ "$(id -u)" -eq 0 ]
|
|
|
|
[ {{ MODE }} = "root" ]
|
2024-05-12 15:16:51 +00:00
|
|
|
case {{ FORMAT }} in tar|squashfs|ext2|ext4) : ;; *) exit 1;; esac
|
2023-03-05 10:08:21 +00:00
|
|
|
|
2024-05-12 15:16:51 +00:00
|
|
|
{{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} {{ DIST }} /tmp/mmdebstrap-{{ DIST }}-{{ VARIANT }}.{{ FORMAT }} {{ MIRROR }}
|
|
|
|
# creating an ext4 image on a 9p filesystem produces different results compared
|
|
|
|
# to creating it on a tmpfs or ext4 fs because 9p does not support discards and
|
|
|
|
# even when running with -E nodiscard, the number of written bytes will differ
|
|
|
|
# https://lore.kernel.org/linux-ext4/171484520952.2626447.2160419274451668597@localhost/T/#t
|
|
|
|
mv /tmp/mmdebstrap-{{ DIST }}-{{ VARIANT }}.{{ FORMAT }} ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.{{ FORMAT }}
|
2023-03-05 10:08:21 +00:00
|
|
|
if [ "{{ FORMAT }}" = tar ]; then
|
support chrootless hurd-i386
$ mmdebstrap --variant=apt --include=passwd,debian-ports-archive-keyring,mmdebstrap,sysvinit-core,sysv-rc \
--customize-hook='chroot "$1" mmdebstrap --mode=chrootless --arch=hurd-i386 --include=sysvinit-core,sysv-rc,debian-ports-archive-keyring,gnumach-image-1-486 --customize-hook="passwd --root=\"\$1\" --delete root" --variant=apt unstable /tmp/chroot.tar "deb http://ftp.ports.debian.org/debian-ports/ unstable main" "deb http://ftp.ports.debian.org/debian-ports/ unreleased main"' \
--customize-hook='copy-out /tmp/chroot.tar .' unstable /dev/null
$ /sbin/mkfs.ext2 -q -F -o hurd -I 128 -b 4096 -d chroot.tar hurd.ext2 204800
$ qemu-system-i386 -nographic -net user,hostfwd=tcp:127.0.0.1:2222-:22 \
-net nic,model=e1000 -m 1G -kernel gnumach-1.8-486-up \
-append 'root=device:hd0 console=com0' --initrd './ext2fs.static --multiboot-command-line=${kernel-command-line} --host-priv-port=${host-port} --device-master-port=${device-port} --exec-server-task=${exec-task} -T typed ${root} $(task-create) $(task-resume),./exec.static $(exec-task=task-create)' \
-drive file=hurd.ext2,format=raw
2024-08-26 23:04:54 +00:00
|
|
|
printf 'ustar\0' | cmp --bytes=6 --ignore-initial=257:0 ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.tar -
|
2023-03-05 10:08:21 +00:00
|
|
|
elif [ "{{ FORMAT }}" = squashfs ]; then
|
|
|
|
printf 'hsqs' | cmp --bytes=4 ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.squashfs -
|
|
|
|
elif [ "{{ FORMAT }}" = ext2 ]; then
|
|
|
|
printf '\123\357' | cmp --bytes=2 --ignore-initial=1080:0 ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.ext2 -
|
2024-05-12 15:16:51 +00:00
|
|
|
printf '\000\000\000\000\000\000\000\000\000\000\000\000' | cmp --bytes=12 --ignore-initial=1116:0 ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.ext2 -
|
|
|
|
elif [ "{{ FORMAT }}" = ext4 ]; then
|
|
|
|
printf '\123\357' | cmp --bytes=2 --ignore-initial=1080:0 ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.ext4 -
|
|
|
|
printf '\074\020\000\000\302\042\000\000\153\004\000\000' | cmp --bytes=12 --ignore-initial=1116:0 ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.ext4 -
|
|
|
|
|
|
|
|
[ "$(/sbin/blkid --match-tag UUID --output value ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.ext4)" = "$(uuidgen --sha1 --namespace="$(uuidgen --sha1 --namespace='@dns' --name mister-muffin.de)" --name $SOURCE_DATE_EPOCH)" ]
|
2023-03-05 10:08:21 +00:00
|
|
|
else
|
|
|
|
echo "unknown format: {{ FORMAT }}" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|