forked from josch/mmdebstrap
tests: more cleanup traps
This commit is contained in:
parent
f3ab0a3d2d
commit
55f376d04a
11 changed files with 28 additions and 5 deletions
|
@ -1,7 +1,9 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
trap "rm -rf /tmp/debian-chroot" EXIT INT TERM
|
||||||
|
|
||||||
{{ CMD }} --mode=root --variant=apt {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
{{ CMD }} --mode=root --variant=apt {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
||||||
chroot /tmp/debian-chroot dpkg-query --showformat '${binary:Package}\n' --show > pkglist.txt
|
chroot /tmp/debian-chroot dpkg-query --showformat '${binary:Package}\n' --show > pkglist.txt
|
||||||
tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort > tar1.txt
|
tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort > tar1.txt
|
||||||
rm -r /tmp/debian-chroot
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
trap "rm -f /tmp/exists" EXIT INT TERM
|
||||||
|
|
||||||
touch /tmp/exists
|
touch /tmp/exists
|
||||||
ret=0
|
ret=0
|
||||||
{{ CMD }} --mode={{ MODE }} --variant=apt {{ DIST }} /tmp/exists {{ MIRROR }} || ret=$?
|
{{ CMD }} --mode={{ MODE }} --variant=apt {{ DIST }} /tmp/exists {{ MIRROR }} || ret=$?
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
trap 'rm -rf /tmp/quoted\"path' EXIT INT TERM
|
||||||
|
|
||||||
ret=0
|
ret=0
|
||||||
{{ CMD }} --mode={{ MODE }} --variant=apt {{ DIST }} /tmp/quoted\"path {{ MIRROR }} || ret=$?
|
{{ CMD }} --mode={{ MODE }} --variant=apt {{ DIST }} /tmp/quoted\"path {{ MIRROR }} || ret=$?
|
||||||
if [ "$ret" = 0 ]; then
|
if [ "$ret" = 0 ]; then
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
trap "rm -rf /tmp/dummypkg.deb /tmp/dummypkg" EXIT INT TERM
|
||||||
|
|
||||||
# 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
|
||||||
# version from the cache instead of using the local .deb
|
# version from the cache instead of using the local .deb
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
trap "rm -rf /tmp/debian-chroot" EXIT INT TERM
|
||||||
|
|
||||||
pkgs=base-files,base-passwd,busybox,debianutils,dpkg,libc-bin,mawk,tar
|
pkgs=base-files,base-passwd,busybox,debianutils,dpkg,libc-bin,mawk,tar
|
||||||
# busybox --install -s will install symbolic links into the rootfs, leaving
|
# busybox --install -s will install symbolic links into the rootfs, leaving
|
||||||
# existing files untouched. It has to run after extraction (otherwise there is
|
# existing files untouched. It has to run after extraction (otherwise there is
|
||||||
|
@ -31,4 +34,3 @@ chroot /tmp/debian-chroot echo foobar \
|
||||||
| chroot /tmp/debian-chroot tee /dev/null \
|
| chroot /tmp/debian-chroot tee /dev/null \
|
||||||
| chroot /tmp/debian-chroot sed 's/foobar/blubber/' \
|
| chroot /tmp/debian-chroot sed 's/foobar/blubber/' \
|
||||||
| chroot /tmp/debian-chroot grep blubber >/dev/null
|
| chroot /tmp/debian-chroot grep blubber >/dev/null
|
||||||
rm -r /tmp/debian-chroot
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ export LC_ALL=C.UTF-8
|
||||||
[ {{ VARIANT }} = "custom" ]
|
[ {{ VARIANT }} = "custom" ]
|
||||||
[ {{ MODE }} = "chrootless" ]
|
[ {{ MODE }} = "chrootless" ]
|
||||||
|
|
||||||
|
trap "rm -rf /tmp/debian-chroot" EXIT INT TERM
|
||||||
|
|
||||||
prefix=
|
prefix=
|
||||||
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
if ! id "${SUDO_USER:-user}" >/dev/null 2>&1; then
|
if ! id "${SUDO_USER:-user}" >/dev/null 2>&1; then
|
||||||
|
|
|
@ -6,6 +6,8 @@ export SOURCE_DATE_EPOCH={{ SOURCE_DATE_EPOCH }}
|
||||||
[ {{ VARIANT }} = "custom" ]
|
[ {{ VARIANT }} = "custom" ]
|
||||||
[ {{ MODE }} = "chrootless" ]
|
[ {{ MODE }} = "chrootless" ]
|
||||||
|
|
||||||
|
trap "rm -rf /tmp/debian-chroot" EXIT INT TERM
|
||||||
|
|
||||||
prefix=
|
prefix=
|
||||||
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
if ! id "${SUDO_USER:-user}" >/dev/null 2>&1; then
|
if ! id "${SUDO_USER:-user}" >/dev/null 2>&1; then
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
trap "rm -rf /tmp/debian-chroot /tmp/log /tmp/trimmed" EXIT INT TERM
|
||||||
|
|
||||||
# we check the full log to also prevent debug printfs to accidentally make it into a commit
|
# we check the full log to also prevent debug printfs to accidentally make it into a commit
|
||||||
{{ CMD }} --mode=root --variant=apt --logfile=/tmp/log {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
{{ CMD }} --mode=root --variant=apt --logfile=/tmp/log {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
|
||||||
# omit the last line which should contain the runtime
|
# omit the last line which should contain the runtime
|
||||||
|
@ -17,5 +20,3 @@ I: cleaning package lists and apt cache...
|
||||||
LOG
|
LOG
|
||||||
tail --lines=1 /tmp/log | grep '^I: success in .* seconds$'
|
tail --lines=1 /tmp/log | grep '^I: success in .* seconds$'
|
||||||
tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort | diff -u tar1.txt -
|
tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort | diff -u tar1.txt -
|
||||||
rm -r /tmp/debian-chroot
|
|
||||||
rm /tmp/log /tmp/trimmed
|
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
[ "$(whoami)" = "root" ]
|
[ "$(whoami)" = "root" ]
|
||||||
|
|
||||||
|
trap "rm -f /tmp/debian-chroot.tar script.sh" EXIT INT TERM
|
||||||
|
|
||||||
cat << 'SCRIPT' > script.sh
|
cat << 'SCRIPT' > script.sh
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
|
@ -23,4 +26,3 @@ chmod +x 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
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
set -eu
|
set -eu
|
||||||
export LC_ALL=C.UTF-8
|
export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
trap "rm -rf /tmp/debian-chroot" EXIT INT TERM
|
||||||
|
|
||||||
[ {{ VARIANT }} = extract ]
|
[ {{ VARIANT }} = extract ]
|
||||||
|
|
||||||
prefix=
|
prefix=
|
||||||
|
|
|
@ -5,6 +5,8 @@ export LC_ALL=C.UTF-8
|
||||||
|
|
||||||
[ "{{ MODE }}" = unshare ]
|
[ "{{ MODE }}" = unshare ]
|
||||||
|
|
||||||
|
trap "rm -rf /tmp/dummypkg.deb /tmp/dummypkg" EXIT INT TERM
|
||||||
|
|
||||||
prefix=
|
prefix=
|
||||||
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
||||||
if ! id "${SUDO_USER:-user}" >/dev/null 2>&1; then
|
if ! id "${SUDO_USER:-user}" >/dev/null 2>&1; then
|
||||||
|
|
Loading…
Reference in a new issue