2022-10-27 12:22:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
export LC_ALL=C.UTF-8
|
|
|
|
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
|
|
|
trap "rm -f /tmp/chrootless.tar /tmp/root.tar" EXIT INT TERM
|
2023-02-02 06:57:58 +00:00
|
|
|
|
|
|
|
[ {{ 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-10-27 12:22:53 +00:00
|
|
|
fi
|
2023-02-02 06:57:58 +00:00
|
|
|
|
2024-01-08 21:27:35 +00:00
|
|
|
MMTARFILTER=
|
|
|
|
[ -x /usr/bin/mmtarfilter ] && MMTARFILTER=/usr/bin/mmtarfilter
|
|
|
|
[ -x ./tarfilter ] && MMTARFILTER=./tarfilter
|
|
|
|
|
2022-10-27 12:22:53 +00:00
|
|
|
# we need --hook-dir=./hooks/merged-usr because usrmerge does not understand
|
|
|
|
# DPKG_ROOT
|
|
|
|
# permissions drwxr-sr-x and extended attributes of ./var/log/journal/ cannot
|
|
|
|
# be preserved under fakeroot
|
2024-01-08 21:27:35 +00:00
|
|
|
# this applies to 'z' lines in files in /usr/lib/tmpfiles.d/
|
2023-01-16 07:14:36 +00:00
|
|
|
for INCLUDE in '' 'apt' 'apt,build-essential' 'systemd-sysv'; do
|
2024-10-11 16:29:25 +00:00
|
|
|
{{ CMD }} --variant={{ VARIANT }} --hook-dir=./hooks/merged-usr \
|
|
|
|
${INCLUDE:+--include="$INCLUDE"} \
|
|
|
|
{{ DIST }} - {{ MIRROR }} \
|
|
|
|
| "$MMTARFILTER" --path-exclude="/var/log/journal" --path-exclude="/etc/credstore*" \
|
|
|
|
>/tmp/root.tar
|
|
|
|
$prefix fakeroot {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --hook-dir=./hooks/merged-usr \
|
|
|
|
${INCLUDE:+--include="$INCLUDE"} \
|
|
|
|
{{ DIST }} - {{ MIRROR }} \
|
|
|
|
| "$MMTARFILTER" --path-exclude="/var/log/journal" --path-exclude="/etc/credstore*" \
|
|
|
|
>/tmp/chrootless.tar
|
|
|
|
cmp /tmp/root.tar /tmp/chrootless.tar || diffoscope /tmp/root.tar /tmp/chrootless.tar
|
|
|
|
rm /tmp/chrootless.tar /tmp/root.tar
|
2022-10-27 12:22:53 +00:00
|
|
|
done
|