tests: drop qemu requirements for tests that only use it to create a user by defaulting to SUDO_USER
This commit is contained in:
parent
98aef0d023
commit
a2d5573749
23 changed files with 322 additions and 205 deletions
|
@ -271,14 +271,14 @@ def main():
|
||||||
tt = "qemu"
|
tt = "qemu"
|
||||||
elif test.get("Needs-QEMU", "false") == "true":
|
elif test.get("Needs-QEMU", "false") == "true":
|
||||||
tt = ("skip", "test needs QEMU")
|
tt = ("skip", "test needs QEMU")
|
||||||
|
elif mode == "unshare" and not have_unshare:
|
||||||
|
tt = ("skip", "test needs unshare")
|
||||||
elif test.get("Needs-Root", "false") == "true":
|
elif test.get("Needs-Root", "false") == "true":
|
||||||
tt = "sudo"
|
tt = "sudo"
|
||||||
elif mode == "auto" and not have_unshare:
|
elif mode == "auto" and not have_unshare:
|
||||||
tt = "sudo"
|
tt = "sudo"
|
||||||
elif mode == "root":
|
elif mode == "root":
|
||||||
tt = "sudo"
|
tt = "sudo"
|
||||||
elif mode == "unshare" and not have_unshare:
|
|
||||||
tt = ("skip", "test needs unshare")
|
|
||||||
else:
|
else:
|
||||||
tt = "null"
|
tt = "null"
|
||||||
tests.append((tt, name, dist, mode, variant, fmt))
|
tests.append((tt, name, dist, mode, variant, fmt))
|
||||||
|
|
30
coverage.txt
30
coverage.txt
|
@ -4,7 +4,7 @@ Variants: minbase buildd -
|
||||||
Needs-Root: true
|
Needs-Root: true
|
||||||
|
|
||||||
Test: as-debootstrap-unshare-wrapper
|
Test: as-debootstrap-unshare-wrapper
|
||||||
Needs-QEMU: true
|
Modes: unshare
|
||||||
|
|
||||||
Test: help
|
Test: help
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ Test: root-mode-inside-chroot
|
||||||
Needs-Root: true
|
Needs-Root: true
|
||||||
|
|
||||||
Test: root-mode-inside-unshare-chroot
|
Test: root-mode-inside-unshare-chroot
|
||||||
Needs-QEMU: true
|
Modes: unshare
|
||||||
|
|
||||||
Test: root-without-cap-sys-admin
|
Test: root-without-cap-sys-admin
|
||||||
Needs-Root: true
|
Needs-Root: true
|
||||||
|
@ -43,7 +43,8 @@ Test: mount-is-missing
|
||||||
Needs-QEMU: true
|
Needs-QEMU: true
|
||||||
|
|
||||||
Test: check-for-bit-by-bit-identical-format-output
|
Test: check-for-bit-by-bit-identical-format-output
|
||||||
Needs-QEMU: true
|
Needs-Root: true
|
||||||
|
Modes: unshare fakechroot
|
||||||
Formats: tar squashfs ext2
|
Formats: tar squashfs ext2
|
||||||
Variants: essential apt minbase buildd - standard
|
Variants: essential apt minbase buildd - standard
|
||||||
Skip-If:
|
Skip-If:
|
||||||
|
@ -51,6 +52,7 @@ Skip-If:
|
||||||
variant == "important" and dist == "oldstable" # /var/lib/systemd/catalog/database differs
|
variant == "important" and dist == "oldstable" # /var/lib/systemd/catalog/database differs
|
||||||
fmt == "squashfs" and dist == "oldstable" # squashfs-tools-ng is not available
|
fmt == "squashfs" and dist == "oldstable" # squashfs-tools-ng is not available
|
||||||
fmt == "ext2" and dist == "oldstable" # genext2fs does not support SOURCE_DATE_EPOCH
|
fmt == "ext2" and dist == "oldstable" # genext2fs does not support SOURCE_DATE_EPOCH
|
||||||
|
mode == "fakechroot" and variant in ["-", "standard"] # no extended attributes
|
||||||
|
|
||||||
Test: tarfilter-idshift
|
Test: tarfilter-idshift
|
||||||
Needs-QEMU: true
|
Needs-QEMU: true
|
||||||
|
@ -74,19 +76,21 @@ Test: missing-device-nodes-outside-the-chroot
|
||||||
Needs-QEMU: true
|
Needs-QEMU: true
|
||||||
|
|
||||||
Test: missing-dev-sys-proc-inside-the-chroot
|
Test: missing-dev-sys-proc-inside-the-chroot
|
||||||
Needs-QEMU: true
|
Modes: unshare
|
||||||
|
Variants: custom
|
||||||
|
|
||||||
Test: chroot-directory-not-accessible-by-apt-user
|
Test: chroot-directory-not-accessible-by-apt-user
|
||||||
Needs-Root: true
|
Needs-Root: true
|
||||||
|
|
||||||
Test: cwd-directory-not-accessible-by-unshared-user
|
Test: cwd-directory-not-accessible-by-unshared-user
|
||||||
Needs-QEMU: true
|
Needs-Root: true
|
||||||
|
Modes: unshare
|
||||||
|
|
||||||
Test: create-gzip-compressed-tarball
|
Test: create-gzip-compressed-tarball
|
||||||
Needs-QEMU: true
|
|
||||||
|
|
||||||
Test: custom-tmpdir
|
Test: custom-tmpdir
|
||||||
Needs-QEMU: true
|
Needs-Root: true
|
||||||
|
Modes: unshare
|
||||||
|
|
||||||
Test: xz-compressed-tarball
|
Test: xz-compressed-tarball
|
||||||
|
|
||||||
|
@ -233,7 +237,6 @@ Needs-Root: true
|
||||||
|
|
||||||
Test: special-hooks-with-mode-mode
|
Test: special-hooks-with-mode-mode
|
||||||
Modes: root unshare fakechroot
|
Modes: root unshare fakechroot
|
||||||
Needs-QEMU: true
|
|
||||||
|
|
||||||
Test: debootstrap-no-op-options
|
Test: debootstrap-no-op-options
|
||||||
Needs-Root: true
|
Needs-Root: true
|
||||||
|
@ -280,7 +283,6 @@ Variants: any
|
||||||
Modes: any
|
Modes: any
|
||||||
|
|
||||||
Test: unpack-doc-debian
|
Test: unpack-doc-debian
|
||||||
Needs-QEMU: true
|
|
||||||
Modes: any
|
Modes: any
|
||||||
Variants: extract
|
Variants: extract
|
||||||
|
|
||||||
|
@ -298,7 +300,6 @@ Skip-If:
|
||||||
Test: chrootless-fakeroot
|
Test: chrootless-fakeroot
|
||||||
Variants: essential
|
Variants: essential
|
||||||
Modes: chrootless
|
Modes: chrootless
|
||||||
Needs-QEMU: true
|
|
||||||
Skip-If:
|
Skip-If:
|
||||||
dist in ["oldstable", "stable"]
|
dist in ["oldstable", "stable"]
|
||||||
|
|
||||||
|
@ -320,6 +321,8 @@ Variants: custom
|
||||||
Modes: chrootless
|
Modes: chrootless
|
||||||
|
|
||||||
Test: install-libmagic-mgc-on-arm64
|
Test: install-libmagic-mgc-on-arm64
|
||||||
|
Variants: custom
|
||||||
|
Modes: chrootless
|
||||||
Skip-If:
|
Skip-If:
|
||||||
hostarch != "amd64"
|
hostarch != "amd64"
|
||||||
not have_binfmt
|
not have_binfmt
|
||||||
|
@ -339,7 +342,6 @@ Modes: fakechroot
|
||||||
|
|
||||||
Test: dev-ptmx
|
Test: dev-ptmx
|
||||||
Modes: root unshare
|
Modes: root unshare
|
||||||
Needs-QEMU: true
|
|
||||||
|
|
||||||
Test: error-if-stdout-is-tty
|
Test: error-if-stdout-is-tty
|
||||||
|
|
||||||
|
@ -349,14 +351,14 @@ Test: include-deb-file
|
||||||
|
|
||||||
Test: unshare-include-deb
|
Test: unshare-include-deb
|
||||||
Modes: unshare
|
Modes: unshare
|
||||||
Needs-QEMU: true
|
|
||||||
|
|
||||||
Test: pivot_root
|
Test: pivot_root
|
||||||
Modes: root unshare
|
Modes: root unshare
|
||||||
Needs-QEMU: true
|
Skip-If: not have_unshare
|
||||||
|
|
||||||
Test: jessie-or-older
|
Test: jessie-or-older
|
||||||
Needs-QEMU: true
|
Needs-Root: true
|
||||||
|
Modes: root unshare fakechroot
|
||||||
Variants: essential apt minbase
|
Variants: essential apt minbase
|
||||||
|
|
||||||
Test: apt-patterns
|
Test: apt-patterns
|
||||||
|
|
|
@ -2,12 +2,20 @@
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
runuser -u user -- {{ CMD }} --variant=custom --mode=unshare --setup-hook='env container=lxc debootstrap unstable "$1" {{ MIRROR }}' - /tmp/debian-mm.tar {{ MIRROR }}
|
fi
|
||||||
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
|
fi
|
||||||
|
|
||||||
|
$prefix {{ CMD }} --variant=custom --mode={{ MODE }} --setup-hook='env container=lxc debootstrap unstable "$1" {{ MIRROR }}' - /tmp/debian-mm.tar {{ MIRROR }}
|
||||||
|
|
||||||
mkdir /tmp/debian-mm
|
mkdir /tmp/debian-mm
|
||||||
tar --xattrs --xattrs-include='*' -C /tmp/debian-mm -xf /tmp/debian-mm.tar
|
tar --xattrs --xattrs-include='*' -C /tmp/debian-mm -xf /tmp/debian-mm.tar
|
||||||
|
|
|
@ -1,12 +1,21 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
||||||
|
|
||||||
|
trap "rm -f /tmp/debian-chroot-{{ MODE }}.{{ FORMAT }} /tmp/debian-chroot-root.{{ FORMAT }}" EXIT INT TERM
|
||||||
|
|
||||||
|
[ "$(id -u)" -eq 0 ]
|
||||||
|
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
fi
|
||||||
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
|
|
||||||
{{ CMD }} --mode=root --variant={{ VARIANT }} {{ DIST }} /tmp/debian-chroot-root.{{ FORMAT }} {{ MIRROR }}
|
{{ CMD }} --mode=root --variant={{ VARIANT }} {{ DIST }} /tmp/debian-chroot-root.{{ FORMAT }} {{ MIRROR }}
|
||||||
if [ "{{ FORMAT }}" = tar ]; then
|
if [ "{{ FORMAT }}" = tar ]; then
|
||||||
printf 'ustar ' | cmp --bytes=6 --ignore-initial=257:0 /tmp/debian-chroot-root.tar -
|
printf 'ustar ' | cmp --bytes=6 --ignore-initial=257:0 /tmp/debian-chroot-root.tar -
|
||||||
|
@ -18,19 +27,11 @@ else
|
||||||
echo "unknown format: {{ FORMAT }}" >&2
|
echo "unknown format: {{ FORMAT }}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
runuser -u user -- {{ CMD }} --mode=unshare --variant={{ VARIANT }} {{ DIST }} /tmp/debian-chroot-unshare.{{ FORMAT }} {{ MIRROR }}
|
|
||||||
cmp /tmp/debian-chroot-root.{{ FORMAT }} /tmp/debian-chroot-unshare.{{ FORMAT }}
|
$prefix {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} {{ DIST }} /tmp/debian-chroot-{{ MODE }}.{{ FORMAT }} {{ MIRROR }}
|
||||||
rm /tmp/debian-chroot-unshare.{{ FORMAT }}
|
cmp /tmp/debian-chroot-root.{{ FORMAT }} /tmp/debian-chroot-{{ MODE }}.{{ FORMAT }} \
|
||||||
case {{ VARIANT }} in essential|apt|minbase|buildd)
|
|| diffoscope /tmp/debian-chroot-root.{{ FORMAT }} /tmp/debian-chroot-{{ MODE }}.{{ FORMAT }}
|
||||||
# variants important and standard differ because permissions drwxr-sr-x
|
|
||||||
# and extended attributes of ./var/log/journal/ cannot be preserved
|
|
||||||
# in fakechroot mode
|
|
||||||
runuser -u user -- {{ CMD }} --mode=fakechroot --variant={{ VARIANT }} {{ DIST }} /tmp/debian-chroot-fakechroot.{{ FORMAT }} {{ MIRROR }}
|
|
||||||
cmp /tmp/debian-chroot-root.{{ FORMAT }} /tmp/debian-chroot-fakechroot.{{ FORMAT }}
|
|
||||||
rm /tmp/debian-chroot-fakechroot.{{ FORMAT }}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
# we cannot test chrootless mode here, because mmdebstrap relies on the
|
# we cannot test chrootless mode here, because mmdebstrap relies on the
|
||||||
# usrmerge package to set up merged-/usr and that doesn't work in chrootless
|
# usrmerge package to set up merged-/usr and that doesn't work in chrootless
|
||||||
# mode
|
# mode
|
||||||
rm /tmp/debian-chroot-root.{{ FORMAT }}
|
|
||||||
|
|
|
@ -3,15 +3,21 @@ set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
||||||
trap "rm -f /tmp/chrootless.tar /tmp/root.tar" EXIT INT TERM
|
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
|
|
||||||
|
[ {{ MODE }} = chrootless ]
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
fi
|
fi
|
||||||
prefix=
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
[ "$(id -u)" -eq 0 ] && prefix="runuser -u user --"
|
fi
|
||||||
|
|
||||||
# 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
|
||||||
# permissions drwxr-sr-x and extended attributes of ./var/log/journal/ cannot
|
# permissions drwxr-sr-x and extended attributes of ./var/log/journal/ cannot
|
||||||
|
@ -21,7 +27,7 @@ for INCLUDE in '' 'apt' 'apt,build-essential' 'systemd-sysv'; do
|
||||||
--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' \
|
--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"} \
|
${INCLUDE:+--include="$INCLUDE"} \
|
||||||
{{ DIST }} /tmp/root.tar {{ MIRROR }}
|
{{ DIST }} /tmp/root.tar {{ MIRROR }}
|
||||||
$prefix fakeroot {{ CMD }} --mode=chrootless --variant={{ VARIANT }} --hook-dir=./hooks/merged-usr \
|
$prefix fakeroot {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --hook-dir=./hooks/merged-usr \
|
||||||
${INCLUDE:+--include="$INCLUDE"} \
|
${INCLUDE:+--include="$INCLUDE"} \
|
||||||
{{ DIST }} /tmp/chrootless.tar {{ MIRROR }}
|
{{ DIST }} /tmp/chrootless.tar {{ MIRROR }}
|
||||||
cmp /tmp/root.tar /tmp/chrootless.tar
|
cmp /tmp/root.tar /tmp/chrootless.tar
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
fi
|
fi
|
||||||
prefix=
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
[ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && prefix="runuser -u user --"
|
fi
|
||||||
|
|
||||||
[ "{{ MODE }}" = "fakechroot" ] && prefix="$prefix fakechroot fakeroot"
|
[ "{{ MODE }}" = "fakechroot" ] && prefix="$prefix fakechroot fakeroot"
|
||||||
$prefix {{ CMD }} --mode={{ MODE }} --variant=apt --architectures=arm64 {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
$prefix {{ CMD }} --mode={{ MODE }} --variant=apt --architectures=arm64 {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
||||||
# we ignore differences between architectures by ignoring some files
|
# we ignore differences between architectures by ignoring some files
|
||||||
|
|
|
@ -1,12 +1,20 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
runuser -u user -- {{ CMD }} --mode=unshare --variant=apt {{ DIST }} /tmp/debian-chroot.tar.gz {{ MIRROR }}
|
fi
|
||||||
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
|
fi
|
||||||
|
|
||||||
|
$prefix {{ CMD }} --mode={{ MODE }} --variant=apt {{ DIST }} /tmp/debian-chroot.tar.gz {{ MIRROR }}
|
||||||
printf '\037\213\010' | cmp --bytes=3 /tmp/debian-chroot.tar.gz -
|
printf '\037\213\010' | cmp --bytes=3 /tmp/debian-chroot.tar.gz -
|
||||||
tar -tf /tmp/debian-chroot.tar.gz | sort | diff -u tar1.txt -
|
tar -tf /tmp/debian-chroot.tar.gz | sort | diff -u tar1.txt -
|
||||||
rm /tmp/debian-chroot.tar.gz
|
rm /tmp/debian-chroot.tar.gz
|
||||||
|
|
|
@ -8,15 +8,14 @@ export LC_ALL=C.UTF-8
|
||||||
prefix=
|
prefix=
|
||||||
include=,
|
include=,
|
||||||
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != root ] && [ "{{ MODE }}" != auto ]; then
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != root ] && [ "{{ MODE }}" != auto ]; then
|
||||||
# this must be qemu
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if ! id -u user >/dev/null 2>&1; then
|
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
fi
|
fi
|
||||||
prefix="runuser -u user --"
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
if [ "{{ VARIANT }}" = extract ] || [ "{{ VARIANT }}" = custom ]; then
|
if [ "{{ VARIANT }}" = extract ] || [ "{{ VARIANT }}" = custom ]; then
|
||||||
include="$(tr '\n' ',' < pkglist.txt)"
|
include="$(tr '\n' ',' < pkglist.txt)"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,25 +1,33 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
[ "$(id -u)" -eq 0 ]
|
||||||
|
[ {{ MODE }} = "unshare" ]
|
||||||
|
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
|
fi
|
||||||
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
|
|
||||||
# https://www.etalabs.net/sh_tricks.html
|
# https://www.etalabs.net/sh_tricks.html
|
||||||
quote () { printf %s\\n "$1" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/'/" ; }
|
quote () { printf %s\\n "$1" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/'/" ; }
|
||||||
useradd --home-dir /home/user --create-home user
|
homedir=$($prefix sh -c 'cd && pwd')
|
||||||
homedir=$(runuser -u user -- 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)\$!"
|
||||||
runuser -u user -- 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"
|
||||||
# set permissions and sticky bit like the real /tmp
|
# set permissions and sticky bit like the real /tmp
|
||||||
chmod 1777 "$homedir/$TMPDIR_ADD"
|
chmod 1777 "$homedir/$TMPDIR_ADD"
|
||||||
runuser -u user -- env TMPDIR="$homedir/$TMPDIR_ADD" {{ CMD }} --mode=unshare --variant=apt \
|
$prefix env TMPDIR="$homedir/$TMPDIR_ADD" {{ CMD }} --mode={{ MODE }} --variant=apt \
|
||||||
--setup-hook='case "$1" in '"$(quote "$homedir/$TMPDIR_ADD/mmdebstrap.")"'??????????) exit 0;; *) echo "$1"; exit 1;; esac' \
|
--setup-hook='case "$1" in '"$(quote "$homedir/$TMPDIR_ADD/mmdebstrap.")"'??????????) exit 0;; *) echo "$1"; exit 1;; esac' \
|
||||||
{{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
{{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
||||||
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
||||||
# use rmdir as a quick check that nothing is remaining in TMPDIR
|
# use rmdir as a quick check that nothing is remaining in TMPDIR
|
||||||
runuser -u user -- rmdir "$homedir/$TMPDIR_ADD"
|
$prefix rmdir "$homedir/$TMPDIR_ADD"
|
||||||
rm /tmp/debian-chroot.tar
|
rm /tmp/debian-chroot.tar
|
||||||
|
|
|
@ -1,21 +1,30 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
[ "$(id -u)" -eq 0 ]
|
||||||
|
[ {{ MODE }} = "unshare" ]
|
||||||
|
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
|
fi
|
||||||
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
|
|
||||||
mkdir /tmp/debian-chroot
|
mkdir /tmp/debian-chroot
|
||||||
chmod 700 /tmp/debian-chroot
|
chmod 700 /tmp/debian-chroot
|
||||||
chown user:user /tmp/debian-chroot
|
chown "${SUDO_USER:-user}:${SUDO_USER:-user}" /tmp/debian-chroot
|
||||||
|
set -- env --chdir=/tmp/debian-chroot
|
||||||
if [ "{{ CMD }}" = "./mmdebstrap" ]; then
|
if [ "{{ CMD }}" = "./mmdebstrap" ]; then
|
||||||
set -- "$(realpath --canonicalize-existing ./mmdebstrap)"
|
set -- "$@" "$(realpath --canonicalize-existing ./mmdebstrap)"
|
||||||
elif [ "{{ CMD }}" = "perl -MDevel::Cover=-silent,-nogcov ./mmdebstrap" ]; then
|
elif [ "{{ CMD }}" = "perl -MDevel::Cover=-silent,-nogcov ./mmdebstrap" ]; then
|
||||||
set -- perl -MDevel::Cover=-silent,-nogcov "$(realpath --canonicalize-existing ./mmdebstrap)"
|
set -- "$@" perl -MDevel::Cover=-silent,-nogcov "$(realpath --canonicalize-existing ./mmdebstrap)"
|
||||||
else
|
else
|
||||||
set -- {{ CMD }}
|
set -- "$@" {{ CMD }}
|
||||||
fi
|
fi
|
||||||
env --chdir=/tmp/debian-chroot runuser -u user -- "$@" --mode=unshare --variant=apt {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
$prefix "$@" --mode={{ MODE }} --variant=apt {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
||||||
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
||||||
rm /tmp/debian-chroot.tar
|
rm /tmp/debian-chroot.tar
|
||||||
|
|
|
@ -7,15 +7,17 @@ if [ {{ MODE }} != unshare ] && [ {{ MODE }} != root ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
useradd --home-dir /home/user --create-home user
|
fi
|
||||||
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
fi
|
fi
|
||||||
prefix=
|
|
||||||
[ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && prefix="runuser -u user --"
|
|
||||||
|
|
||||||
# this mimics what apt does in apt-pkg/deb/dpkgpm.cc/pkgDPkgPM::StartPtyMagic()
|
# this mimics what apt does in apt-pkg/deb/dpkgpm.cc/pkgDPkgPM::StartPtyMagic()
|
||||||
cat > /tmp/test.c << 'END'
|
cat > /tmp/test.c << 'END'
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
|
||||||
|
[ {{ VARIANT }} = "custom" ]
|
||||||
|
[ {{ MODE }} = "chrootless" ]
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
fi
|
fi
|
||||||
prefix=
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
[ "$(id -u)" -eq 0 ] && prefix="runuser -u user --"
|
fi
|
||||||
$prefix {{ CMD }} --mode=chrootless --variant=custom --include=doc-debian {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
|
||||||
|
$prefix {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --include=doc-debian {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
||||||
tar -C /tmp/debian-chroot --owner=0 --group=0 --numeric-owner --sort=name --clamp-mtime --mtime="$(date --utc --date=@{{ SOURCE_DATE_EPOCH }} --iso-8601=seconds)" -cf /tmp/debian-chroot.tar .
|
tar -C /tmp/debian-chroot --owner=0 --group=0 --numeric-owner --sort=name --clamp-mtime --mtime="$(date --utc --date=@{{ SOURCE_DATE_EPOCH }} --iso-8601=seconds)" -cf /tmp/debian-chroot.tar .
|
||||||
tar tvf /tmp/debian-chroot.tar > doc-debian.tar.list
|
tar tvf /tmp/debian-chroot.tar > doc-debian.tar.list
|
||||||
rm /tmp/debian-chroot.tar
|
rm /tmp/debian-chroot.tar
|
||||||
|
|
|
@ -2,15 +2,22 @@
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
||||||
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
|
||||||
|
[ {{ VARIANT }} = "custom" ]
|
||||||
|
[ {{ MODE }} = "chrootless" ]
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
fi
|
fi
|
||||||
prefix=
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
[ "$(id -u)" -eq 0 ] && prefix="runuser -u user --"
|
fi
|
||||||
$prefix {{ CMD }} --mode=chrootless --variant=custom --include=doc-debian {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
|
||||||
|
$prefix {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --include=doc-debian {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
||||||
tar tvf /tmp/debian-chroot.tar | grep -v ' ./dev' | diff -u doc-debian.tar.list -
|
tar tvf /tmp/debian-chroot.tar | grep -v ' ./dev' | diff -u doc-debian.tar.list -
|
||||||
rm /tmp/debian-chroot.tar
|
rm /tmp/debian-chroot.tar
|
||||||
|
|
|
@ -2,16 +2,23 @@
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
||||||
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
|
||||||
|
[ {{ VARIANT }} = "custom" ]
|
||||||
|
[ {{ MODE }} = "chrootless" ]
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
fi
|
fi
|
||||||
prefix=
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
[ "$(id -u)" -eq 0 ] && prefix="runuser -u user --"
|
fi
|
||||||
$prefix {{ CMD }} --mode=chrootless --skip=cleanup/tmp --variant=custom --include=doc-debian --setup-hook='touch "$1/tmp/setup"' --customize-hook='touch "$1/tmp/customize"' {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
|
||||||
|
$prefix {{ CMD }} --mode={{ MODE }} --skip=cleanup/tmp --variant={{ VARIANT }} --include=doc-debian --setup-hook='touch "$1/tmp/setup"' --customize-hook='touch "$1/tmp/customize"' {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
||||||
rm /tmp/debian-chroot/tmp/setup
|
rm /tmp/debian-chroot/tmp/setup
|
||||||
rm /tmp/debian-chroot/tmp/customize
|
rm /tmp/debian-chroot/tmp/customize
|
||||||
tar -C /tmp/debian-chroot --owner=0 --group=0 --numeric-owner --sort=name --clamp-mtime --mtime="$(date --utc --date=@{{ SOURCE_DATE_EPOCH }} --iso-8601=seconds)" -cf /tmp/debian-chroot.tar .
|
tar -C /tmp/debian-chroot --owner=0 --group=0 --numeric-owner --sort=name --clamp-mtime --mtime="$(date --utc --date=@{{ SOURCE_DATE_EPOCH }} --iso-8601=seconds)" -cf /tmp/debian-chroot.tar .
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
|
||||||
|
[ {{ VARIANT }} = "custom" ]
|
||||||
|
[ {{ MODE }} = "chrootless" ]
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
fi
|
fi
|
||||||
prefix=
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
[ "$(id -u)" -eq 0 ] && prefix="runuser -u user --"
|
fi
|
||||||
$prefix {{ CMD }} --mode=chrootless --variant=custom --architectures=arm64 --include=libmagic-mgc {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
|
||||||
|
$prefix {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --architectures=arm64 --include=libmagic-mgc {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
||||||
# delete contents of libmagic-mgc
|
# delete contents of libmagic-mgc
|
||||||
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
|
||||||
|
|
|
@ -1,15 +1,30 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
||||||
|
|
||||||
|
trap "rm -f /tmp/debian-chroot-{{ MODE }}.tar /tmp/debian-chroot-root-normal.tar" EXIT INT TERM
|
||||||
|
|
||||||
|
[ "$(id -u)" -eq 0 ]
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
fi
|
||||||
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
|
fi
|
||||||
|
|
||||||
|
MMTARFILTER=
|
||||||
|
[ -x /usr/bin/mmtarfilter ] && MMTARFILTER=/usr/bin/mmtarfilter
|
||||||
|
[ -x ./tarfilter ] && MMTARFILTER=./tarfilter
|
||||||
|
|
||||||
filter() {
|
filter() {
|
||||||
./tarfilter \
|
"$MMTARFILTER" \
|
||||||
--path-exclude=/usr/bin/uncompress \
|
--path-exclude=/usr/bin/uncompress \
|
||||||
--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 \
|
||||||
|
@ -20,19 +35,7 @@ filter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# base for comparison without jessie-or-older hook
|
# base for comparison without jessie-or-older hook
|
||||||
{{ CMD }} --mode=root --variant={{ VARIANT }} {{ DIST }} - {{ MIRROR }} | filter > /tmp/debian-chroot-root-normal.tar
|
{{ CMD }} --mode=root --variant={{ VARIANT }} {{ DIST }} - {{ MIRROR }} > /tmp/debian-chroot-root-normal.tar
|
||||||
|
|
||||||
# root
|
$prefix {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --hook-dir=./hooks/jessie-or-older {{ DIST }} - {{ MIRROR }} | filter > /tmp/debian-chroot-{{ MODE }}.tar
|
||||||
{{ CMD }} --mode=root --variant={{ VARIANT }} --hook-dir=./hooks/jessie-or-older {{ DIST }} - {{ MIRROR }} | filter > /tmp/debian-chroot-root.tar
|
filter < /tmp/debian-chroot-root-normal.tar | cmp - /tmp/debian-chroot-{{ MODE }}.tar
|
||||||
cmp /tmp/debian-chroot-root-normal.tar /tmp/debian-chroot-root.tar
|
|
||||||
rm /tmp/debian-chroot-root.tar
|
|
||||||
# unshare
|
|
||||||
runuser -u user -- {{ CMD }} --mode=unshare --variant={{ VARIANT }} --hook-dir=./hooks/jessie-or-older {{ DIST }} - {{ MIRROR }} | filter > /tmp/debian-chroot-unshare.tar
|
|
||||||
cmp /tmp/debian-chroot-root-normal.tar /tmp/debian-chroot-unshare.tar
|
|
||||||
rm /tmp/debian-chroot-unshare.tar
|
|
||||||
# fakechroot
|
|
||||||
runuser -u user -- {{ CMD }} --mode=fakechroot --variant={{ VARIANT }} --hook-dir=./hooks/jessie-or-older {{ DIST }} - {{ MIRROR }} | filter > /tmp/debian-chroot-fakechroot.tar
|
|
||||||
cmp /tmp/debian-chroot-root-normal.tar /tmp/debian-chroot-fakechroot.tar
|
|
||||||
rm /tmp/debian-chroot-fakechroot.tar
|
|
||||||
|
|
||||||
rm /tmp/debian-chroot-root-normal.tar
|
|
||||||
|
|
|
@ -1,9 +1,20 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
[ {{ MODE }} = "unshare" ]
|
||||||
|
[ {{ VARIANT }} = "custom" ]
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
runuser -u user -- {{ CMD }} --mode=unshare --variant=custom --include=dpkg,dash,diffutils,coreutils,libc-bin,sed {{ DIST }} /dev/null {{ MIRROR }}
|
fi
|
||||||
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
|
fi
|
||||||
|
|
||||||
|
$prefix {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --include=dpkg,dash,diffutils,coreutils,libc-bin,sed {{ DIST }} /dev/null {{ MIRROR }}
|
||||||
|
|
|
@ -7,16 +7,22 @@
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
[ "{{ MODE }}" = "fakechroot" ]
|
|
||||||
trap "rm -f /tmp/debian-chroot.tar" EXIT INT TERM
|
trap "rm -f /tmp/debian-chroot.tar" EXIT INT TERM
|
||||||
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
|
||||||
|
[ "{{ MODE }}" = "fakechroot" ]
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
fi
|
fi
|
||||||
prefix=
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
[ "$(id -u)" -eq 0 ] && prefix="runuser -u user --"
|
fi
|
||||||
$prefix env PATH=/usr/bin:/bin fakechroot fakeroot {{ CMD }} --mode=fakechroot --variant=apt {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
|
||||||
|
$prefix env PATH=/usr/bin:/bin fakechroot fakeroot {{ CMD }} --mode={{ MODE }} --variant=apt {{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
||||||
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
||||||
|
|
|
@ -4,17 +4,17 @@ export LC_ALL=C.UTF-8
|
||||||
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
||||||
trap "rm -f /tmp/chroot1.tar /tmp/chroot2.tar /tmp/chroot3.tar /tmp/mmdebstrap" EXIT INT TERM
|
trap "rm -f /tmp/chroot1.tar /tmp/chroot2.tar /tmp/chroot3.tar /tmp/mmdebstrap" EXIT INT TERM
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
fi
|
||||||
useradd --home-dir /home/user --create-home user
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prefix=
|
|
||||||
[ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && prefix="runuser -u user --"
|
|
||||||
|
|
||||||
MMDEBSTRAP=
|
MMDEBSTRAP=
|
||||||
[ -e /usr/bin/mmdebstrap ] && MMDEBSTRAP=/usr/bin/mmdebstrap
|
[ -e /usr/bin/mmdebstrap ] && MMDEBSTRAP=/usr/bin/mmdebstrap
|
||||||
|
|
|
@ -5,13 +5,22 @@
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
[ {{ MODE }} = "unshare" ]
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
[ "$(whoami)" = "root" ]
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
useradd --home-dir /home/user --create-home user
|
fi
|
||||||
cat << 'SCRIPT' > script.sh
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat << 'SCRIPT' > /tmp/script.sh
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
rootfs="$1"
|
rootfs="$1"
|
||||||
|
@ -22,10 +31,10 @@ chroot "$rootfs" env --chdir=/mnt \
|
||||||
{{ CMD }} --mode=root --variant=apt \
|
{{ CMD }} --mode=root --variant=apt \
|
||||||
{{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
{{ DIST }} /tmp/debian-chroot.tar {{ MIRROR }}
|
||||||
SCRIPT
|
SCRIPT
|
||||||
chmod +x script.sh
|
chmod +x /tmp/script.sh
|
||||||
runuser -u user -- {{ CMD }} --mode=unshare --variant=apt --include=perl,mount \
|
$prefix {{ CMD }} --mode={{ MODE }} --variant=apt --include=perl,mount \
|
||||||
--customize-hook=./script.sh \
|
--customize-hook=/tmp/script.sh \
|
||||||
--customize-hook="download /tmp/debian-chroot.tar /tmp/debian-chroot.tar" \
|
--customize-hook="download /tmp/debian-chroot.tar /tmp/debian-chroot.tar" \
|
||||||
{{ DIST }} /dev/null {{ MIRROR }}
|
{{ DIST }} /dev/null {{ MIRROR }}
|
||||||
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt -
|
||||||
rm /tmp/debian-chroot.tar script.sh
|
rm /tmp/debian-chroot.tar /tmp/script.sh
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
fi
|
fi
|
||||||
prefix=
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
[ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && prefix="runuser -u user --"
|
fi
|
||||||
|
|
||||||
[ "{{ MODE }}" = "fakechroot" ] && prefix="$prefix fakechroot fakeroot"
|
[ "{{ MODE }}" = "fakechroot" ] && prefix="$prefix fakechroot fakeroot"
|
||||||
symlinktarget=/real
|
symlinktarget=/real
|
||||||
[ "{{ MODE }}" = "fakechroot" ] && symlinktarget='$1/real'
|
[ "{{ MODE }}" = "fakechroot" ] && symlinktarget='$1/real'
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
|
||||||
|
[ {{ VARIANT }} = extract ]
|
||||||
|
|
||||||
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
fi
|
fi
|
||||||
prefix=
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
[ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && prefix="runuser -u user --"
|
fi
|
||||||
|
|
||||||
[ "{{ MODE }}" = "fakechroot" ] && prefix="$prefix fakechroot fakeroot"
|
[ "{{ MODE }}" = "fakechroot" ] && prefix="$prefix fakechroot fakeroot"
|
||||||
$prefix {{ CMD }} --mode={{ MODE }} --variant=extract --include=doc-debian {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
$prefix {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --include=doc-debian {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
||||||
# delete contents of doc-debian
|
# delete contents of doc-debian
|
||||||
rm /tmp/debian-chroot/usr/share/doc-base/debian-*
|
rm /tmp/debian-chroot/usr/share/doc-base/debian-*
|
||||||
rm -r /tmp/debian-chroot/usr/share/doc/debian
|
rm -r /tmp/debian-chroot/usr/share/doc/debian
|
||||||
|
|
|
@ -5,14 +5,17 @@ export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
[ "{{ MODE }}" = unshare ]
|
[ "{{ MODE }}" = unshare ]
|
||||||
|
|
||||||
if [ "$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1; then
|
prefix=
|
||||||
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
|
if ! id "${SUDO_USER:-user}" 2>/dev/null; then
|
||||||
if [ ! -e /mmdebstrap-testenv ]; then
|
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
|
||||||
useradd --home-dir /home/user --create-home user
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
||||||
|
fi
|
||||||
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
||||||
fi
|
fi
|
||||||
[ "$(id -u)" -eq 0 ] && prefix="runuser -u user --"
|
|
||||||
|
|
||||||
# instead of obtaining a .deb from our cache, we create a new package because
|
# instead of obtaining a .deb from our cache, we create a new package because
|
||||||
# otherwise apt might decide to download the package with the same name and
|
# otherwise apt might decide to download the package with the same name and
|
||||||
|
|
Loading…
Reference in a new issue