| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- #!/usr/bin/env bash
- # Run the four required installer scenarios in one disposable Debian systemd container.
- set -euo pipefail
- if [[ $# -ne 3 ]]; then
- echo "Usage: $0 NEW_ARCHIVE PREVIOUS_V0.1.1_ARCHIVE OUTPUT_DIR" >&2
- exit 2
- fi
- NEW_ARCHIVE="$(realpath -e -- "$1")"
- OLD_ARCHIVE="$(realpath -e -- "$2")"
- OUTPUT_DIR="$(realpath -m -- "$3")"
- SYSTEMD_IMAGE="${HTH_SYSTEMD_TEST_IMAGE:-localhost/hth-systemd-test:debian13}"
- RUN_ID="hth-install-matrix-$(date -u +%Y%m%dT%H%M%SZ)-$$"
- CONTAINER="$RUN_ID"
- LOG="$OUTPUT_DIR/matrix.log"
- RECEIPT="$OUTPUT_DIR/matrix-receipt.txt"
- command -v podman >/dev/null 2>&1 || { echo "podman is required" >&2; exit 2; }
- podman image exists "$SYSTEMD_IMAGE" || {
- echo "missing disposable systemd test image: $SYSTEMD_IMAGE" >&2
- exit 2
- }
- mkdir -p "$OUTPUT_DIR"
- : >"$LOG"
- cleanup() { podman rm -f "$CONTAINER" >/dev/null 2>&1 || true; }
- trap cleanup EXIT
- NEW_SHA="$(sha256sum "$NEW_ARCHIVE" | awk '{print $1}')"
- OLD_SHA="$(sha256sum "$OLD_ARCHIVE" | awk '{print $1}')"
- IMAGE_ID="$(podman image inspect --format '{{.Id}}' "$SYSTEMD_IMAGE")"
- podman run -d --name "$CONTAINER" --privileged --systemd=always --tmpfs /run --tmpfs /run/lock -v "$NEW_ARCHIVE:/packages/new.tar.gz:ro" -v "$OLD_ARCHIVE:/packages/old.tar.gz:ro" "$SYSTEMD_IMAGE" /sbin/init >/dev/null
- for _ in $(seq 1 100); do
- if podman exec "$CONTAINER" systemctl is-system-running >/dev/null 2>&1; then break; fi
- sleep 0.1
- done
- podman exec "$CONTAINER" bash -lc "
- set -e
- mkdir -p /opt/matrix/new /opt/matrix/old
- tar -xzf /packages/new.tar.gz -C /opt/matrix/new
- tar -xzf /packages/old.tar.gz -C /opt/matrix/old
- chmod +x /opt/matrix/new/*/*.sh /opt/matrix/old/*/*.sh
- " 2>&1 | tee -a "$LOG"
- run_guest() {
- local label="$1" command_text="$2"
- echo "${label}_BEGIN" | tee -a "$LOG"
- podman exec "$CONTAINER" bash -lc "$command_text" 2>&1 | tee -a "$LOG"
- echo "${label}_PASS" | tee -a "$LOG"
- }
- run_guest SCENARIO_FRESH '
- set -e
- cd /opt/matrix/new/*
- ./install.sh
- ./verify-install.sh --no-escalate
- '
- run_guest SCENARIO_REINSTALL '
- set -e
- cd /opt/matrix/new/*
- ./install.sh
- ./verify-install.sh --no-escalate
- '
- run_guest SCENARIO_PURGE_REINSTALL '
- set -e
- cd /opt/matrix/new/*
- ./uninstall.sh --purge --yes
- ./install.sh
- ./verify-install.sh --no-escalate
- '
- run_guest SCENARIO_UPGRADE '
- set -e
- cd /opt/matrix/new/*
- ./uninstall.sh --purge --yes
- cd /opt/matrix/old/*
- if ./install.sh --backend mock >/tmp/previous-install.log 2>&1; then
- previous_direct=PASS
- else
- previous_direct=KNOWN_PROFILE_PERMISSION_FAILURE
- systemctl stop hthd.service >/dev/null 2>&1 || true
- chgrp hth /etc/hth/profiles/prod2u-door-temp/profile.json
- chmod 0640 /etc/hth/profiles/prod2u-door-temp/profile.json
- systemctl start hthd.service
- fi
- systemctl is-active --quiet hthd.service
- /usr/local/bin/hthctl --observe-sock /run/hth/observe/observe.sock --timeout 5s devices >/dev/null
- echo "PREVIOUS_RELEASE_RUNNING tag=v0.1.1 commit=7128a205a5cf70256bf6bb3cc87068b1d03e7fd4 direct_install=$previous_direct"
- cd /opt/matrix/new/*
- ./install.sh --upgrade
- ./verify-install.sh --no-escalate
- '
- run_guest SCENARIO_UPGRADE_FROM_FAILED_OLD '
- set -e
- cd /opt/matrix/new/*
- ./uninstall.sh --purge --yes
- cd /opt/matrix/old/*
- if ./install.sh --backend mock >/tmp/previous-failed-install.log 2>&1; then
- echo "expected v0.1.1 permission failure was not reproduced" >&2
- exit 1
- fi
- grep -q "Job for hthd.service failed" /tmp/previous-failed-install.log
- cd /opt/matrix/new/*
- ./install.sh --upgrade
- ./verify-install.sh --no-escalate
- '
- {
- echo "schema=hth-install-matrix-receipt-v1"
- echo "status=PASS"
- echo "run_id=$RUN_ID"
- echo "systemd_image=$SYSTEMD_IMAGE"
- echo "systemd_image_id=$IMAGE_ID"
- echo "new_archive=$NEW_ARCHIVE"
- echo "new_archive_sha256=$NEW_SHA"
- echo "previous_release_tag=v0.1.1"
- echo "previous_release_commit=7128a205a5cf70256bf6bb3cc87068b1d03e7fd4"
- echo "previous_archive=$OLD_ARCHIVE"
- echo "previous_archive_sha256=$OLD_SHA"
- echo "fresh_install=PASS"
- echo "same_version_reinstall=PASS"
- echo "purge_reinstall=PASS"
- echo "previous_release_upgrade=PASS"
- echo "upgrade_from_failed_previous_install=PASS"
- echo "hardware_validation=NOT RUN"
- echo "com_validation=NOT RUN"
- echo "jtag_validation=NOT RUN"
- echo "real_thermal_performance=NOT RUN"
- echo "generated_at_utc=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
- echo "log_sha256=$(sha256sum "$LOG" | awk '{print $1}')"
- } >"$RECEIPT"
- cat "$RECEIPT"
- echo "HTH_INSTALL_MATRIX_PASS"
|