From 822f8eafec6c740e7fa567ff20d1ae826190bc26 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Thu, 27 Oct 2022 14:22:53 +0200 Subject: [PATCH] tests: test chrootless essential and systemd-sysv with fakeroot and foreign --- coverage.txt | 19 ++++++++++++++-- tests/chrootless | 16 +++++++++++++ tests/chrootless-essential | 13 ----------- tests/chrootless-fakeroot | 29 ++++++++++++++++++++++++ tests/chrootless-foreign | 46 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 108 insertions(+), 15 deletions(-) create mode 100644 tests/chrootless delete mode 100644 tests/chrootless-essential create mode 100644 tests/chrootless-fakeroot create mode 100644 tests/chrootless-foreign diff --git a/coverage.txt b/coverage.txt index 1093e13..33ddd18 100644 --- a/coverage.txt +++ b/coverage.txt @@ -288,12 +288,27 @@ Test: install-doc-debian Modes: chrootless Variants: custom -Test: chrootless-essential -Variants: custom +Test: chrootless +Variants: essential Modes: chrootless Skip-If: dist in ["oldstable", "stable"] +Test: chrootless-fakeroot +Variants: essential +Modes: chrootless +Skip-If: + dist in ["oldstable", "stable"] + +Test: chrootless-foreign +Variants: essential +Modes: chrootless +Skip-If: + dist in ["oldstable", "stable"] + hostarch != "amd64" + not run_ma_same_tests +Needs-QEMU: true + Test: install-doc-debian-and-output-tarball Variants: custom Modes: chrootless diff --git a/tests/chrootless b/tests/chrootless new file mode 100644 index 0000000..cead669 --- /dev/null +++ b/tests/chrootless @@ -0,0 +1,16 @@ +#!/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 +# we need --hook-dir=./hooks/merged-usr because usrmerge does not understand +# DPKG_ROOT +for INCLUDE in '' 'systemd-sysv'; do + for MODE in root chrootless; do + {{ CMD }} --mode=$MODE --variant={{ VARIANT }} --hook-dir=./hooks/merged-usr \ + ${INCLUDE:+--include="$INCLUDE"} \ + {{ DIST }} "/tmp/$MODE.tar" {{ MIRROR }} + done + cmp /tmp/root.tar /tmp/chrootless.tar + rm /tmp/chrootless.tar /tmp/root.tar +done diff --git a/tests/chrootless-essential b/tests/chrootless-essential deleted file mode 100644 index bfb110b..0000000 --- a/tests/chrootless-essential +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -set -eu -export LC_ALL=C.UTF-8 -if [ "$(id -u)" -eq 0 ] && ! id -u 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 - adduser --gecos user --disabled-password user -fi -prefix= -[ "$(id -u)" -eq 0 ] && prefix="runuser -u user --" -$prefix fakechroot fakeroot {{ CMD }} --mode=chrootless --variant=essential {{ DIST }} /dev/null {{ MIRROR }} diff --git a/tests/chrootless-fakeroot b/tests/chrootless-fakeroot new file mode 100644 index 0000000..9d83df9 --- /dev/null +++ b/tests/chrootless-fakeroot @@ -0,0 +1,29 @@ +#!/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 +if [ "$(id -u)" -eq 0 ] && ! id -u 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 + adduser --gecos user --disabled-password user +fi +prefix= +[ "$(id -u)" -eq 0 ] && prefix="runuser -u user --" +# 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 +for INCLUDE in '' 'systemd-sysv'; do + {{ 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 }} + $prefix fakeroot {{ CMD }} --mode=chrootless --variant={{ VARIANT }} --hook-dir=./hooks/merged-usr \ + ${INCLUDE:+--include="$INCLUDE"} \ + {{ DIST }} /tmp/chrootless.tar {{ MIRROR }} + cmp /tmp/root.tar /tmp/chrootless.tar + rm /tmp/chrootless.tar /tmp/root.tar +done diff --git a/tests/chrootless-foreign b/tests/chrootless-foreign new file mode 100644 index 0000000..1b04f51 --- /dev/null +++ b/tests/chrootless-foreign @@ -0,0 +1,46 @@ +#!/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 +if [ ! -e /mmdebstrap-testenv ]; then + echo "this test modifies the system and should only be run inside a container" >&2 + exit 1 +fi + +[ "$(id -u)" -eq 0 ] +[ -e /proc/sys/fs/binfmt_misc/qemu-aarch64 ] + +# we need --hook-dir=./hooks/merged-usr because usrmerge does not understand +# DPKG_ROOT +for INCLUDE in '' 'systemd-sysv'; do + echo 1 > /proc/sys/fs/binfmt_misc/qemu-aarch64 + arch-test arm64 + {{ CMD }} --mode=root --architecture=arm64 --variant={{ VARIANT }} \ + --hook-dir=./hooks/merged-usr ${INCLUDE:+--include="$INCLUDE"} \ + {{ DIST }} "/tmp/root.tar" {{ MIRROR }} + echo 0 > /proc/sys/fs/binfmt_misc/qemu-aarch64 + ! arch-test arm64 + {{ CMD }} --mode=chrootless --architecture=arm64 --variant={{ VARIANT }} \ + --hook-dir=./hooks/merged-usr ${INCLUDE:+--include="$INCLUDE"} \ + {{ DIST }} "/tmp/chrootless.tar" {{ MIRROR }} + # when creating a foreign architecture chroot, the tarballs are not + # bit-by-bit identical but contain a few remaining differences: + # + # * /etc/ld.so.cache -- hard problem, must be solved in glibc upstream + # * /var/lib/dpkg/triggers -- #990712 + # * /var/cache/debconf/*.dat-old -- needs investigation + for tar in root chrootless; do + <"/tmp/$tar.tar" \ + ./tarfilter \ + --path-exclude=/var/cache/debconf/config.dat-old \ + --path-exclude=/var/cache/debconf/templates.dat-old \ + --path-exclude=/etc/ld.so.cache \ + --path-exclude=/var/lib/dpkg/triggers/File \ + --path-exclude=/var/lib/dpkg/triggers/ldconfig \ + > "/tmp/$tar.tar.tmp" + mv "/tmp/$tar.tar.tmp" "/tmp/$tar.tar" + done + cmp /tmp/root.tar /tmp/chrootless.tar + rm /tmp/chrootless.tar /tmp/root.tar +done