#!/bin/sh set -eu BUILDER_DIR="$(CDPATH= cd -- "$(dirname "$0")" && pwd)" TEST_ROOT="$(mktemp -d)" trap 'rm -rf "$TEST_ROOT"' EXIT INT TERM HUP PROJECT_VERSION_EFFECTIVE="13.0-test" BEE_ISO_VOLUME="EASY_BEE_TEST" LOG_DIR="$TEST_ROOT/log" mkdir -p "$LOG_DIR" . "$BUILDER_DIR/lib/iso-validation.sh" . "$BUILDER_DIR/lib/template.sh" . "$BUILDER_DIR/lib/bootloader.sh" literal_file="$TEST_ROOT/literal-file" printf '%s\n' 'before %%VALUE%% after %%VALUE%%' > "$literal_file" replace_literal_in_file "$literal_file" '%%VALUE%%' 'a&b#c\\d' if [ "$(cat "$literal_file")" != 'before a&b#c\\d after a&b#c\\d' ]; then echo "ERROR: generic literal replacement changed replacement characters" >&2 exit 1 fi if replace_literal_in_file "$literal_file" '' value >/dev/null 2>&1; then echo "ERROR: generic literal replacement accepted an empty placeholder" >&2 exit 1 fi if replace_literal_in_file "$literal_file" '%%MISSING%%' value >/dev/null 2>&1; then echo "ERROR: generic literal replacement accepted a missing placeholder" >&2 exit 1 fi for valid_version in 13 13.0 v13.0-2-gabcdef0-dirty; do if ! validate_project_version "$valid_version"; then echo "ERROR: rejected valid project version: $valid_version" >&2 exit 1 fi done for invalid_version in '' '.13' '13.' '13/0' '13_0' '13 0' '13&0'; do if validate_project_version "$invalid_version"; then echo "ERROR: accepted unsafe project version: $invalid_version" >&2 exit 1 fi done literal_template="$TEST_ROOT/literal-template" literal_output="$TEST_ROOT/literal-output" printf '%s\n' '@VERSION@ @KERNEL@ @APPEND_LIVE@ @INITRD@' > "$literal_template" render_bootloader_template "$literal_template" "$literal_output" \ '13&0#test' '@KERNEL@' '/live/vmlinuz\\literal' 'boot=live marker=a&b#c\\d' '@INITRD@' '/live/initrd.img' literal_expected='13&0#test /live/vmlinuz\\literal boot=live marker=a&b#c\\d /live/initrd.img' if [ "$(cat "$literal_output")" != "$literal_expected" ]; then echo "ERROR: bootloader renderer changed literal replacement characters" >&2 exit 1 fi if render_bootloader_template "$literal_template" "$literal_output" \ '13.0-test' '@MISSING_KERNEL@' '/live/vmlinuz' 'boot=live' '@INITRD@' '/live/initrd.img' >/dev/null 2>&1; then echo "ERROR: bootloader renderer accepted a missing required placeholder" >&2 exit 1 fi rendered_grub="$TEST_ROOT/grub.cfg" rendered_isolinux="$TEST_ROOT/live.cfg" sed \ -e 's#@APPEND_LIVE@#boot=live live-media-label=EASY_BEE_TEST#g' \ -e 's#@KERNEL_LIVE@#/live/vmlinuz#g' \ -e 's#@INITRD_LIVE@#/live/initrd.img#g' \ -e 's#@VERSION@#13.0-test#g' \ "$BUILDER_DIR/config/bootloaders/grub-efi/grub.cfg" > "$rendered_grub" sed \ -e 's#@APPEND_LIVE@#boot=live live-media-label=EASY_BEE_TEST#g' \ -e 's#@LINUX@#/live/vmlinuz#g' \ -e 's#@INITRD@#/live/initrd.img#g' \ -e 's#@VERSION@#13.0-test#g' \ "$BUILDER_DIR/config/bootloaders/isolinux/live.cfg.in" > "$rendered_isolinux" validate_live_cmdline_params "$rendered_grub" linux GRUB "$BEE_ISO_VOLUME" validate_live_cmdline_params "$rendered_isolinux" append isolinux "$BEE_ISO_VOLUME" missing_serialization="$TEST_ROOT/missing-serialization.cfg" sed 's/ udev\.children_max=1//' "$rendered_grub" > "$missing_serialization" if validate_live_cmdline_params "$missing_serialization" linux GRUB "$BEE_ISO_VOLUME" >/dev/null 2>&1; then echo "ERROR: validator accepted a live entry without udev.children_max=1" >&2 exit 1 fi missing_boot_live="$TEST_ROOT/missing-boot-live.cfg" awk 'BEGIN { removed=0 } /^ linux / && !removed { sub(/ boot=live/, ""); removed=1 } { print }' \ "$rendered_grub" > "$missing_boot_live" if validate_live_cmdline_params "$missing_boot_live" linux GRUB "$BEE_ISO_VOLUME" >/dev/null 2>&1; then echo "ERROR: validator ignored a live entry without boot=live" >&2 exit 1 fi CACHE_ROOT="$TEST_ROOT/cache" BUILD_VARIANT="test" BUILD_WORK_DIR="$TEST_ROOT/work" OVERLAY_STAGE_DIR="$TEST_ROOT/overlay" DEBIAN_KERNEL_ABI="6.1.0-test" SQUASHFS_FILENAME="filesystem-v13.0-test.squashfs" DIST_DIR="$TEST_ROOT/dist" mkdir -p "$BUILD_WORK_DIR/binary/live" "$OVERLAY_STAGE_DIR" touch "$BUILD_WORK_DIR/live-image-amd64.hybrid.iso" touch "$BUILD_WORK_DIR/binary/live/$SQUASHFS_FILENAME" . "$BUILDER_DIR/lib/fast-path.sh" # Isolate the decision test from repository content and GNU find extensions. hash_heavy_config() { printf '%s\n' test-heavy-hash; } write_overlay_manifest() { find "$OVERLAY_STAGE_DIR" -mindepth 1 -print | sed "s#^$OVERLAY_STAGE_DIR/##" | sort > "$1"; } printf '%s\n' test-heavy-hash > "$FULL_BUILD_HASH_FILE" printf '%s\n' "$DEBIAN_KERNEL_ABI" > "$FULL_BUILD_ABI_FILE" write_overlay_manifest "$FULL_BUILD_OVERLAY_MANIFEST" touch "$FULL_BUILD_MARKER" if needs_full_build; then echo "ERROR: fast path was rejected for unchanged valid state" >&2 exit 1 fi touch "$OVERLAY_STAGE_DIR/added-by-fast-path" if needs_full_build; then echo "ERROR: an additive overlay change unnecessarily forced a full build" >&2 exit 1 fi write_overlay_manifest "$FULL_BUILD_OVERLAY_MANIFEST" rm "$OVERLAY_STAGE_DIR/added-by-fast-path" if ! needs_full_build >/dev/null; then echo "ERROR: removal from the latest fast-path overlay was not detected" >&2 exit 1 fi touch "$OVERLAY_STAGE_DIR/added-by-fast-path" printf '%s\n' different-abi > "$FULL_BUILD_ABI_FILE" if ! needs_full_build >/dev/null; then echo "ERROR: kernel ABI change did not force a full build" >&2 exit 1 fi echo "build library tests: OK"