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
|
|
|
|
|
|
|
[ {{ VARIANT }} = "custom" ]
|
|
|
|
[ {{ MODE }} = "chrootless" ]
|
|
|
|
|
|
|
|
prefix=
|
|
|
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
2024-10-11 16:29:25 +00:00
|
|
|
if ! id "${SUDO_USER:-user}" >/dev/null 2>&1; 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
|
|
|
fi
|
2023-02-02 06:57:58 +00:00
|
|
|
|
2024-01-30 06:08:22 +00:00
|
|
|
case "$(dpkg --print-architecture)" in
|
2024-10-11 16:29:25 +00:00
|
|
|
arm64)
|
|
|
|
foreign_arch=amd64
|
|
|
|
;;
|
|
|
|
amd64)
|
|
|
|
foreign_arch=arm64
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unsupported native architecture" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
2024-01-30 06:08:22 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
$prefix {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --architectures="$foreign_arch" --include=libmagic-mgc {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
2022-05-25 14:02:09 +00:00
|
|
|
# delete contents of libmagic-mgc
|
|
|
|
rm /tmp/debian-chroot/usr/lib/file/magic.mgc
|
|
|
|
rm /tmp/debian-chroot/usr/share/doc/libmagic-mgc/README.Debian
|
|
|
|
rm /tmp/debian-chroot/usr/share/doc/libmagic-mgc/changelog.Debian.gz
|
|
|
|
rm /tmp/debian-chroot/usr/share/doc/libmagic-mgc/changelog.gz
|
|
|
|
rm /tmp/debian-chroot/usr/share/doc/libmagic-mgc/copyright
|
2024-03-27 04:50:51 +00:00
|
|
|
rm -f /tmp/debian-chroot/usr/share/doc/libmagic-mgc/"changelog.Debian.$foreign_arch.gz"
|
2022-05-25 14:02:09 +00:00
|
|
|
rm /tmp/debian-chroot/usr/share/file/magic.mgc
|
|
|
|
rm /tmp/debian-chroot/usr/share/misc/magic.mgc
|
|
|
|
# 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
|
|
|
|
rm /tmp/debian-chroot/var/cache/apt/archives/lock
|
|
|
|
rm /tmp/debian-chroot/var/lib/dpkg/lock
|
|
|
|
rm /tmp/debian-chroot/var/lib/dpkg/lock-frontend
|
|
|
|
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
|
|
|
|
# in chrootless mode, there is more to remove
|
|
|
|
rm /tmp/debian-chroot/var/lib/dpkg/arch
|
|
|
|
rm /tmp/debian-chroot/var/lib/dpkg/triggers/Lock
|
|
|
|
rm /tmp/debian-chroot/var/lib/dpkg/triggers/Unincorp
|
|
|
|
rm /tmp/debian-chroot/var/lib/dpkg/status-old
|
|
|
|
rm /tmp/debian-chroot/var/lib/dpkg/info/format
|
|
|
|
rm /tmp/debian-chroot/var/lib/dpkg/info/libmagic-mgc.md5sums
|
|
|
|
rm /tmp/debian-chroot/var/lib/dpkg/info/libmagic-mgc.list
|
|
|
|
# the rest should be empty directories that we can rmdir recursively
|
|
|
|
find /tmp/debian-chroot -depth -print0 | xargs -0 rmdir
|