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
|
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-10-27 12:22:53 +00:00
|
|
|
fi
|
2023-02-02 06:57:58 +00:00
|
|
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
2022-10-27 12:22:53 +00:00
|
|
|
fi
|
2023-02-02 06:57:58 +00:00
|
|
|
|
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
|
2023-01-16 07:14:36 +00:00
|
|
|
for INCLUDE in '' 'apt' 'apt,build-essential' 'systemd-sysv'; do
|
2022-10-27 12:22:53 +00:00
|
|
|
{{ CMD }} --variant={{ VARIANT }} --hook-dir=./hooks/merged-usr \
|
|
|
|
--customize-hook='if [ -d "$1"/var/log/journal ]; then rmdir "$1"/var/log/journal; mkdir --mode=2755 "$1"/var/log/journal; chroot "$1" chown root:systemd-journal /var/log/journal; fi' \
|
|
|
|
${INCLUDE:+--include="$INCLUDE"} \
|
|
|
|
{{ DIST }} /tmp/root.tar {{ MIRROR }}
|
2023-02-02 06:57:58 +00:00
|
|
|
$prefix fakeroot {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --hook-dir=./hooks/merged-usr \
|
2022-10-27 12:22:53 +00:00
|
|
|
${INCLUDE:+--include="$INCLUDE"} \
|
|
|
|
{{ DIST }} /tmp/chrootless.tar {{ MIRROR }}
|
2023-02-10 03:10:23 +00:00
|
|
|
cmp /tmp/root.tar /tmp/chrootless.tar || diffoscope /tmp/root.tar /tmp/chrootless.tar
|
2022-10-27 12:22:53 +00:00
|
|
|
rm /tmp/chrootless.tar /tmp/root.tar
|
|
|
|
done
|