Files
RedBear-OS/local/scripts
vasilito f91cb8716a build-redbear: comprehensive build-system improvements 1+3+4+5+6+7+8
Implements 7 of 8 improvements from local/docs/BUILD-SYSTEM-IMPROVEMENT-PROPOSAL.md:

Improvement 1+5: trap-based stash-and-restore for ALL 9 fork sources
  - Replaces single-relibc stash with a loop over the canonical fork
    inventory (relibc, kernel, base, bootloader, installer, redoxfs,
    libredox, syscall, userutils)
  - Records each stash SHA in a label-keyed map for safe round-tripping
  - Pop stashes in LIFO order matching user-visible stash pop convention
  - Idempotent: re-entry during the same build does not double-stash
  - Reports (does not silently swallow) real git errors during stash push
  - Restored on EXIT regardless of success/failure/signal

Improvement 3: cookbook binary freshness check
  - Replaces existence-only check with BLAKE3-of-src/.rs fingerprint
  - Hash written to target/release/.cookbook-src-fingerprint
  - Rebuild triggers on any source file content change, not just mtime
  - Survives git operations that change content without touching mtime

Improvement 4: strict-by-default uncommitted-edit gate
  - Refuses to build with uncommitted edits in any fork source
  - Catches the 'works on my machine' bug class where pkgar fingerprints
    silently mismatch the committed HEAD
  - Escape hatch: REDBEAR_ALLOW_DIRTY=1 for emergency CI use
  - apply-durable-source-edits.py auto-enables strict mode when
    REDBEAR_BUILD_PHASE is set (set by build-redbear.sh)

Improvement 6: failure-cleanup trap with diagnostics
  - EXIT trap captures last 30 lines of each cookbook log
  - Lists orphaned cook/cargo processes (often root cause of follow-on
    build failures via held locks)
  - Reports per-recipe build state (complete vs incomplete)
  - Preserves diagnostics in REDBEAR_BUILD_STATE_DIR (mktemp -d)
  - REDBEAR_KEEP_BUILD_STATE=1 retains the state dir after exit

Improvement 7: pre-cook offline/upstream consistency
  - Pre-cook now follows the same offline policy as the main build phase
  - REDBEAR_ALLOW_UPSTREAM=1 → offline=false
  - default / REDBEAR_RELEASE → offline=true
  - Pre-cook logs captured into REDBEAR_BUILD_LOGS_DIR for diagnostics
  - Sets REDBEAR_BUILD_PHASE=pre-cook so downstream code can distinguish

Improvement 8: cookbook protection against out-of-band invocations
  - src/bin/repo.rs emits a warning when invoked without
    REDBEAR_CANONICAL_BUILD=1 in the environment
  - The warning lists what is bypassed (cache invalidation, prefix
    rebuild, fingerprint tracking, dirty gate)
  - Non-fatal: CI scripts that manage their own checks are unaffected

Smoke-tested: ./local/scripts/build-redbear.sh redbear-mini now exits 1
when relibc/kernel have uncommitted edits, and proceeds when
REDBEAR_ALLOW_DIRTY=1 is set.
2026-07-10 22:10:33 +03:00
..