tests/chrootless: make sure that nothing outside the chroot changes

This commit is contained in:
Johannes Schauer Marin Rodrigues 2025-01-11 09:04:07 +01:00
parent e62f32b098
commit dc5bbb7173
Signed by: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -3,6 +3,7 @@ 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
before=$(tar --one-file-system --anchored --exclude="./var/log/journal/*" --exclude=./var/log/wtmp -C / -c ./usr ./bin ./etc ./lib ./sbin ./var | md5sum)
for INCLUDE in '' 'apt' 'apt,build-essential' 'systemd-sysv'; do
for MODE in root chrootless; do
{{ CMD }} --mode=$MODE --variant={{ VARIANT }} \
@ -12,3 +13,8 @@ for INCLUDE in '' 'apt' 'apt,build-essential' 'systemd-sysv'; do
cmp /tmp/root.tar /tmp/chrootless.tar || diffoscope /tmp/root.tar /tmp/chrootless.tar
rm /tmp/chrootless.tar /tmp/root.tar
done
after=$(tar --one-file-system --anchored --exclude="./var/log/journal/*" --exclude=./var/log/wtmp -C / -c ./usr ./bin ./etc ./lib ./sbin ./var | md5sum)
if [ "$before" != "$after" ]; then
echo "found changes outside the chroot" >&2
exit 1
fi