2022-05-25 14:02:09 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
export LC_ALL=C.UTF-8
|
2023-02-02 06:57:58 +00:00
|
|
|
|
2023-02-18 22:05:35 +00:00
|
|
|
trap "rm -rf /tmp/debian-chroot" EXIT INT TERM
|
|
|
|
|
2023-02-02 06:57:58 +00:00
|
|
|
[ {{ VARIANT }} = extract ]
|
|
|
|
|
|
|
|
prefix=
|
|
|
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
2023-02-09 09:04:22 +00:00
|
|
|
if ! id "${SUDO_USER:-user}" >/dev/null 2>&1; then
|
2023-02-02 06:57:58 +00:00
|
|
|
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}"
|
2022-05-25 14:02:09 +00:00
|
|
|
fi
|
2023-02-02 06:57:58 +00:00
|
|
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
2022-05-25 14:02:09 +00:00
|
|
|
fi
|
2023-02-02 06:57:58 +00:00
|
|
|
|
2022-05-25 14:02:09 +00:00
|
|
|
[ "{{ MODE }}" = "fakechroot" ] && prefix="$prefix fakechroot fakeroot"
|
2023-02-02 06:57:58 +00:00
|
|
|
$prefix {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --include=doc-debian {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
2022-05-25 14:02:09 +00:00
|
|
|
# delete contents of doc-debian
|
2023-05-06 06:33:15 +00:00
|
|
|
rm /tmp/debian-chroot/usr/share/doc-base/doc-debian.debian-*
|
2022-05-25 14:02:09 +00:00
|
|
|
rm -r /tmp/debian-chroot/usr/share/doc/debian
|
|
|
|
rm -r /tmp/debian-chroot/usr/share/doc/doc-debian
|
|
|
|
# delete real files
|
|
|
|
rm /tmp/debian-chroot/etc/apt/sources.list
|
|
|
|
rm /tmp/debian-chroot/etc/fstab
|
|
|
|
rm /tmp/debian-chroot/etc/hostname
|
|
|
|
rm /tmp/debian-chroot/etc/resolv.conf
|
|
|
|
rm /tmp/debian-chroot/var/lib/dpkg/status
|
2022-10-16 12:47:55 +00:00
|
|
|
rm /tmp/debian-chroot/var/lib/dpkg/arch
|
2022-05-25 14:02:09 +00:00
|
|
|
rm /tmp/debian-chroot/var/cache/apt/archives/lock
|
|
|
|
rm /tmp/debian-chroot/var/lib/apt/lists/lock
|
|
|
|
## delete merged usr symlinks
|
|
|
|
#rm /tmp/debian-chroot/libx32
|
|
|
|
#rm /tmp/debian-chroot/lib64
|
|
|
|
#rm /tmp/debian-chroot/lib32
|
|
|
|
#rm /tmp/debian-chroot/sbin
|
|
|
|
#rm /tmp/debian-chroot/bin
|
|
|
|
#rm /tmp/debian-chroot/lib
|
|
|
|
# delete ./dev (files might exist or not depending on the mode)
|
|
|
|
rm -f /tmp/debian-chroot/dev/console
|
|
|
|
rm -f /tmp/debian-chroot/dev/fd
|
|
|
|
rm -f /tmp/debian-chroot/dev/full
|
|
|
|
rm -f /tmp/debian-chroot/dev/null
|
|
|
|
rm -f /tmp/debian-chroot/dev/ptmx
|
|
|
|
rm -f /tmp/debian-chroot/dev/random
|
|
|
|
rm -f /tmp/debian-chroot/dev/stderr
|
|
|
|
rm -f /tmp/debian-chroot/dev/stdin
|
|
|
|
rm -f /tmp/debian-chroot/dev/stdout
|
|
|
|
rm -f /tmp/debian-chroot/dev/tty
|
|
|
|
rm -f /tmp/debian-chroot/dev/urandom
|
|
|
|
rm -f /tmp/debian-chroot/dev/zero
|
|
|
|
# the rest should be empty directories that we can rmdir recursively
|
|
|
|
find /tmp/debian-chroot -depth -print0 | xargs -0 rmdir
|