-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsystem-testing
More file actions
executable file
·96 lines (86 loc) · 3.54 KB
/
Copy pathsystem-testing
File metadata and controls
executable file
·96 lines (86 loc) · 3.54 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
set -eu
curdir=$(readlink -f "${0%/*}")
bdebstrap_binary="${1-$curdir/bdebstrap}"
examples_dir="${2-$curdir/examples}"
DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH)
# change to temporary directory to not interfere with the source
cd "${AUTOPKGTEST_TMP-${TMPDIR-/tmp}}"
check_existing() {
local directory="$1"
shift
for file in "$@"; do
if test ! -e "${directory}/${file}"; then
echo "Error: Expected generated file '${directory}/${file}' not found. Content of '${directory}':" >&2
ls "${directory}"
exit 1
fi
done
}
header() {
printf "\n+------------------------------------------------------------------------------+\n"
printf "| %-76s |\n" "$1"
printf "+------------------------------------------------------------------------------+\n\n"
}
test_example1() {
header "Example 1: Minimal Debian unstable tarball"
"$bdebstrap_binary" -v -c "$examples_dir/Debian-unstable.yaml" --name example1 --mode root
check_existing example1 config.yaml manifest root.tar.xz
"$bdebstrap_binary" -v -c example1/config.yaml -o example1-rebuild
check_existing example1-rebuild config.yaml manifest root.tar.xz
echo "Info: Check that 'example1' and 'example1-rebuild' are bit-by-bit identical..."
diffoscope example1 example1-rebuild
rm -r example1 example1-rebuild
}
test_example2() {
header "Example 2: Debian live system"
sed '/ - upload ~/d' "$examples_dir/Debian-trixie-live.yaml" > Debian-trixie-live.yaml
if test "$DEB_HOST_ARCH" != amd64; then
# Use host architecture to avoid testing building for foreign architecture
case "$DEB_HOST_ARCH" in
arm64) kernel="linux-image-cloud-arm64" ;;
armel) kernel="linux-image-rpi" ;;
armhf) kernel="linux-image-armmp-lpae" ;;
ppc64el) kernel="linux-image-powerpc64le" ;;
riscv64 | s390x) kernel="linux-image-${DEB_HOST_ARCH}" ;;
*)
echo "Info: Skipping this example, because the architecture ${DEB_HOST_ARCH} is not supported for trixie."
return 0
;;
esac
sed -i "s/linux-image-cloud-amd64/${kernel}/" Debian-trixie-live.yaml
sed -i "s/amd64/${DEB_HOST_ARCH}/" Debian-trixie-live.yaml
fi
"$bdebstrap_binary" -v -c Debian-trixie-live.yaml --packages iputils-clockdiff --name example2 --mode root
check_existing example2 config.yaml initrd.img manifest root.squashfs vmlinuz
xattr=$(rdsquashfs -x /usr/bin/clockdiff example2/root.squashfs)
if test -z "$xattr"; then
echo "Error: /usr/bin/clockdiff from example2/root.squashfs lacks security xattrs!" >&2
return 1
else
echo "Info: /usr/bin/clockdiff has xattrs: $xattr"
fi
rm -r example2
}
test_example3() {
header "Example 3: Minimal Ubuntu 26.04 LTS tarball"
case "$DEB_HOST_ARCH" in
amd64 | amd64v3 | arm64 | armhf | i386 | ppc64el | s390x) ;;
riscv64)
if ! grep -q "^isa.*sscofpmf" /proc/cpuinfo; then
echo "Info: Skipping this example, because riscv64 CPU does not support RVA23S64 ISA."
return 0
fi
;;
*)
echo "Info: Skipping this example, because Ubuntu does not support architecture ${DEB_HOST_ARCH}."
return 0
;;
esac
"$bdebstrap_binary" -v -c "$examples_dir/Ubuntu-26.04.yaml" --name example3 --mode root
check_existing example3 config.yaml manifest root.tar.xz
rm -r example3
}
test_example1
test_example2
test_example3