#!/usr/bin/env bash # Smoke: assert macOS product pkg carries product ID, Verae branding, license UI. # Prefer an existing dist pkg; else build unsigned with SKIP_SIGN=1. set -euo pipefail PKG_DIR="$(cd "$(dirname "$0")" && pwd)" ROOT="$(cd "$PKG_DIR/../../.." && pwd)" DIST="$ROOT/build/macos-pkg/dist" VERSION="${VERSION:-}" if [[ -z "$VERSION" && -f "$ROOT/internal/job/job.go" ]]; then VERSION="$(grep -E 'HelperVersion[[:space:]]*=' "$ROOT/internal/job/job.go" | head -1 | sed -E 's/.*"([^"]+)".*/\1/')" fi VERSION="${VERSION:-0.3.6}" PRODUCT="${1:-}" if [[ -z "$PRODUCT" ]]; then if [[ -f "$DIST/VeraePrintStamp-${VERSION}.pkg" ]]; then PRODUCT="$DIST/VeraePrintStamp-${VERSION}.pkg" elif [[ -f "$DIST/VeraePrintStamp-macos.pkg" ]]; then PRODUCT="$DIST/VeraePrintStamp-macos.pkg" else echo "→ no existing pkg; building unsigned product (SKIP_SIGN=1)" SKIP_SIGN=1 "$PKG_DIR/build-pkg.sh" PRODUCT="$DIST/VeraePrintStamp-${VERSION}.pkg" fi fi echo "→ smoke installer UI: $PRODUCT" TMP="$(mktemp -d /tmp/verae-pkg-smoke.XXXXXX)" trap 'rm -rf "$TMP"' EXIT pkgutil --expand "$PRODUCT" "$TMP/exp" pass=0 fail=0 check() { local id="$1"; shift if "$@" >/dev/null 2>&1; then echo " PASS $id" pass=$((pass+1)) else echo " FAIL $id" fail=$((fail+1)) fi } has_file() { local name="$1" local f f="$(find "$TMP/exp" -name "$name" -print -quit 2>/dev/null || true)" [[ -n "$f" && -s "$f" ]] } find_one() { find "$TMP/exp" -name "$1" -print -quit 2>/dev/null || true } DIST_FILE="" if [[ -f "$TMP/exp/Distribution" ]]; then DIST_FILE="$TMP/exp/Distribution" elif [[ -f "$TMP/exp/Distribution.xml" ]]; then DIST_FILE="$TMP/exp/Distribution.xml" fi check has-distribution test -n "$DIST_FILE" -a -s "${DIST_FILE:-/dev/null}" check title-verae grep -q 'Verae Print Stamp' "$DIST_FILE" check product-id grep -q 'ai.verae.print-stamp' "$DIST_FILE" check license-ref grep -qi 'license' "$DIST_FILE" check welcome-ref grep -qi 'welcome' "$DIST_FILE" check readme-ref grep -qi 'readme' "$DIST_FILE" check background-ref grep -qi 'background' "$DIST_FILE" check welcome-html has_file welcome.html check license-html has_file license.html check readme-html has_file readme.html check conclusion-html has_file conclusion.html check background-png has_file background.png WELCOME="$(find_one welcome.html)" LICENSE="$(find_one license.html)" README="$(find_one readme.html)" check welcome-branding grep -Eq '531B59|Verae branded|Product ID' "$WELCOME" check license-accept grep -Eiq 'accept|Agree|License Agreement' "$LICENSE" check readme-product-id grep -q 'ai.verae.print-stamp' "$README" echo "════════════════════════════════" echo " installer-ui PASS=$pass FAIL=$fail" [[ "$fail" -eq 0 ]]