summaryrefslogtreecommitdiffstats
path: root/tests/jessie-or-older
blob: db941b6911ec33a60824a6f196f3fc81458c99e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
set -eu
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}" >/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

filter() {
	"$MMTARFILTER" \
		--path-exclude=/usr/bin/uncompress \
		--path-exclude=/var/cache/debconf/config.dat-old \
		--path-exclude=/var/cache/debconf/templates.dat-old \
		--path-exclude=/var/lib/dpkg/available \
		--path-exclude=/var/lib/dpkg/diversions \
		--path-exclude=/var/lib/dpkg/diversions-old \
		--path-exclude=/var/lib/dpkg/cmethopt \
		--path-exclude=/var/lib/dpkg/status-old \
		--path-exclude=/var/lib/shells.state
}

# base for comparison without jessie-or-older hook
{{ CMD }} --mode=root --variant={{ VARIANT }} {{ DIST }} - {{ MIRROR }} > /tmp/debian-chroot-root-normal.tar

$prefix {{ CMD }} --mode={{ MODE }} --variant={{ VARIANT }} --hook-dir=./hooks/jessie-or-older {{ DIST }} - {{ MIRROR }} | filter > /tmp/debian-chroot-{{ MODE }}.tar
filter < /tmp/debian-chroot-root-normal.tar | cmp - /tmp/debian-chroot-{{ MODE }}.tar