2022-05-25 14:02:09 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
export LC_ALL=C.UTF-8
|
2023-02-18 22:05:35 +00:00
|
|
|
|
|
|
|
trap "rm -rf /tmp/debian-chroot" EXIT INT TERM
|
|
|
|
|
2022-05-25 14:02:09 +00:00
|
|
|
pkgs=base-files,base-passwd,busybox,debianutils,dpkg,libc-bin,mawk,tar
|
|
|
|
# busybox --install -s will install symbolic links into the rootfs, leaving
|
|
|
|
# existing files untouched. It has to run after extraction (otherwise there is
|
|
|
|
# no busybox binary) and before first configuration
|
|
|
|
{{ CMD }} --mode=root --variant=custom \
|
|
|
|
--include=$pkgs \
|
|
|
|
--setup-hook='mkdir -p "$1/bin"' \
|
|
|
|
--setup-hook='echo root:x:0:0:root:/root:/bin/sh > "$1/etc/passwd"' \
|
|
|
|
--setup-hook='printf "root:x:0:\nmail:x:8:\nutmp:x:43:\n" > "$1/etc/group"' \
|
|
|
|
--extract-hook='chroot "$1" busybox --install -s' \
|
|
|
|
{{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
|
|
|
echo "$pkgs" | tr ',' '\n' > /tmp/expected
|
|
|
|
chroot /tmp/debian-chroot dpkg-query -f '${binary:Package}\n' -W \
|
|
|
|
| comm -12 - /tmp/expected \
|
|
|
|
| diff -u - /tmp/expected
|
|
|
|
rm /tmp/expected
|
|
|
|
for cmd in echo cat sed grep; do
|
|
|
|
test -L /tmp/debian-chroot/bin/$cmd
|
2024-01-08 21:36:07 +00:00
|
|
|
test "$(readlink /tmp/debian-chroot/bin/$cmd)" = "/usr/bin/busybox"
|
2022-05-25 14:02:09 +00:00
|
|
|
done
|
2022-11-16 12:59:38 +00:00
|
|
|
for cmd in sort tee; do
|
2022-05-25 14:02:09 +00:00
|
|
|
test -L /tmp/debian-chroot/usr/bin/$cmd
|
2024-01-08 21:36:07 +00:00
|
|
|
test "$(readlink /tmp/debian-chroot/usr/bin/$cmd)" = "/usr/bin/busybox"
|
2022-05-25 14:02:09 +00:00
|
|
|
done
|
2024-01-08 21:54:43 +00:00
|
|
|
|
|
|
|
# if /bin or /sbin are not symlinks, add /bin and /sbin to PATH
|
|
|
|
if [ ! -L /tmp/debian-chroot/bin ] || [ ! -L /tmp/debian-chroot/sbin ]; then
|
|
|
|
export PATH="$PATH:/sbin:/bin"
|
|
|
|
fi
|
2022-05-25 14:02:09 +00:00
|
|
|
chroot /tmp/debian-chroot echo foobar \
|
|
|
|
| chroot /tmp/debian-chroot cat \
|
|
|
|
| chroot /tmp/debian-chroot sort \
|
2022-11-16 12:59:38 +00:00
|
|
|
| chroot /tmp/debian-chroot tee /dev/null \
|
2022-05-25 14:02:09 +00:00
|
|
|
| chroot /tmp/debian-chroot sed 's/foobar/blubber/' \
|
|
|
|
| chroot /tmp/debian-chroot grep blubber >/dev/null
|