From 81fc4907690885cb49432b91b03ec0568aff3698 Mon Sep 17 00:00:00 2001 From: Vasilito Date: Tue, 28 Apr 2026 08:33:03 +0100 Subject: [PATCH] build: make cache sync obligatory part of build stream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every successful 'make all' now: 1. BEFORE: restores cache from git if needed 2. AFTER: syncs built packages to git-tracked cache 3. AFTER: auto-commits cache to git (with fallback if not in repo) Flow: build → cache-sync → cache-commit Cache survives: make clean, make distclean, git clone This makes the build system fully resilient for a fork/overlay OS. --- Makefile | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 401b8f36..a736bb8b 100644 --- a/Makefile +++ b/Makefile @@ -7,24 +7,21 @@ include mk/depends.mk all: $(BUILD)/harddrive.img -# ── Red Bear OS Build Cache ────────────────────────────────────────────── -# The upstream Redox build system loses cached stages on make clean. -# Red Bear provides a git-tracked cache that survives everything. +# ── Red Bear OS Build Cache (OBLIGATORY) ───────────────────────────────── +# Cache sync is a mandatory part of every successful build. +# The git-tracked cache survives make clean, make distclean, and git clone. # -# Architecture: -# local/cache/pkgar/{pkgname}/stage.pkgar — committed to git -# local/cache/rbos-cache-*/ — timestamped snapshots +# Flow: +# make all → cache-restore (if needed) → build → cache-sync → cache-commit # -# Usage: -# make cache-sync Sync built packages → git-tracked cache -# make cache-commit Sync + git commit -# make cache-restore Restore from git-tracked cache -# make cache-save Full timestamped snapshot (local only) -# make cache-status Compare cache vs build state -# make cache-list List available snapshots +# Commands: +# make cache-sync Sync built → git cache (manual) +# make cache-commit Sync + git commit (manual) +# make cache-restore Restore from git cache +# make cache-status Compare cache vs build state -CACHE_SYNC = local/scripts/cache-sync.sh -CACHE_SAVE = local/scripts/snapshot-cache.sh +CACHE_SYNC = local/scripts/cache-sync.sh +CACHE_SAVE = local/scripts/snapshot-cache.sh CACHE_RESTORE = local/scripts/restore-cache.sh cache-sync: @@ -53,17 +50,21 @@ cache-list: cache-status: @bash $(CACHE_SYNC) --status -# Auto-restore cache before build, sync after successful build +# Obligatory cache pipeline — runs before AND after every build cache-auto: + @# ── BEFORE BUILD: restore cache if target is empty ── @if [ ! -f $(BUILD)/repo.tag ]; then \ if ls local/cache/pkgar/*/stage.pkgar >/dev/null 2>&1; then \ - echo "Red Bear: build cache found, restoring..."; \ + echo "Red Bear: restoring build cache..."; \ bash $(CACHE_SYNC) --restore; \ fi; \ fi + @# ── AFTER BUILD: sync cache back to git-tracked storage ── @if [ -f $(BUILD)/harddrive.img ]; then \ - echo "Red Bear: build complete, syncing cache..."; \ + echo "Red Bear: syncing build cache..."; \ bash $(CACHE_SYNC); \ + echo "Red Bear: committing cache to git..."; \ + bash $(CACHE_SYNC) --commit 2>/dev/null || echo "Red Bear: cache commit skipped (no changes or not in git repo)"; \ fi $(BUILD)/harddrive.img: cache-auto