build: Red Bear cache system — resilient to make clean

Adds comprehensive build cache snapshot and restore for overlay OS.

Problem: Upstream Redox build system is single-stream — make clean
destroys cached stage.pkgar files permanently. Build can't recover
without full from-scratch rebuild (2-4 hours).

Solution: Red Bear cache system provides:
- snapshot-cache.sh: Save all stage.pkgar to local/cache/
- restore-cache.sh: Restore from snapshot after make clean
- Auto-restore: Makefile auto-restores cache before build
- Essential cache: Pre-built caches for boot packages tracked in git
- Cookbook fixes: Missing deps trigger rebuild instead of crash

With cache restore, make clean recovery is measured in seconds,
not hours.

Gaps fixed in cookbook:
- modified_all_btree: missing dep → UNIX_EPOCH (rebuild trigger)
- sysroot install: missing dep → skip + rebuild
This commit is contained in:
2026-04-28 08:07:14 +01:00
parent 525f008d60
commit d1c5beb50d
5 changed files with 271 additions and 0 deletions
+39
View File
@@ -7,6 +7,45 @@ 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 snapshot/restore so the build can recover quickly.
# Essential package caches are tracked in git under local/cache/essential/.
#
# Usage:
# make cache-save Save full cache snapshot
# make cache-save-essential Save only essential (boot) packages
# make cache-restore Auto-restore latest cache before build
# make cache-verify Check cache integrity
CACHE_SCRIPT = local/scripts/snapshot-cache.sh
RESTORE_SCRIPT = local/scripts/restore-cache.sh
cache-save:
@bash $(CACHE_SCRIPT)
cache-save-essential:
@bash $(CACHE_SCRIPT) --essential
cache-restore:
@bash $(RESTORE_SCRIPT)
cache-verify:
@bash $(RESTORE_SCRIPT) --verify
cache-list:
@bash $(CACHE_SCRIPT) --list
# Auto-restore cache if available (runs before all builds)
cache-auto:
@if [ -d local/cache ] && ls local/cache/rbos-cache-* >/dev/null 2>&1; then \
echo "Red Bear: restoring build cache..."; \
bash $(RESTORE_SCRIPT); \
fi
# Ensure cache is restored before build
$(BUILD)/harddrive.img: cache-auto
live:
-$(FUMOUNT) $(BUILD)/filesystem/ || true
-$(FUMOUNT) /tmp/redbear_installer/ || true