Files
RedBear-OS/mk/redbear.mk
T
vasilito de44b9324e feat: build-system resilience (fetch retry, strict cache parse, auto_deps preserve, Tier 1 messages)
Tier 3 code improvements (from BUILD-SYSTEM-ASSESSMENT-2026-07-18 Part 6.2):

- Q2: Add run_command_with_retry() helper with exponential backoff (1s, 2s, 4s).
  Wrap download_wget and git clone with 3 attempts. Git clone closure cleans
  partial tmp dir between retries (git refuses non-empty clone targets).

- Q3: Preserve auto_deps.toml alongside dep_hashes.toml in binary store publish
  (repo_builder.rs). Restore path prefers the preserved copy, falling back to
  declared-depends-only reconstruction only when the preserved copy is absent
  (e.g. published by an older cookbook). Preserves full ELF dynamic dep graph.

- Q4: DepHashes::read now returns Result<Option<Self>, String> discriminating
  'missing' (legitimate first build, fall back to mtime) from 'corrupt' (loud
  WARN + force rebuild). Closes a silent-swallow gap where a corrupt
  dep_hashes.toml produced an incorrect mtime-fallback rebuild.

- Q6: Standardize error reporting in repo.rs nonstop path to {:#} format,
  matching the pattern established in the earlier Tier 1 message commit.

Tier 1 message fixes (remaining items from assessment Part 5.3/5.4):

- M26: build-redbear.sh:569 '30-60 minutes' -> config-dependent range
- A6/A8: Makefile container messages add remediation hint
- B3: mk/config.mk sccache hint adds install guidance
- H2: mk/qemu.mk Unsupported ARCH lists supported values
- mk/redbear.mk comment 'fully-patched' -> 'versioned'

Verification: cargo check 0 errors, cargo test --lib 35/35 passed,
cargo clippy 0 new warnings vs baseline, make -n live + validate clean.
2026-07-18 16:54:24 +09:00

51 lines
1.9 KiB
Makefile

# Red Bear OS integration — runs before repo cook and disk image creation
# Ensures all custom recipe symlinks, patches, assets, and firmware are staged.
REDBEAR_TAG=$(BUILD)/redbear.tag
REDBEAR_FP=$(REDBEAR_TAG).fp
REDBEAR_INPUTS = local/scripts/integrate-redbear.sh local/recipes local/Assets local/firmware
# FORCE is retained so Make evaluates this recipe on every build. The fingerprint
# check inside the recipe decides whether the expensive integration actually
# runs. Removing FORCE would break detection of newly-added files under
# local/recipes/ because Make's mtime model cannot track directory-tree growth.
$(REDBEAR_TAG): FORCE
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
@current=$$(find $(REDBEAR_INPUTS) -type f -printf '%P %s %T@\n' 2>/dev/null | sort | sha256sum | cut -d' ' -f1); \
stored=""; \
if [ -f "$(REDBEAR_FP)" ]; then stored=$$(cat "$(REDBEAR_FP)" 2>/dev/null); fi; \
if [ "$$current" = "$$stored" ] && [ -f "$@" ]; then \
touch "$@"; \
else \
echo "Red Bear: integration inputs changed (or first run), executing integrate-redbear.sh..."; \
bash -c 'export REDBEAR_TAG="$$1"; exec bash local/scripts/integrate-redbear.sh' _ '$(REDBEAR_TAG)'; \
echo "$$current" > "$(REDBEAR_FP)"; \
fi
endif
redbear: $(REDBEAR_TAG)
redbear_clean:
rm -f "$(REDBEAR_TAG)" "$(REDBEAR_FP)"
# Source archival — exports versioned source archives
# for all recipes with source/ directories to sources/<target>/
# Runs after `make all` and also standalone via `make sources`
SOURCES_DIR=$(BUILD)/../sources/$(TARGET)
SOURCES_TAG=$(SOURCES_DIR)/.sources-tag
# Standalone: archive what's cached (no rebuild needed)
sources:
@echo "Archiving source packages..."
bash local/scripts/archive-sources.sh --all
@mkdir -p "$(SOURCES_DIR)"
@touch "$(SOURCES_TAG)"
@echo "Sources archived: $$(wc -l < $(SOURCES_DIR)/packages.txt 2>/dev/null || echo 0) packages"
# Hook: run after full build
$(BUILD)/harddrive.img: sources
FORCE: