diff --git a/scripts/gnome/hydrate-gnome.sh b/scripts/gnome/hydrate-gnome.sh new file mode 100755 index 00000000..b1d5845c --- /dev/null +++ b/scripts/gnome/hydrate-gnome.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +# hydrate-gnome.sh — proyecta al FHS el cierre de runtime de una receta GNOME, desde artefactos +# SELLADOS del store, sin rebuild ni reproduce (`hammer hydrate --into`). +# +# DIFERENCIA CON scripts/kde/hydrate-from-store.sh, y por qué importa: aquél resuelve el cierre desde +# un `index.json` de repo y elige el artefacto por MTIME con un CUTOFF ("el más nuevo anterior a hoy"). +# Eso es una heurística: si dos artefactos del mismo paquete conviven en el store, la fecha no dice +# cuál corresponde a la receta VIGENTE. Acá el cierre sale del GRAFO REAL de recetas (`[deps].build`, +# resolución hermano→padre, la misma que usa hammer) y el artefacto se elige por `hammer hash`, que +# calcula el ArtifactHash de la receta de HOY sin construir. O sea: cero ambigüedad, y si falta algo +# el reporte dice exactamente qué receta y con qué hash lo buscaba. +# +# Uso: scripts/gnome/hydrate-gnome.sh [receta.toml ...] +# Env: RFS (def work/gnome-rootfs) destino +# STORE (def ./store) +# LINK (def static) static=hardlink | dynamic=patchelf +# KEEP (def 0) 1 = no borrar el RFS previo +set -uo pipefail +ROOT="$(cd "$(dirname "$0")/../.." && pwd)"; cd "$ROOT" +RFS="${RFS:-work/gnome-rootfs}"; STORE="${STORE:-./store}"; LINK="${LINK:-static}" +HAMMER="${HAMMER:-./target/release/hammer}"; KEEP="${KEEP:-0}" +TARGETS=("${@:-recipes/incoming-gnome/gnome-shell.toml}") + +# ── cierre transitivo por el grafo de recetas, en orden topológico ────────────────────────────── +PLAN=$(python3 - "${TARGETS[@]}" <<'PY' +import sys, tomllib +from pathlib import Path + +def resolve(base_dir: Path, dep: str) -> Path | None: + """Misma regla que hammer_build::resolve_dep_path: HERMANO primero, luego el catálogo PADRE. + Nunca de reojo a otra cola — por eso icu4c hubo que copiarla a incoming-gnome/.""" + sib = base_dir / f"{dep}.toml" + if sib.exists(): + return sib + par = base_dir.parent / f"{dep}.toml" + return par if par.exists() else None + +seen, order, missing = set(), [], [] + +def visit(path: Path): + p = path.resolve() + if p in seen: + return + seen.add(p) + try: + r = tomllib.loads(p.read_text()) + except Exception as e: + print(f"!PARSE\t{p}\t{e}", file=sys.stderr) + return + for d in r.get("deps", {}).get("build", []): + q = resolve(p.parent, d) + if q is None: + missing.append((p.name, d)) + else: + visit(q) + order.append((p, r.get("name", p.stem))) + +for t in sys.argv[1:]: + visit(Path(t)) + +for recipe, dep in missing: + print(f"!NORECIPE\t{recipe}\t{dep}", file=sys.stderr) +for p, name in order: + print(f"{p}\t{name}") +PY +) + +[ "$KEEP" = 1 ] || rm -rf "$RFS" +mkdir -p "$RFS" +total=$(printf '%s\n' "$PLAN" | grep -c . || true) +echo "==> cierre de ${TARGETS[*]}: $total recetas → $RFS (link=$LINK)" + +ok=0; miss=0; MISSING="" +while IFS=$'\t' read -r path name; do + [ -n "$path" ] || continue + h=$("$HAMMER" --store "$STORE" hash "$path" 2>/dev/null | tail -1) + if [ -z "$h" ]; then + printf " ✗ %-28s (hash falló)\n" "$name"; miss=$((miss+1)); MISSING="$MISSING $name"; continue + fi + hex="${h#b3:}" + if [ ! -d "$STORE/$hex-$name" ]; then + printf " ✗ %-28s %s NO-SELLADO\n" "$name" "${hex:0:12}"; miss=$((miss+1)); MISSING="$MISSING $name"; continue + fi + if "$HAMMER" --store "$STORE" hydrate "$hex" --into "$RFS" --link "$LINK" >/dev/null 2>&1; then + ok=$((ok+1)) + else + printf " ✗ %-28s %s (hydrate falló)\n" "$name" "${hex:0:12}"; miss=$((miss+1)); MISSING="$MISSING $name" + fi +done <<< "$PLAN" + +echo "==> $ok proyectados · $miss faltantes" +[ -n "$MISSING" ] && echo " faltan:$MISSING" +echo " binarios: $(find "$RFS" -type f -perm -u+x 2>/dev/null | wc -l) · .so: $(find "$RFS" -name '*.so*' 2>/dev/null | wc -l) · typelibs: $(find "$RFS" -name '*.typelib' 2>/dev/null | wc -l)" +[ "$miss" = 0 ]