diff options
Diffstat (limited to '')
-rw-r--r-- | tests/chrootless | 16 | ||||
-rw-r--r-- | tests/chrootless-fakeroot | 43 | ||||
-rw-r--r-- | tests/chrootless-foreign | 68 |
3 files changed, 127 insertions, 0 deletions
diff --git a/tests/chrootless b/tests/chrootless new file mode 100644 index 0000000..77490c3 --- /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 '' 'apt' 'apt,build-essential' 'systemd-sysv'; do + for MODE in root chrootless; do + {{ CMD }} --mode=$MODE --variant={{ VARIANT }} --hook-dir=./hooks/merged-usr \ + ${INCLUDE:+--include="$INCLUDE"} --skip=check/chrootless \ + {{ DIST }} "/tmp/$MODE.tar" {{ MIRROR }} + done + cmp /tmp/root.tar /tmp/chrootless.tar || diffoscope /tmp/root.tar /tmp/chrootless.tar + rm /tmp/chrootless.tar /tmp/root.tar +done diff --git a/tests/chrootless-fakeroot b/tests/chrootless-fakeroot new file mode 100644 index 0000000..8821fa6 --- /dev/null +++ b/tests/chrootless-fakeroot @@ -0,0 +1,43 @@ +#!/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 + +[ {{ MODE }} = chrootless ] + +prefix= +if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then + 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} --" +fi + +MMTARFILTER= +[ -x /usr/bin/mmtarfilter ] && MMTARFILTER=/usr/bin/mmtarfilter +[ -x ./tarfilter ] && MMTARFILTER=./tarfilter + +# 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 +# this applies to 'z' lines in files in /usr/lib/tmpfiles.d/ +for INCLUDE in '' 'apt' 'apt,build-essential' 'systemd-sysv'; do + {{ 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 +done diff --git a/tests/chrootless-foreign b/tests/chrootless-foreign new file mode 100644 index 0000000..03203d0 --- /dev/null +++ b/tests/chrootless-foreign @@ -0,0 +1,68 @@ +#!/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 + +deb2qemu() { + case "$1" in + amd64) echo x86_64;; + arm64) echo aarch64;; + armel|armhf) echo arm;; + ppc64el) echo ppc64le;; + *) echo "$1";; + esac +} +if [ "$(dpkg --print-architecture)" = "arm64" ]; then + arch=amd64 +else + arch=arm64 +fi + +[ "$(id -u)" -eq 0 ] +[ -e "/proc/sys/fs/binfmt_misc/qemu-$(deb2qemu "$arch")" ] + + +# we need --hook-dir=./hooks/merged-usr because usrmerge does not understand +# DPKG_ROOT +# +# dpkg is unable to install architecture arch:all packages with a +# dependency on an arch:any package (perl-modules-5.34 in this case) +# inside foreign architecture chrootless chroots, because dpkg will use +# its own architecture as the native architecture, see #825385 and #1020533 +# So we are not testing the installation of apt,build-essential here. +for INCLUDE in '' 'apt' 'systemd-sysv'; do + echo 1 > "/proc/sys/fs/binfmt_misc/qemu-$(deb2qemu "$arch")" + arch-test "$arch" + {{ CMD }} --mode=root --architecture="$arch" --variant={{ VARIANT }} \ + --hook-dir=./hooks/merged-usr ${INCLUDE:+--include="$INCLUDE"} \ + {{ DIST }} "/tmp/root.tar" {{ MIRROR }} + echo 0 > "/proc/sys/fs/binfmt_misc/qemu-$(deb2qemu "$arch")" + arch-test "$arch" && exit 1 + {{ CMD }} --mode=chrootless --architecture="$arch" --variant={{ VARIANT }} \ + --hook-dir=./hooks/merged-usr ${INCLUDE:+--include="$INCLUDE"} \ + --skip=check/chrootless {{ 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 || diffoscope /tmp/root.tar /tmp/chrootless.tar + rm /tmp/chrootless.tar /tmp/root.tar +done |