#!/usr/bin/env bash # Build one Marqdo Harness candidate archive and verify it from a cold extract. # # The archive is a prebuilt portable tree: the forked DSH source, its production # node_modules layout and the built lib/web artifacts. It contains no Marqdo # CLI/stdlib/ext/tool implementation; those are installed at runtime from # trusted releases into MDH_HOME. A user needs Node 24 and nothing else: no # pnpm install, no Rust, no source build. set -euo pipefail cd "$(dirname "$0")/.." root="$PWD" out="${MARQDO_CI_OUT:-$root/.ci}" mkdir -p "$out" stage="$(mktemp -d "${TMPDIR:-/tmp}/mdh-package.XXXXXX")" verify="$(mktemp -d "${TMPDIR:-/tmp}/mdh-cold.XXXXXX")" trap 'rm -rf "$stage" "$verify"' EXIT test -f apps/cli/lib/bin.js || { echo "build artifacts missing; run pnpm run build" >&2; exit 1; } test -f apps/web/dist/index.html || { echo "web build missing; run pnpm run build" >&2; exit 1; } name="marqdo-harness-$(git rev-parse --short HEAD)-x86_64-unknown-linux-gnu" app="$stage/$name" mkdir -p "$app" # Copy the prebuilt tree without VCS data or local scratch. tar -C "$root" -cf - \ --exclude=.git --exclude=.ci --exclude=.integration-work --exclude=.issue-work \ --exclude=node_modules/.cache --exclude='*.log' . | tar -C "$app" -xf - cat > "$app/mdh" <<'SH' #!/usr/bin/env bash set -euo pipefail here="$(cd "$(dirname "$0")" && pwd)" exec node "$here/scripts/mdh.mjs" "$@" SH chmod 755 "$app/mdh" # A cold extract with a fresh home and no developer checkout must compose the # single product profile without network access. export MDH_HOME="$verify/home" "$app/mdh" --dump-config > "$verify/dump.yml" 2> "$verify/dump.err" grep -q 'mdh-harness' "$verify/dump.yml" grep -q 'mdh-web' "$verify/dump.yml" test -s "$verify/dump.yml" archive="$out/$name.tar.gz" tar -czf "$archive" -C "$stage" "$name" sha256sum "$archive" | tee "$out/$name.tar.gz.sha256" stat -c '%n %s bytes' "$archive" python3 - "$archive" "$verify/dump.yml" <<'PY' import hashlib, json, pathlib, subprocess, sys archive = pathlib.Path(sys.argv[1]) record = { 'schema': 'marqdo.mdh.package-evidence', 'schema_version': 1, 'status': 'PASS', 'archive': archive.name, 'size': archive.stat().st_size, 'sha256': hashlib.sha256(archive.read_bytes()).hexdigest(), 'application_sha': subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip(), 'platform': 'x86_64-unknown-linux-gnu', 'node': subprocess.check_output(['node', '--version'], text=True).strip(), 'cold_compose': 'PASS', 'contains_marqdo_cli_source': False, 'unverified': ['signature', 'installer on a second clean host', 'real model E2E'], } (archive.parent / 'package-evidence.json').write_text(json.dumps(record, indent=2) + '\n') print(json.dumps(record, indent=2)) PY