#!/usr/bin/env bash # ───────────────────────────────────────────────────────────────────────────── # Arcline OS — fast, offline validation of the build tree. # # scripts/validate.sh # # Runs on any machine (no root, no network). Checks: # * every shell script parses (bash -n) # * every edition has a complete manifest (metadata, packages, cmdline, fstab) # * package lists reference no obvious duplicate lines # * the Makefile + versions.mk parse # ───────────────────────────────────────────────────────────────────────────── set -euo pipefail source "$(dirname "${BASH_SOURCE[0]}")/common.sh" fail=0 note_fail() { warn "$1"; fail=1; } log "validating shell scripts…" while IFS= read -r -d '' s; do if ! bash -n "$s"; then note_fail "syntax error in $s" fi done < <(find "$ROOT/scripts" "$ROOT/btrfs" "$ROOT/toolchain" "$ROOT/tests" "$ROOT/overlays" \ -type f \( -name '*.sh' -o -name 'arcline-installer-session' \) -print0 2>/dev/null) log "validating installer (python syntax)…" if command -v python3 >/dev/null 2>&1; then python3 -m py_compile "$ROOT/installer/arcline-installer" 2>/dev/null \ || note_fail "python syntax error in installer/arcline-installer" rm -rf "$ROOT/installer/__pycache__" fi log "validating editions…" for e in "${EDITIONS[@]}"; do ed="$(edition_dir "$e")" for f in metadata.yaml packages.list kernel.cmdline fstab; do [[ -f "$ed/$f" ]] || note_fail "edition '$e' missing $f" done # package list sanity: no blank-or-comment duplicates if [[ -f "$ed/packages.list" ]]; then dup="$(grep -vE '^\s*(#|$)' "$ed/packages.list" | sort | uniq -d)" [[ -z "$dup" ]] || note_fail "edition '$e' has duplicate package entries: $(echo "$dup" | tr '\n' ' ')" fi done log "validating top-level Makefile / versions.mk…" make -C "$ROOT" -n check >/dev/null 2>&1 || note_fail "Makefile dry-run failed (make -n check)" log "validating YAML manifests (if python3 + pyyaml available)…" if python3 -c 'import yaml' 2>/dev/null; then python3 - "$ROOT" <<'PYEOF' || note_fail "YAML manifest parse failed" import sys, glob, yaml root = sys.argv[1] for f in sorted(glob.glob(root + "/editions/*/metadata.yaml")): d = yaml.safe_load(open(f)) assert d.get("edition") and d.get("codename"), f"{f}: missing edition/codename" assert d.get("image", {}).get("type"), f"{f}: missing image.type" assert "services" in d, f"{f}: missing services" assert isinstance(d["services"].get("enabled", []), list) PYEOF else warn "python3/pyyaml not available — skipping YAML parse (structural checks above still apply)" fi if [[ $fail -eq 0 ]]; then log "validation passed ✓" else die "validation found problems" fi