Compare commits

..

16 commits
main ... main

Author SHA1 Message Date
6617436d70
release 1.5.4 2024-10-28 09:16:58 +01:00
e4777d8fdf
document how to build a jessie chroot tarball 2024-10-28 09:15:18 +01:00
14e2f9ea11
tests/check-against-debootstrap-dist: require iputils-ping >= 3:20240905-1 2024-10-28 09:15:00 +01:00
99f82456f3
do not generate apt sources.list entry if SUITE is empty 2024-10-28 09:13:48 +01:00
5055b1b44c
tests/check-against-debootstrap-dist: since iputils-ping 20240905 there are no extended attributes anymore 2024-10-11 18:38:04 +02:00
c82fc7e261
format shell scripts with shfmt --binary-next-line --case-indent --indent 2 --simplify 2024-10-11 18:32:57 +02:00
eca6cb314c
tests/tarfilter-idshift: use a fabricated tarball instead of real chroot
iputils-ping does not ship /bin/ping with xattrs anymore.
2024-10-11 11:16:14 +02:00
395ee60a7f
release 1.5.3 2024-09-13 07:35:10 +02:00
1a8f2537ac
explain --pax-option with comment 2024-09-13 01:19:17 +02:00
0f5d935941
more sanity checks of target directory 2024-09-13 01:19:02 +02:00
dbce1ee27b
fix typo 2024-09-13 01:18:20 +02:00
6e4ed4a049
add --skip=cleanup/reproducible/machine-id 2024-09-13 01:17:52 +02:00
87b9b385b3
tarfilter: do not rely on paths being absolute (starting with a single slash) 2024-09-13 01:16:31 +02:00
acf036fa79
qemu-user now includes the static binary and qemu-user-static will be dropped in the long-term 2024-09-13 01:13:04 +02:00
d9c04338f8
support chrootless hurd-i386
$ mmdebstrap --variant=apt --include=passwd,debian-ports-archive-keyring,mmdebstrap,sysvinit-core,sysv-rc \
    --customize-hook='chroot "$1" mmdebstrap --mode=chrootless --arch=hurd-i386 --include=sysvinit-core,sysv-rc,debian-ports-archive-keyring,gnumach-image-1-486 --customize-hook="passwd --root=\"\$1\" --delete root" --variant=apt unstable /tmp/chroot.tar "deb http://ftp.ports.debian.org/debian-ports/ unstable main" "deb http://ftp.ports.debian.org/debian-ports/ unreleased main"' \
    --customize-hook='copy-out /tmp/chroot.tar .' unstable /dev/null
$ /sbin/mkfs.ext2 -q -F -o hurd -I 128 -b 4096 -d chroot.tar hurd.ext2 204800
$ qemu-system-i386 -nographic -net user,hostfwd=tcp:127.0.0.1:2222-:22 \
    -net nic,model=e1000 -m 1G -kernel gnumach-1.8-486-up \
    -append 'root=device:hd0 console=com0' --initrd './ext2fs.static --multiboot-command-line=${kernel-command-line} --host-priv-port=${host-port} --device-master-port=${device-port} --exec-server-task=${exec-task} -T typed ${root} $(task-create) $(task-resume),./exec.static $(exec-task=task-create)' \
    -drive file=hurd.ext2,format=raw
2024-08-27 01:15:00 +02:00
d0568a2b9e
Wait for (reap) potential zombies and otherwise long-running background processes
Otherwise they might hog resources like /dev/null which can then not be
unmounted resulting in their mountpoints (the regular files) not being
removable and then the removal of device nodes in run_cleanup (if
mmdebstrap is run with --skip=output/dev) will fail.

Another potential solution would be to run each hook and apt invocation
in its own process namespace but this would require to remount /proc and
this in turn would require a new mount namespace as well but we'd like
to keep the mount namespace across multiple hooks...
2024-08-18 22:07:52 +02:00
113 changed files with 3254 additions and 1952 deletions

View file

@ -1,3 +1,16 @@
1.5.4 (2024-10-28)
------------------
- do not generate apt sources.list entry if SUITE is empty
1.5.3 (2024-09-13)
------------------
- tidy up any zombie processes
- chrootless hurd-i386
- add --skip=cleanup/reproducible/machine-id
- m-a-b-q: replace test_installed by dpkg-checkbuilddeps
1.5.2 (2024-06-26) 1.5.2 (2024-06-26)
------------------ ------------------

View file

@ -362,6 +362,21 @@ def main():
check=False, check=False,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
).stdout.decode() ).stdout.decode()
shfmt = subprocess.run(
[
"shfmt",
"--posix",
"--binary-next-line",
"--case-indent",
"--indent",
"2",
"--simplify",
"-d",
"shared/test.sh",
],
check=False,
stdout=subprocess.PIPE,
).stdout.decode()
argv = None argv = None
match test: match test:
case "qemu": case "qemu":
@ -411,9 +426,11 @@ def main():
acc_time_per_test[name].append(walltime) acc_time_per_test[name].append(walltime)
print(separator, file=sys.stderr) print(separator, file=sys.stderr)
print(f"duration: {walltime}", file=sys.stderr) print(f"duration: {walltime}", file=sys.stderr)
if proc.returncode != 0 or shellcheck != "": if proc.returncode != 0 or shellcheck != "" or shfmt != "":
if shellcheck != "": if shellcheck != "":
print(shellcheck) print(shellcheck)
if shfmt != "":
print(shfmt)
failed.append(formated_test_name) failed.append(formated_test_name)
print("result: FAILURE", file=sys.stderr) print("result: FAILURE", file=sys.stderr)
else: else:

View file

@ -8,7 +8,8 @@ set -eu
case "$CMD" in case "$CMD" in
"mmdebstrap "* | mmdebstrap | *" mmdebstrap" | *" mmdebstrap "*) "mmdebstrap "* | mmdebstrap | *" mmdebstrap" | *" mmdebstrap "*)
MMSCRIPT="$(command -v mmdebstrap 2>/dev/null)";; MMSCRIPT="$(command -v mmdebstrap 2>/dev/null)"
;;
*) MMSCRIPT=./mmdebstrap ;; *) MMSCRIPT=./mmdebstrap ;;
esac esac
@ -41,6 +42,8 @@ done
shellcheck --exclude=SC2016 coverage.sh make_mirror.sh run_null.sh run_qemu.sh gpgvnoexpkeysig mmdebstrap-autopkgtest-build-qemu hooks/*/*.sh shellcheck --exclude=SC2016 coverage.sh make_mirror.sh run_null.sh run_qemu.sh gpgvnoexpkeysig mmdebstrap-autopkgtest-build-qemu hooks/*/*.sh
shfmt --binary-next-line --case-indent --indent 2 --simplify -d coverage.sh make_mirror.sh run_null.sh run_qemu.sh mmdebstrap-autopkgtest-build-qemu gpgvnoexpkeysig
mirrordir="./shared/cache/debian" mirrordir="./shared/cache/debian"
if [ ! -e "$mirrordir" ]; then if [ ! -e "$mirrordir" ]; then
@ -105,7 +108,7 @@ END
fi fi
# check if the wiki has to be updated with pod2markdown output # check if the wiki has to be updated with pod2markdown output
if [ "${DEBEMAIL:-}" = "josch@debian.org" ]; then if [ "${DEBEMAIL-}" = "josch@debian.org" ]; then
bash -exc "diff -u <(curl --silent https://gitlab.mister-muffin.de/josch/mmdebstrap/wiki/raw/Home | dos2unix; echo) <(pod2markdown < mmdebstrap)" || : bash -exc "diff -u <(curl --silent https://gitlab.mister-muffin.de/josch/mmdebstrap/wiki/raw/Home | dos2unix; echo) <(pod2markdown < mmdebstrap)" || :
fi fi

View file

@ -430,3 +430,8 @@ Modes: root unshare
Test: skip-tar-in-mknod Test: skip-tar-in-mknod
Modes: unshare Modes: unshare
Test: zombie-reaping
Modes: unshare
Test: empty-suite

View file

@ -322,8 +322,14 @@ if [ "$FORCE_UPDATE" != "yes" ] && [ -e "$oldmirrordir/dists/$DEFAULT_DIST/InRel
http_code=$(curl --output /dev/null --silent --location --head --time-cond "$oldmirrordir/dists/$DEFAULT_DIST/InRelease" --write-out '%{http_code}' "$mirror/dists/$DEFAULT_DIST/InRelease") http_code=$(curl --output /dev/null --silent --location --head --time-cond "$oldmirrordir/dists/$DEFAULT_DIST/InRelease" --write-out '%{http_code}' "$mirror/dists/$DEFAULT_DIST/InRelease")
case "$http_code" in case "$http_code" in
200) ;; # need update 200) ;; # need update
304) echo up-to-date; exit 0;; 304)
*) echo "unexpected status: $http_code"; exit 1;; echo up-to-date
exit 0
;;
*)
echo "unexpected status: $http_code"
exit 1
;;
esac esac
fi fi
@ -453,7 +459,7 @@ if [ "$HAVE_QEMU" = "yes" ]; then
tmpdir="$(mktemp -d)" tmpdir="$(mktemp -d)"
trap 'kill "$PROXYPID" || :;cleanuptmpdir; cleanup_newcachedir' EXIT INT TERM trap 'kill "$PROXYPID" || :;cleanuptmpdir; cleanup_newcachedir' EXIT INT TERM
pkgs=perl-doc,systemd-sysv,perl,arch-test,fakechroot,fakeroot,mount,uidmap,qemu-user-static,qemu-user,dpkg-dev,mini-httpd,libdevel-cover-perl,libtemplate-perl,debootstrap,procps,apt-cudf,aspcud,python3,libcap2-bin,gpg,debootstrap,distro-info-data,iproute2,ubuntu-keyring,apt-utils,squashfs-tools-ng,genext2fs,linux-image-generic,passwd,e2fsprogs,uuid-runtime pkgs=perl-doc,systemd-sysv,perl,arch-test,fakechroot,fakeroot,mount,uidmap,qemu-user-binfmt,dpkg-dev,mini-httpd,libdevel-cover-perl,libtemplate-perl,debootstrap,procps,apt-cudf,aspcud,python3,libcap2-bin,gpg,debootstrap,distro-info-data,iproute2,ubuntu-keyring,apt-utils,squashfs-tools-ng,genext2fs,linux-image-generic,passwd,e2fsprogs,uuid-runtime
if [ ! -e ./mmdebstrap ]; then if [ ! -e ./mmdebstrap ]; then
pkgs="$pkgs,mmdebstrap" pkgs="$pkgs,mmdebstrap"
fi fi

1376
mmdebstrap

File diff suppressed because it is too large Load diff

View file

@ -234,8 +234,8 @@ while test "$#" -gt 0; do
done done
test -z "$RELEASE" -o -z "$IMAGE" && usage_error "missing positional arguments" test -z "$RELEASE" -o -z "$IMAGE" && usage_error "missing positional arguments"
test "$BOOT" = efi || test "$BOOT" = efi \
die "this tool does not support boot modes other than efi" || die "this tool does not support boot modes other than efi"
case "$ARCHITECTURE" in case "$ARCHITECTURE" in
amd64) amd64)
@ -289,11 +289,11 @@ case $arches in
*) die "enable $ARCHITECTURE by running: sudo dpkg --add-architecture $ARCHITECTURE && sudo apt update" ;; *) die "enable $ARCHITECTURE by running: sudo dpkg --add-architecture $ARCHITECTURE && sudo apt update" ;;
esac esac
test "$(dpkg-query -f '${db:Status-Status}' -W "dpkg-dev")" = installed || test "$(dpkg-query -f '${db:Status-Status}' -W "dpkg-dev")" = installed \
die "please install dpkg-dev" || die "please install dpkg-dev"
dpkg-checkbuilddeps -d "autopkgtest, dosfstools, e2fsprogs, fdisk, mount, mtools, passwd, uidmap, libarchive13, systemd-boot-efi:$ARCHITECTURE $BINUTILS" /dev/null || dpkg-checkbuilddeps -d "autopkgtest, dosfstools, e2fsprogs, fdisk, mount, mtools, passwd, uidmap, libarchive13, systemd-boot-efi:$ARCHITECTURE $BINUTILS" /dev/null \
die "please install the required packages listed above" || die "please install the required packages listed above"
BOOTSTUB="/usr/lib/systemd/boot/efi/linux${EFIIMG#boot}.stub" BOOTSTUB="/usr/lib/systemd/boot/efi/linux${EFIIMG#boot}.stub"
@ -327,7 +327,8 @@ set -- \
--architecture="$ARCHITECTURE" --architecture="$ARCHITECTURE"
case $MIRROR in http://snapshot.debian.org/archive/* | https://snapshot.debian.org/archive/*) case $MIRROR in http://snapshot.debian.org/archive/* | https://snapshot.debian.org/archive/*)
set -- "$@" --aptopt='Acquire::Check-Valid-Until "false"';; set -- "$@" --aptopt='Acquire::Check-Valid-Until "false"'
;;
esac esac
EXT_FEATURES= EXT_FEATURES=
@ -373,7 +374,7 @@ mmdebstrap "$@" | {
set -- "$@" -O "$EXT_FEATURES" set -- "$@" -O "$EXT_FEATURES"
fi fi
EXTOPTS="offset=$(((FAT_OFFSET_SECTORS + FAT_SIZE_SECTORS) * 512))" EXTOPTS="offset=$(((FAT_OFFSET_SECTORS + FAT_SIZE_SECTORS) * 512))"
if test -n "${SOURCE_DATE_EPOCH:-}"; then if test -n "${SOURCE_DATE_EPOCH-}"; then
uuid="$(uuidgen --sha1 --namespace="$(uuidgen --sha1 --namespace='@dns' --name mister-muffin.de)" --name "$SOURCE_DATE_EPOCH")" uuid="$(uuidgen --sha1 --namespace="$(uuidgen --sha1 --namespace='@dns' --name mister-muffin.de)" --name "$SOURCE_DATE_EPOCH")"
set -- "$@" -U "$uuid" set -- "$@" -U "$uuid"
EXTOPTS="$EXTOPTS,hash_seed=$uuid" EXTOPTS="$EXTOPTS,hash_seed=$uuid"
@ -383,7 +384,6 @@ mmdebstrap "$@" | {
/sbin/mke2fs "$@" /sbin/mke2fs "$@"
} }
echo "root=LABEL=autopkgtestvm rw console=ttyS0" >"$WORKDIR/cmdline" echo "root=LABEL=autopkgtestvm rw console=ttyS0" >"$WORKDIR/cmdline"
align_size() { align_size() {
@ -399,8 +399,8 @@ test "$RELEASE" = jessie -a "$((alignment))" -lt "$((1024*1024))" && {
} }
lastoffset=0 lastoffset=0
# shellcheck disable=SC2034 # unused variables serve documentation # shellcheck disable=SC2034 # unused variables serve documentation
lastoffset="$("${GNU_PREFIX}objdump" -h "$BOOTSTUB" | lastoffset="$("${GNU_PREFIX}objdump" -h "$BOOTSTUB" \
while read -r idx name size vma lma fileoff algn behind; do | while read -r idx name size vma lma fileoff algn behind; do
test -z "$behind" -a "${algn#"2**"}" != "$algn" || continue test -z "$behind" -a "${algn#"2**"}" != "$algn" || continue
offset=$((0x$vma + 0x$size)) offset=$((0x$vma + 0x$size))
test "$offset" -gt "$lastoffset" || continue test "$offset" -gt "$lastoffset" || continue

View file

@ -26,13 +26,22 @@ done
# - Read fd 3 and let the group exit with that value # - Read fd 3 and let the group exit with that value
# - Redirect fd 4 to stdout # - Redirect fd 4 to stdout
ret=0 ret=0
{ { { { {
ret=0; {
( exec 3>&- 4>&-; env --chdir=./shared $SUDO sh -x ./test.sh 2>&1) || ret=$?; {
echo $ret >&3; {
} | tee shared/output.txt >&4; ret=0
} 3>&1; (
} | { read -r xs; exit "$xs"; } exec 3>&- 4>&-
env --chdir=./shared $SUDO sh -x ./test.sh 2>&1
) || ret=$?
echo $ret >&3
} | tee shared/output.txt >&4
} 3>&1
} | {
read -r xs
exit "$xs"
}
} 4>&1 || ret=$? } 4>&1 || ret=$?
if [ "$ret" -ne 0 ]; then if [ "$ret" -ne 0 ]; then
echo "test.sh failed" echo "test.sh failed"

View file

@ -218,8 +218,11 @@ Lastly, shift user id and group id of each entry by the value given by the
skip = False skip = False
if not hasattr(args, "pathfilter"): if not hasattr(args, "pathfilter"):
return False return False
# normalize path and make it absolute by stripping off all leading
# dots and slashes and then prepending a slash
name = "/" + member.name.lstrip("./")
for t, r in args.pathfilter: for t, r in args.pathfilter:
if r.match(member.name[1:]) is not None: if r.match(name) is not None:
if t == "path_include": if t == "path_include":
skip = False skip = False
else: else:
@ -230,7 +233,7 @@ Lastly, shift user id and group id of each entry by the value given by the
continue continue
prefix = prefix_prog.sub(r"\1", r.pattern) prefix = prefix_prog.sub(r"\1", r.pattern)
prefix = prefix.rstrip("/") prefix = prefix.rstrip("/")
if member.name[1:].startswith(prefix): if name.startswith(prefix):
return False return False
return skip return skip

View file

@ -6,4 +6,7 @@ trap "rm -f /tmp/debian-chroot.tar" EXIT INT TERM
--include '?narrow(?archive(^{{ DIST }}$),?essential)' \ --include '?narrow(?archive(^{{ DIST }}$),?essential)' \
--include apt \ --include apt \
{{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }} {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
{ tar -tf /tmp/debian-chroot.tar; echo ./var/lib/apt/extended_states; } | sort | diff -u tar1.txt - {
tar -tf /tmp/debian-chroot.tar
echo ./var/lib/apt/extended_states
} | sort | diff -u tar1.txt -

View file

@ -5,7 +5,7 @@ if [ ! -e /mmdebstrap-testenv ]; then
echo "this test modifies the system and should only be run inside a container" >&2 echo "this test modifies the system and should only be run inside a container" >&2
exit 1 exit 1
fi fi
apt-get remove --yes qemu-user-static binfmt-support qemu-user apt-get remove --yes qemu-user-binfmt binfmt-support qemu-user
# the following is not necessary anymore since systemd-binfmt # the following is not necessary anymore since systemd-binfmt
# successfully disables support upon removal of qemu-user with # successfully disables support upon removal of qemu-user with
# the upload of src:systemd 251.2-4: https://bugs.debian.org/1012163 # the upload of src:systemd 251.2-4: https://bugs.debian.org/1012163

View file

@ -31,7 +31,7 @@ AUTOPROXY=
eval "$(apt-config shell AUTOPROXY Acquire::http::Proxy-Auto-Detect)" eval "$(apt-config shell AUTOPROXY Acquire::http::Proxy-Auto-Detect)"
if [ -n "$AUTOPROXY" ] && [ -x "$AUTOPROXY" ] && [ -e /tmp/.auto-apt-proxy-0 ]; then if [ -n "$AUTOPROXY" ] && [ -x "$AUTOPROXY" ] && [ -e /tmp/.auto-apt-proxy-0 ]; then
TMP_APT_CONFIG=$(mktemp) TMP_APT_CONFIG=$(mktemp)
echo "Dir \"/dev/null\";" > "$TMP_APT_CONFIG" echo 'Dir "/dev/null";' >"$TMP_APT_CONFIG"
chmod 644 "$TMP_APT_CONFIG" chmod 644 "$TMP_APT_CONFIG"
fi fi

View file

@ -6,6 +6,9 @@ trap "rm -f /tmp/debian-chroot.tar" EXIT INT TERM
--include "$(tr '\n' ',' <pkglist.txt)" \ --include "$(tr '\n' ',' <pkglist.txt)" \
--aptopt='APT::Solver "aspcud"' \ --aptopt='APT::Solver "aspcud"' \
{{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }} {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
{ tar -tf /tmp/debian-chroot.tar; echo ./var/lib/apt/extended_states; } | sort \ {
tar -tf /tmp/debian-chroot.tar
echo ./var/lib/apt/extended_states
} | sort \
| grep -v '^./etc/apt/apt.conf.d/99mmdebstrap$' \ | grep -v '^./etc/apt/apt.conf.d/99mmdebstrap$' \
| diff -u tar1.txt - | diff -u tar1.txt -

View file

@ -109,6 +109,7 @@ if [ "{{ VARIANT }}" = "-" ]; then
rm /tmp/debian-{{ DIST }}-debootstrap/var/lib/systemd/catalog/database rm /tmp/debian-{{ DIST }}-debootstrap/var/lib/systemd/catalog/database
rm /tmp/debian-{{ DIST }}-mm/var/lib/systemd/catalog/database rm /tmp/debian-{{ DIST }}-mm/var/lib/systemd/catalog/database
case {{ DIST }} in oldstable | stable)
cap=$(chroot /tmp/debian-{{ DIST }}-debootstrap /sbin/getcap /bin/ping) cap=$(chroot /tmp/debian-{{ DIST }}-debootstrap /sbin/getcap /bin/ping)
expected="/bin/ping cap_net_raw=ep" expected="/bin/ping cap_net_raw=ep"
if [ "$cap" != "$expected" ]; then if [ "$cap" != "$expected" ]; then
@ -122,7 +123,10 @@ if [ "{{ VARIANT }}" = "-" ]; then
echo "but mmdebstrap produced: $cap" >&2 echo "but mmdebstrap produced: $cap" >&2
exit 1 exit 1
fi fi
;;
esac
fi fi
rm /tmp/debian-{{ DIST }}-mm/var/cache/apt/archives/lock rm /tmp/debian-{{ DIST }}-mm/var/cache/apt/archives/lock
rm /tmp/debian-{{ DIST }}-mm/var/lib/apt/extended_states rm /tmp/debian-{{ DIST }}-mm/var/lib/apt/extended_states
rm /tmp/debian-{{ DIST }}-mm/var/lib/apt/lists/lock rm /tmp/debian-{{ DIST }}-mm/var/lib/apt/lists/lock
@ -215,7 +219,10 @@ case {{ DIST }} in testing|unstable)
case $oldlink in case $oldlink in
/usr/*) : ;; /usr/*) : ;;
/*) oldlink="/usr$oldlink" ;; /*) oldlink="/usr$oldlink" ;;
*) echo unexpected >&2; exit 1 ;; *)
echo unexpected >&2
exit 1
;;
esac esac
ln -sf "$oldlink" "/tmp/debian-{{ DIST }}-$d/etc/systemd/system/$f" ln -sf "$oldlink" "/tmp/debian-{{ DIST }}-$d/etc/systemd/system/$f"
done done

View file

@ -26,7 +26,6 @@ fi
[ "$(id -u)" -eq 0 ] [ "$(id -u)" -eq 0 ]
[ -e "/proc/sys/fs/binfmt_misc/qemu-$(deb2qemu "$arch")" ] [ -e "/proc/sys/fs/binfmt_misc/qemu-$(deb2qemu "$arch")" ]
# we need --hook-dir=./hooks/merged-usr because usrmerge does not understand # we need --hook-dir=./hooks/merged-usr because usrmerge does not understand
# DPKG_ROOT # DPKG_ROOT
# #
@ -53,8 +52,7 @@ for INCLUDE in '' 'apt' 'systemd-sysv'; do
# * /var/lib/dpkg/triggers -- #990712 # * /var/lib/dpkg/triggers -- #990712
# * /var/cache/debconf/*.dat-old -- needs investigation # * /var/cache/debconf/*.dat-old -- needs investigation
for tar in root chrootless; do for tar in root chrootless; do
<"/tmp/$tar.tar" \ ./tarfilter <"/tmp/$tar.tar" \
./tarfilter \
--path-exclude=/var/cache/debconf/config.dat-old \ --path-exclude=/var/cache/debconf/config.dat-old \
--path-exclude=/var/cache/debconf/templates.dat-old \ --path-exclude=/var/cache/debconf/templates.dat-old \
--path-exclude=/etc/ld.so.cache \ --path-exclude=/etc/ld.so.cache \

View file

@ -38,7 +38,8 @@ $prefix {{ CMD }} --mode={{ MODE }} --variant=apt --architectures="$foreign_arch
{{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }} {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
# we ignore differences between architectures by ignoring some files # we ignore differences between architectures by ignoring some files
# and renaming others # and renaming others
{ tar -tf /tmp/debian-chroot.tar \ {
tar -tf /tmp/debian-chroot.tar \
| grep -v '^\./usr/bin/i386$' \ | grep -v '^\./usr/bin/i386$' \
| grep -v '^\./usr/bin/x86_64$' \ | grep -v '^\./usr/bin/x86_64$' \
| grep -v '^\./lib64$' \ | grep -v '^\./lib64$' \
@ -53,10 +54,10 @@ $prefix {{ CMD }} --mode={{ MODE }} --variant=apt --architectures="$foreign_arch
| grep -v '^\./usr/share/man/man8/i386\.8\.gz$' \ | grep -v '^\./usr/share/man/man8/i386\.8\.gz$' \
| grep -v '^\./usr/share/man/man8/x86_64\.8\.gz$' \ | grep -v '^\./usr/share/man/man8/x86_64\.8\.gz$' \
| sed "s/$foreign_gnu/$native_gnu/" \ | sed "s/$foreign_gnu/$native_gnu/" \
| sed "s/$foreign_arch/$native_arch/"; | sed "s/$foreign_arch/$native_arch/"
} | sort >/tmp/tar2.txt } | sort >/tmp/tar2.txt
{ < tar1.txt \ {
grep -v '^\./usr/bin/i386$' \ grep <tar1.txt -v '^\./usr/bin/i386$' \
| grep -v '^\./usr/bin/x86_64$' \ | grep -v '^\./usr/bin/x86_64$' \
| grep -v '^\./lib32$' \ | grep -v '^\./lib32$' \
| grep -v '^\./lib64$' \ | grep -v '^\./lib64$' \
@ -72,6 +73,6 @@ $prefix {{ CMD }} --mode={{ MODE }} --variant=apt --architectures="$foreign_arch
| grep -v "^\\./usr/lib/$native_gnu/perl/5\\.[0-9][.0-9]\\+/.*\\.ph$" \ | grep -v "^\\./usr/lib/$native_gnu/perl/5\\.[0-9][.0-9]\\+/.*\\.ph$" \
| grep -v "^\\./usr/share/doc/[^/]\\+/changelog\\(\\.Debian\\)\\?\\.$native_arch\\.gz$" \ | grep -v "^\\./usr/share/doc/[^/]\\+/changelog\\(\\.Debian\\)\\?\\.$native_arch\\.gz$" \
| grep -v '^\./usr/share/man/man8/i386\.8\.gz$' \ | grep -v '^\./usr/share/man/man8/i386\.8\.gz$' \
| grep -v '^\./usr/share/man/man8/x86_64\.8\.gz$'; | grep -v '^\./usr/share/man/man8/x86_64\.8\.gz$'
} | sort | diff -u - /tmp/tar2.txt >&2 } | sort | diff -u - /tmp/tar2.txt >&2
rm /tmp/debian-chroot.tar /tmp/tar2.txt rm /tmp/debian-chroot.tar /tmp/tar2.txt

View file

@ -18,7 +18,7 @@ prefix="runuser -u ${SUDO_USER:-user} --"
quote() { printf %s\\n "$1" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/'/"; } quote() { printf %s\\n "$1" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/'/"; }
homedir=$($prefix sh -c 'cd && pwd') homedir=$($prefix sh -c 'cd && pwd')
# apt:test/integration/test-apt-key # apt:test/integration/test-apt-key
TMPDIR_ADD="This is fü\$\$ing cràzy, \$(apt -v)\$!" TMPDIR_ADD='This is fü$$ing cràzy, $(apt -v)$!'
$prefix mkdir "$homedir/$TMPDIR_ADD" $prefix mkdir "$homedir/$TMPDIR_ADD"
# make sure the unshared user can traverse into the TMPDIR # make sure the unshared user can traverse into the TMPDIR
chmod 711 "$homedir" chmod 711 "$homedir"

View file

@ -40,6 +40,6 @@ tar -C /tmp/debian-chroot --one-file-system -c . \
tar -t \ tar -t \
| grep -v "^./etc/apt/sources.list.d/0000deb822.sources$" \ | grep -v "^./etc/apt/sources.list.d/0000deb822.sources$" \
| grep -v "^./etc/apt/sources.list.d/0001main.list$" \ | grep -v "^./etc/apt/sources.list.d/0001main.list$" \
| grep -v "^./etc/apt/sources.list.d/0002sources.list"; | grep -v "^./etc/apt/sources.list.d/0002sources.list"
printf "./etc/apt/sources.list\n"; printf "./etc/apt/sources.list\n"
} | sort | diff -u tar1.txt - } | sort | diff -u tar1.txt -

View file

@ -39,6 +39,6 @@ tar -C /tmp/debian-chroot --one-file-system -c . \
tar -t \ tar -t \
| grep -v "^./etc/apt/sources.list.d/0000deb822.sources$" \ | grep -v "^./etc/apt/sources.list.d/0000deb822.sources$" \
| grep -v "^./etc/apt/sources.list.d/0001main.sources$" \ | grep -v "^./etc/apt/sources.list.d/0001main.sources$" \
| grep -v "^./etc/apt/sources.list.d/0002sources.list$"; | grep -v "^./etc/apt/sources.list.d/0002sources.list$"
printf "./etc/apt/sources.list\n"; printf "./etc/apt/sources.list\n"
} | sort | diff -u tar1.txt - } | sort | diff -u tar1.txt -

View file

@ -7,4 +7,8 @@ echo no-pager > /tmp/config
printf 'path-exclude=/usr/share/doc/*\nno-pager\npath-include=/usr/share/doc/dpkg/copyright\n' | cmp /tmp/debian-chroot/etc/dpkg/dpkg.cfg.d/99mmdebstrap - printf 'path-exclude=/usr/share/doc/*\nno-pager\npath-include=/usr/share/doc/dpkg/copyright\n' | cmp /tmp/debian-chroot/etc/dpkg/dpkg.cfg.d/99mmdebstrap -
rm /tmp/debian-chroot/etc/dpkg/dpkg.cfg.d/99mmdebstrap rm /tmp/debian-chroot/etc/dpkg/dpkg.cfg.d/99mmdebstrap
tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort >tar2.txt tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort >tar2.txt
{ grep -v '^./usr/share/doc/.' tar1.txt; echo ./usr/share/doc/dpkg/; echo ./usr/share/doc/dpkg/copyright; } | sort | diff -u - tar2.txt {
grep -v '^./usr/share/doc/.' tar1.txt
echo ./usr/share/doc/dpkg/
echo ./usr/share/doc/dpkg/copyright
} | sort | diff -u - tar2.txt

View file

@ -12,18 +12,24 @@ EOF
SCRIPT SCRIPT
chmod +x /tmp/checkeatmydata.sh chmod +x /tmp/checkeatmydata.sh
# first four bytes: magic # first four bytes: magic
elfheader="\\177ELF" elfheader='\177ELF'
# fifth byte: bits # fifth byte: bits
case "$(dpkg-architecture -qDEB_HOST_ARCH_BITS)" in case "$(dpkg-architecture -qDEB_HOST_ARCH_BITS)" in
32) elfheader="$elfheader\\001" ;; 32) elfheader="$elfheader\\001" ;;
64) elfheader="$elfheader\\002" ;; 64) elfheader="$elfheader\\002" ;;
*) echo "bits not supported"; exit 1;; *)
echo "bits not supported"
exit 1
;;
esac esac
# sixth byte: endian # sixth byte: endian
case "$(dpkg-architecture -qDEB_HOST_ARCH_ENDIAN)" in case "$(dpkg-architecture -qDEB_HOST_ARCH_ENDIAN)" in
little) elfheader="$elfheader\\001" ;; little) elfheader="$elfheader\\001" ;;
big) elfheader="$elfheader\\002" ;; big) elfheader="$elfheader\\002" ;;
*) echo "endian not supported"; exit 1;; *)
echo "endian not supported"
exit 1
;;
esac esac
# seventh and eigth byte: elf version (1) and abi (unset) # seventh and eigth byte: elf version (1) and abi (unset)
elfheader="$elfheader\\001\\000" elfheader="$elfheader\\001\\000"

13
tests/empty-suite Normal file
View file

@ -0,0 +1,13 @@
#!/bin/sh
set -eu
export LC_ALL=C.UTF-8
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
trap "rm -f /tmp/debian-chroot.tar" EXIT INT TERM
{{ CMD }} --variant={{ VARIANT }} --verbose \
--setup-hook='echo deb {{ MIRROR }} {{ DIST }} main >> "$1"/etc/apt/sources.list' \
'' /tmp/debian-chroot.tar
cmp ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.tar /tmp/debian-chroot.tar \
|| diffoscope ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.tar /tmp/debian-chroot.tar

View file

@ -6,11 +6,12 @@ if [ ! -e /mmdebstrap-testenv ]; then
exit 1 exit 1
fi fi
# remove qemu just to be sure # remove qemu just to be sure
apt-get remove --yes qemu-user-static binfmt-support qemu-user apt-get remove --yes qemu-user-binfmt binfmt-support qemu-user
{{ CMD }} --mode={{ MODE }} --variant=apt --architectures=i386 {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }} {{ CMD }} --mode={{ MODE }} --variant=apt --architectures=i386 {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
# we ignore differences between architectures by ignoring some files # we ignore differences between architectures by ignoring some files
# and renaming others # and renaming others
{ tar -tf /tmp/debian-chroot.tar \ {
tar -tf /tmp/debian-chroot.tar \
| grep -v '^\./usr/bin/i386$' \ | grep -v '^\./usr/bin/i386$' \
| grep -v '^\./usr/lib/ld-linux\.so\.2$' \ | grep -v '^\./usr/lib/ld-linux\.so\.2$' \
| grep -v '^\./usr/lib/i386-linux-gnu/ld-linux\.so\.2$' \ | grep -v '^\./usr/lib/i386-linux-gnu/ld-linux\.so\.2$' \
@ -20,10 +21,10 @@ apt-get remove --yes qemu-user-static binfmt-support qemu-user
| grep -v '^\./usr/share/doc/[^/]\+/changelog\(\.Debian\)\?\.i386\.gz$' \ | grep -v '^\./usr/share/doc/[^/]\+/changelog\(\.Debian\)\?\.i386\.gz$' \
| sed 's/i386-linux-gnu/x86_64-linux-gnu/' \ | sed 's/i386-linux-gnu/x86_64-linux-gnu/' \
| sed 's/i386/amd64/' \ | sed 's/i386/amd64/' \
| sed 's/\/stubs-32.ph$/\/stubs-64.ph/'; | sed 's/\/stubs-32.ph$/\/stubs-64.ph/'
} | sort >tar2.txt } | sort >tar2.txt
{ < tar1.txt \ {
grep -v '^\./usr/bin/i386$' \ grep <tar1.txt -v '^\./usr/bin/i386$' \
| grep -v '^\./usr/bin/x86_64$' \ | grep -v '^\./usr/bin/x86_64$' \
| grep -v '^\./usr/lib32/$' \ | grep -v '^\./usr/lib32/$' \
| grep -v '^\./lib32$' \ | grep -v '^\./lib32$' \
@ -36,6 +37,6 @@ apt-get remove --yes qemu-user-static binfmt-support qemu-user
| grep -v '^\./usr/lib/x86_64-linux-gnu/libmvec\.so\.1$' \ | grep -v '^\./usr/lib/x86_64-linux-gnu/libmvec\.so\.1$' \
| grep -v '^\./usr/share/doc/[^/]\+/changelog\(\.Debian\)\?\.amd64\.gz$' \ | grep -v '^\./usr/share/doc/[^/]\+/changelog\(\.Debian\)\?\.amd64\.gz$' \
| grep -v '^\./usr/share/man/man8/i386\.8\.gz$' \ | grep -v '^\./usr/share/man/man8/i386\.8\.gz$' \
| grep -v '^\./usr/share/man/man8/x86_64\.8\.gz$'; | grep -v '^\./usr/share/man/man8/x86_64\.8\.gz$'
} | sort | diff -u - tar2.txt >&2 } | sort | diff -u - tar2.txt >&2
rm /tmp/debian-chroot.tar rm /tmp/debian-chroot.tar

View file

@ -27,7 +27,10 @@ export LC_ALL=C.UTF-8
--architectures="$native_arch,$foreign_arch" \ --architectures="$native_arch,$foreign_arch" \
--include="libmagic-mgc:$foreign_arch" \ --include="libmagic-mgc:$foreign_arch" \
{{ DIST }} /tmp/debian-chroot {{ MIRROR }} {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
{ echo "$native_arch"; echo "$foreign_arch"; } | cmp /tmp/debian-chroot/var/lib/dpkg/arch - {
echo "$native_arch"
echo "$foreign_arch"
} | cmp /tmp/debian-chroot/var/lib/dpkg/arch -
rm /tmp/debian-chroot/usr/lib/file/magic.mgc rm /tmp/debian-chroot/usr/lib/file/magic.mgc
rm /tmp/debian-chroot/usr/share/doc/libmagic-mgc/README.Debian rm /tmp/debian-chroot/usr/share/doc/libmagic-mgc/README.Debian
rm -f /tmp/debian-chroot/usr/share/doc/libmagic-mgc/"changelog.Debian.$foreign_arch.gz" rm -f /tmp/debian-chroot/usr/share/doc/libmagic-mgc/"changelog.Debian.$foreign_arch.gz"

View file

@ -28,7 +28,10 @@ export LC_ALL=C.UTF-8
--architectures="$foreign_arch" \ --architectures="$foreign_arch" \
--include="libmagic-mgc:$foreign_arch" \ --include="libmagic-mgc:$foreign_arch" \
{{ DIST }} /tmp/debian-chroot {{ MIRROR }} {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
{ echo "$native_arch"; echo "$foreign_arch"; } | cmp /tmp/debian-chroot/var/lib/dpkg/arch - {
echo "$native_arch"
echo "$foreign_arch"
} | cmp /tmp/debian-chroot/var/lib/dpkg/arch -
rm /tmp/debian-chroot/usr/lib/file/magic.mgc rm /tmp/debian-chroot/usr/lib/file/magic.mgc
rm /tmp/debian-chroot/usr/share/doc/libmagic-mgc/README.Debian rm /tmp/debian-chroot/usr/share/doc/libmagic-mgc/README.Debian
rm -f /tmp/debian-chroot/usr/share/doc/libmagic-mgc/"changelog.Debian.$foreign_arch.gz" rm -f /tmp/debian-chroot/usr/share/doc/libmagic-mgc/"changelog.Debian.$foreign_arch.gz"

View file

@ -14,7 +14,7 @@ case {{ FORMAT }} in tar|squashfs|ext2|ext4) : ;; *) exit 1;; esac
# https://lore.kernel.org/linux-ext4/171484520952.2626447.2160419274451668597@localhost/T/#t # https://lore.kernel.org/linux-ext4/171484520952.2626447.2160419274451668597@localhost/T/#t
mv /tmp/mmdebstrap-{{ DIST }}-{{ VARIANT }}.{{ FORMAT }} ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.{{ FORMAT }} mv /tmp/mmdebstrap-{{ DIST }}-{{ VARIANT }}.{{ FORMAT }} ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.{{ FORMAT }}
if [ "{{ FORMAT }}" = tar ]; then if [ "{{ FORMAT }}" = tar ]; then
printf 'ustar ' | cmp --bytes=6 --ignore-initial=257:0 ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.tar - printf 'ustar\0' | cmp --bytes=6 --ignore-initial=257:0 ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.tar -
elif [ "{{ FORMAT }}" = squashfs ]; then elif [ "{{ FORMAT }}" = squashfs ]; then
printf 'hsqs' | cmp --bytes=4 ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.squashfs - printf 'hsqs' | cmp --bytes=4 ./cache/mmdebstrap-{{ DIST }}-{{ VARIANT }}.squashfs -
elif [ "{{ FORMAT }}" = ext2 ]; then elif [ "{{ FORMAT }}" = ext2 ]; then

View file

@ -17,19 +17,19 @@ fi
# test this for both unshare and root mode because the code paths creating # test this for both unshare and root mode because the code paths creating
# entries in /dev are different depending on whether mknod is available or not # entries in /dev are different depending on whether mknod is available or not
$prefix {{ CMD }} --mode={{ MODE }} --variant=apt --skip=output/dev {{ DIST }} - {{ MIRROR }} | { $prefix {{ CMD }} --mode={{ MODE }} --variant=apt --skip=output/dev {{ DIST }} - {{ MIRROR }} | {
tar -t; tar -t
echo ./dev/console; echo ./dev/console
echo ./dev/fd; echo ./dev/fd
echo ./dev/full; echo ./dev/full
echo ./dev/null; echo ./dev/null
echo ./dev/ptmx; echo ./dev/ptmx
echo ./dev/pts/; echo ./dev/pts/
echo ./dev/random; echo ./dev/random
echo ./dev/shm/; echo ./dev/shm/
echo ./dev/stderr; echo ./dev/stderr
echo ./dev/stdin; echo ./dev/stdin
echo ./dev/stdout; echo ./dev/stdout
echo ./dev/tty; echo ./dev/tty
echo ./dev/urandom; echo ./dev/urandom
echo ./dev/zero; echo ./dev/zero
} | sort | diff -u tar1.txt - } | sort | diff -u tar1.txt -

View file

@ -18,13 +18,13 @@ fi
# entries in /dev are different depending on whether mknod is available or not # entries in /dev are different depending on whether mknod is available or not
$prefix {{ CMD }} --mode={{ MODE }} --variant=apt --skip=output/mknod \ $prefix {{ CMD }} --mode={{ MODE }} --variant=apt --skip=output/mknod \
{{ DIST }} - {{ MIRROR }} | { {{ DIST }} - {{ MIRROR }} | {
tar -t; tar -t
echo ./dev/console; echo ./dev/console
echo ./dev/full; echo ./dev/full
echo ./dev/null; echo ./dev/null
echo ./dev/ptmx; echo ./dev/ptmx
echo ./dev/random; echo ./dev/random
echo ./dev/tty; echo ./dev/tty
echo ./dev/urandom; echo ./dev/urandom
echo ./dev/zero; echo ./dev/zero
} | sort | diff -u tar1.txt - } | sort | diff -u tar1.txt -

View file

@ -8,9 +8,21 @@ mkdir /tmp/root/real
run_testA() { run_testA() {
echo content >/tmp/foo echo content >/tmp/foo
# shellcheck disable=SC2094 # shellcheck disable=SC2094
{ { { {{ CMD }} --hook-helper /tmp/root root setup '' 1 upload /tmp/foo "$1" < /tmp/myfifo 3>&-; echo $? >&3; printf "\\000\\000adios"; {
} | {{ CMD }} --hook-listener 1 3>&- >/tmp/myfifo; echo $?; } 3>&1; {
} | { read -r xs1; [ "$xs1" -eq 0 ]; read -r xs2; [ "$xs2" -eq 0 ]; } {
{{ CMD }} --hook-helper /tmp/root root setup '' 1 upload /tmp/foo "$1" </tmp/myfifo 3>&-
echo $? >&3
printf '\000\000adios'
} | {{ CMD }} --hook-listener 1 3>&- >/tmp/myfifo
echo $?
} 3>&1
} | {
read -r xs1
[ "$xs1" -eq 0 ]
read -r xs2
[ "$xs2" -eq 0 ]
}
echo content | diff -u - /tmp/root/real/foo echo content | diff -u - /tmp/root/real/foo
rm /tmp/foo rm /tmp/foo
rm /tmp/root/real/foo rm /tmp/root/real/foo

View file

@ -1,58 +1,111 @@
#!/bin/sh #!/bin/sh
set -eu set -eu
export LC_ALL=C.UTF-8 export LC_ALL=C.UTF-8
if [ ! -e /mmdebstrap-testenv ]; then
echo "this test modifies the system and should only be run inside a container" >&2 trap "rm -f /tmp/mkpaxtar.pl /tmp/orig.tar /tmp/file /tmp/expected /tmp/filtered.tar" EXIT INT TERM
exit 1
fi cat <<'END' >/tmp/mkpaxtar.pl
trap "rm -f /tmp/debian-chroot.tar /tmp/debian-chroot-shifted.tar /tmp/debian-chroot.txt /tmp/debian-chroot-shiftedback.tar /tmp/expected; rm -rf /tmp/debian-chroot" EXIT INT TERM #!/usr/bin/env perl
useradd --home-dir /home/user --create-home user
echo user:100000:65536 | cmp /etc/subuid - use strict;
echo user:100000:65536 | cmp /etc/subgid - use warnings;
# include iputils-ping so that we can verify that tarfilter does not remove
# extended attributes my @entries = (
# run through tarshift no-op to create a tarball that should be bit-by-bit # filename mode type content
# identical to a round trip through "tarfilter --idshift X" and "tarfilter --idshift -X" ['./PaxHeaders/file', oct(644), 'x', "57 SCHILY.xattr.security.capability=\x01\0\0\x02\0\x20\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x0a"],
runuser -u user -- {{ CMD }} --mode=unshare --variant=apt --include=iputils-ping {{ DIST }} - {{ MIRROR }} \ ['./file', oct(644), 0, 'test'],
| ./tarfilter --idshift 0 > /tmp/debian-chroot.tar );
my $num_entries = 0;
foreach my $file (@entries) {
my ($fname, $mode, $type, $content) = @{$file};
my $entry = pack(
'a100 a8 a8 a8 a12 a12 A8 a1 a100 a6 a2 a32 a32 a8 a8 a155 x12',
$fname,
sprintf('%07o', $mode),
sprintf('%07o', 0), # uid
sprintf('%07o', 0), # gid
sprintf('%011o', length $content), # size
sprintf('%011o', 0), # mtime
'', # checksum
$type,
'', # linkname
"ustar", # magic
"00", # version
'', # username
'', # groupname
'', # dev major
'', # dev minor
'', # prefix
);
# compute and insert checksum
substr($entry, 148, 7)
= sprintf("%06o\0", unpack("%16C*", $entry));
print $entry;
$num_entries += 1;
if (length $content) {
print(pack 'a512', $content);
$num_entries += 1;
}
}
# https://www.gnu.org/software/tar/manual/html_node/Standard.html
#
# Physically, an archive consists of a series of file entries terminated by an
# end-of-archive entry, which consists of two 512 blocks of zero bytes. At the
# end of the archive file there are two 512-byte blocks filled with binary
# zeros as an end-of-file marker.
print(pack 'a512', '');
print(pack 'a512', '');
$num_entries += 2;
# https://www.gnu.org/software/tar/manual/html_section/tar_76.html
#
# Some devices requires that all write operations be a multiple of a certain
# size, and so, tar pads the archive out to the next record boundary.
#
# The default blocking factor is 20. With a block size of 512 bytes, we get a
# record size of 10240.
for (my $i = $num_entries ; $i < 20 ; $i++) {
print(pack 'a512', '');
}
END
MMTARFILTER=
[ -x /usr/bin/mmtarfilter ] && MMTARFILTER=/usr/bin/mmtarfilter
[ -x ./tarfilter ] && MMTARFILTER=./tarfilter
perl /tmp/mkpaxtar.pl | "$MMTARFILTER" >/tmp/orig.tar
# make sure that xattrs are set in the original tarball # make sure that xattrs are set in the original tarball
mkdir /tmp/debian-chroot tar --xattrs --xattrs-include='*' --directory /tmp/ -xf /tmp/orig.tar ./file
tar --xattrs --xattrs-include='*' --directory /tmp/debian-chroot -xf /tmp/debian-chroot.tar ./usr/bin/ping echo "/tmp/file cap_net_raw=ep" >/tmp/expected
echo "/tmp/debian-chroot/usr/bin/ping cap_net_raw=ep" > /tmp/expected getcap /tmp/file | diff -u /tmp/expected - >&2
getcap /tmp/debian-chroot/usr/bin/ping | diff -u /tmp/expected - >&2 # make sure that the file content is as expected
rm /tmp/debian-chroot/usr/bin/ping printf test | diff -u /tmp/file - >&2
rmdir /tmp/debian-chroot/usr/bin # make sure that uid/gid are as expected in the original tarball
rmdir /tmp/debian-chroot/usr echo "0 0 644" >/tmp/expected
rmdir /tmp/debian-chroot stat --format="%u %g %a" /tmp/file | diff -u /tmp/expected - >&2
# shift the uid/gid forward by 100000 and backward by 100000 rm /tmp/file
./tarfilter --idshift 100000 < /tmp/debian-chroot.tar > /tmp/debian-chroot-shifted.tar # tarball must be bit by-bit-identical after round-trip
./tarfilter --idshift -100000 < /tmp/debian-chroot-shifted.tar > /tmp/debian-chroot-shiftedback.tar "$MMTARFILTER" --idshift 0 </tmp/orig.tar >/tmp/filtered.tar
# the tarball before and after the roundtrip through tarfilter should be bit cmp /tmp/orig.tar /tmp/filtered.tar
# by bit identical
cmp /tmp/debian-chroot.tar /tmp/debian-chroot-shiftedback.tar # now shift uid/gid
# manually adjust uid/gid and compare "tar -t" output "$MMTARFILTER" --idshift 100000 </tmp/orig.tar >/tmp/filtered.tar
tar --numeric-owner -tvf /tmp/debian-chroot.tar \ # make sure that uid/gid are as expected in the filtered tarball
| sed 's# 42/0 # 100042/100000 #' \ tar --xattrs --xattrs-include='*' --directory /tmp/ -xf /tmp/filtered.tar ./file
| sed 's# 0/0 # 100000/100000 #' \ echo "100000 100000 644" >/tmp/expected
| sed 's# 0/5 # 100000/100005 #' \ stat --format="%u %g %a" /tmp/file | diff -u /tmp/expected - >&2
| sed 's# 0/8 # 100000/100008 #' \ rm /tmp/file
| sed 's# 0/42 # 100000/100042 #' \
| sed 's# 0/43 # 100000/100043 #' \ # now shift uid/gid back to create a round-trip
| sed 's# 0/50 # 100000/100050 #' \ "$MMTARFILTER" --idshift -100000 </tmp/filtered.tar >/tmp/filtered2.tar
| sed 's/ \+/ /g' \
> /tmp/debian-chroot.txt # the result must be identical to the original and will thus also include the
tar --numeric-owner -tvf /tmp/debian-chroot-shifted.tar \ # correct xattr information
| sed 's/ \+/ /g' \ cmp /tmp/orig.tar /tmp/filtered2.tar
| diff -u /tmp/debian-chroot.txt - >&2
mkdir /tmp/debian-chroot
tar --xattrs --xattrs-include='*' --directory /tmp/debian-chroot -xf /tmp/debian-chroot-shifted.tar
echo "100000 100000" > /tmp/expected
stat --format="%u %g" /tmp/debian-chroot/usr/bin/ping | diff -u /tmp/expected - >&2
echo "/tmp/debian-chroot/usr/bin/ping cap_net_raw=ep" > /tmp/expected
getcap /tmp/debian-chroot/usr/bin/ping | diff -u /tmp/expected - >&2
echo "0 0" > /tmp/expected
runuser -u user -- {{ CMD }} --unshare-helper /usr/sbin/chroot /tmp/debian-chroot stat --format="%u %g" /usr/bin/ping \
| diff -u /tmp/expected - >&2
echo "/usr/bin/ping cap_net_raw=ep" > /tmp/expected
runuser -u user -- {{ CMD }} --unshare-helper /usr/sbin/chroot /tmp/debian-chroot getcap /usr/bin/ping \
| diff -u /tmp/expected - >&2

View file

@ -8,7 +8,8 @@ fi
trap "rm -f /tmp/debian-chroot.tar" EXIT INT TERM trap "rm -f /tmp/debian-chroot.tar" EXIT INT TERM
rm /etc/resolv.conf /etc/hostname rm /etc/resolv.conf /etc/hostname
{{ CMD }} --mode={{ MODE }} --variant=apt {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }} {{ CMD }} --mode={{ MODE }} --variant=apt {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
{ tar -tf /tmp/debian-chroot.tar; {
printf "./etc/hostname\n"; tar -tf /tmp/debian-chroot.tar
printf "./etc/resolv.conf\n"; printf "./etc/hostname\n"
printf "./etc/resolv.conf\n"
} | sort | diff -u tar1.txt - } | sort | diff -u tar1.txt -

38
tests/zombie-reaping Normal file
View file

@ -0,0 +1,38 @@
#!/bin/sh
set -eu
export LC_ALL=C.UTF-8
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
[ {{ MODE }} = "unshare" ]
trap "rm -f /tmp/debian-chroot.tar" EXIT INT TERM
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
$prefix {{ CMD }} --mode={{ MODE }} --variant=apt \
--skip=output/dev \
--customize-hook='chroot "$1" sh -c "sleep 1m > /dev/null" &' \
{{ DIST }} - {{ MIRROR }} \
| "$MMTARFILTER" --path-exclude="/dev" \
>/tmp/debian-chroot.tar
origfilter() {
"$MMTARFILTER" <./cache/mmdebstrap-{{ DIST }}-apt.tar --path-exclude="/dev/*" --path-exclude="/dev"
}
origfilter | cmp - /tmp/debian-chroot.tar \
|| origfilter | diffoscope - /tmp/debian-chroot.tar