2022-12-23 09:02:04 +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 }}.tar /tmp/debian-chroot-root-normal.tar" EXIT INT TERM
|
|
|
|
|
|
|
|
[ "$(id -u)" -eq 0 ]
|
|
|
|
|
|
|
|
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}"
|
|
|
|
fi
|
|
|
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
|
|
|
fi
|
|
|
|
|
|
|
|
MMTARFILTER=
|
|
|
|
[ -x /usr/bin/mmtarfilter ] && MMTARFILTER=/usr/bin/mmtarfilter
|
|
|
|
[ -x ./tarfilter ] && MMTARFILTER=./tarfilter
|
|
|
|
|
2022-12-23 09:02:04 +00:00
|
|
|
filter() {
|
2023-02-02 06:57:58 +00:00
|
|
|
"$MMTARFILTER" \
|
2022-12-23 09:02:04 +00:00
|
|
|
--path-exclude=/usr/bin/uncompress \
|
|
|
|
--path-exclude=/var/cache/debconf/config.dat-old \
|
|
|
|
--path-exclude=/var/cache/debconf/templates.dat-old \
|
|
|
|
--path-exclude=/var/lib/dpkg/available \
|
2023-05-11 04:55:33 +00:00
|
|
|
--path-exclude=/var/lib/dpkg/diversions \
|
2022-12-23 09:02:04 +00:00
|
|
|
--path-exclude=/var/lib/dpkg/cmethopt \
|
|
|
|
--path-exclude=/var/lib/dpkg/status-old \
|
|
|
|
--path-exclude=/var/lib/shells.state
|
|
|
|
}
|
|
|
|
|
|
|
|
# base for comparison without jessie-or-older hook
|
2023-02-02 06:57:58 +00:00
|
|
|
{{ CMD }} --mode=root --variant={{ VARIANT }} {{ DIST }} - {{ MIRROR }} > /tmp/debian-chroot-root-normal.tar
|
2022-12-23 09:02:04 +00:00
|
|
|
|
2023-02-02 06:57:58 +00:00
|
|
|
$prefix {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --hook-dir=./hooks/jessie-or-older {{ DIST }} - {{ MIRROR }} | filter > /tmp/debian-chroot-{{ MODE }}.tar
|
|
|
|
filter < /tmp/debian-chroot-root-normal.tar | cmp - /tmp/debian-chroot-{{ MODE }}.tar
|