| 1 |
#!/bin/sh |
| 2 |
set -eu |
| 3 |
|
| 4 |
curdir=$(readlink -f "${0%/*}") |
| 5 |
bdebstrap_binary="${1-$curdir/bdebstrap}" |
| 6 |
examples_dir="${2-$curdir/examples}" |
| 7 |
|
| 8 |
DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH) |
| 9 |
|
| 10 |
# change to temporary directory to not interfere with the source |
| 11 |
cd "${AUTOPKGTEST_TMP-${TMPDIR-/tmp}}" |
| 12 |
|
| 13 |
check_existing() { |
| 14 |
local directory="$1" |
| 15 |
shift |
| 16 |
|
| 17 |
for file in "$@"; do |
| 18 |
if test ! -e "${directory}/${file}"; then |
| 19 |
echo "Error: Expected generated file '${directory}/${file}' not found. Content of '${directory}':" >&2 |
| 20 |
ls "${directory}" |
| 21 |
exit 1 |
| 22 |
fi |
| 23 |
done |
| 24 |
} |
| 25 |
|
| 26 |
header() { |
| 27 |
printf "\n+------------------------------------------------------------------------------+\n" |
| 28 |
printf "| %-76s |\n" "$1" |
| 29 |
printf "+------------------------------------------------------------------------------+\n\n" |
| 30 |
} |
| 31 |
|
| 32 |
test_example1() { |
| 33 |
header "Example 1: Minimal Debian unstable tarball" |
| 34 |
"$bdebstrap_binary" -v -c "$examples_dir/Debian-unstable.yaml" --name example1 --mode root |
| 35 |
check_existing example1 config.yaml manifest root.tar.xz |
| 36 |
"$bdebstrap_binary" -v -c example1/config.yaml -o example1-rebuild |
| 37 |
check_existing example1-rebuild config.yaml manifest root.tar.xz |
| 38 |
echo "Info: Check that 'example1' and 'example1-rebuild' are bit-by-bit identical..." |
| 39 |
diffoscope example1 example1-rebuild |
| 40 |
rm -r example1 example1-rebuild |
| 41 |
} |
| 42 |
|
| 43 |
test_example2() { |
| 44 |
header "Example 2: Debian live system" |
| 45 |
sed '/ - upload ~/d' "$examples_dir/Debian-trixie-live.yaml" > Debian-trixie-live.yaml |
| 46 |
if test "$DEB_HOST_ARCH" != amd64; then |
| 47 |
# Use host architecture to avoid testing building for foreign architecture |
| 48 |
case "$DEB_HOST_ARCH" in |
| 49 |
arm64) kernel="linux-image-cloud-arm64" ;; |
| 50 |
armel) kernel="linux-image-rpi" ;; |
| 51 |
armhf) kernel="linux-image-armmp-lpae" ;; |
| 52 |
ppc64el) kernel="linux-image-powerpc64le" ;; |
| 53 |
riscv64 | s390x) kernel="linux-image-${DEB_HOST_ARCH}" ;; |
| 54 |
*) |
| 55 |
echo "Info: Skipping this example, because the architecture ${DEB_HOST_ARCH} is not supported for trixie." |
| 56 |
return 0 |
| 57 |
;; |
| 58 |
esac |
| 59 |
sed -i "s/linux-image-cloud-amd64/${kernel}/" Debian-trixie-live.yaml |
| 60 |
sed -i "s/amd64/${DEB_HOST_ARCH}/" Debian-trixie-live.yaml |
| 61 |
fi |
| 62 |
"$bdebstrap_binary" -v -c Debian-trixie-live.yaml --packages iputils-clockdiff --name example2 --mode root |
| 63 |
check_existing example2 config.yaml initrd.img manifest root.squashfs vmlinuz |
| 64 |
xattr=$(rdsquashfs -x /usr/bin/clockdiff example2/root.squashfs) |
| 65 |
if test -z "$xattr"; then |
| 66 |
echo "Error: /usr/bin/clockdiff from example2/root.squashfs lacks security xattrs!" >&2 |
| 67 |
return 1 |
| 68 |
else |
| 69 |
echo "Info: /usr/bin/clockdiff has xattrs: $xattr" |
| 70 |
fi |
| 71 |
rm -r example2 |
| 72 |
} |
| 73 |
|
| 74 |
test_example3() { |
| 75 |
header "Example 3: Minimal Ubuntu 26.04 LTS tarball" |
| 76 |
case "$DEB_HOST_ARCH" in |
| 77 |
amd64 | amd64v3 | arm64 | armhf | i386 | ppc64el | s390x) ;; |
| 78 |
riscv64) |
| 79 |
if ! grep -q "^isa.*sscofpmf" /proc/cpuinfo; then |
| 80 |
echo "Info: Skipping this example, because riscv64 CPU does not support RVA23S64 ISA." |
| 81 |
return 0 |
| 82 |
fi |
| 83 |
;; |
| 84 |
*) |
| 85 |
echo "Info: Skipping this example, because Ubuntu does not support architecture ${DEB_HOST_ARCH}." |
| 86 |
return 0 |
| 87 |
;; |
| 88 |
esac |
| 89 |
"$bdebstrap_binary" -v -c "$examples_dir/Ubuntu-26.04.yaml" --name example3 --mode root |
| 90 |
check_existing example3 config.yaml manifest root.tar.xz |
| 91 |
rm -r example3 |
| 92 |
} |
| 93 |
|
| 94 |
test_example1 |
| 95 |
test_example2 |
| 96 |
test_example3 |