From 019c0f40e9668703986d638f8e6d415d6224ab4a Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Mon, 18 May 2026 05:47:27 +0200 Subject: [PATCH] artifact-rootfs: surface git-log failure when computing configng hash Original code masked git failures with `|| echo "unknown"` - the build silently fell through to a degraded cache key without telling the operator anything. A torn cache/sources/armbian-configng clone, broken HEAD, or permissions glitch was indistinguishable from a healthy "couldn't compute" state. Capture stdout+stderr from git log, branch on exit status, and display_alert the git error text when rc != 0. Still falls through to "unknown" so the build completes - this is a best-effort caching knob, not a build-blocker, and the downstream check in create-cache.sh already skips the fingerprint fold on "unknown". Scope kept exactly as before: BUILD_DESKTOP=yes only, path-filtered to tools/modules/desktops/. CLI builds don't invoke armbian-config at build time and configng content outside the desktop subtree doesn't reach the rootfs from a build-time path, so broadening the filter would only churn cache for no benefit. Comment touch-up in create-cache.sh documents that scoping for future readers. --- lib/functions/artifacts/artifact-rootfs.sh | 25 ++++++++++++++++++++-- lib/functions/rootfs/create-cache.sh | 4 +++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/functions/artifacts/artifact-rootfs.sh b/lib/functions/artifacts/artifact-rootfs.sh index 0a1bc6c73e0f..ffd2405e482e 100644 --- a/lib/functions/artifacts/artifact-rootfs.sh +++ b/lib/functions/artifacts/artifact-rootfs.sh @@ -18,12 +18,33 @@ function artifact_rootfs_config_dump() { # Track the latest commit touching configng's desktop definitions. # Any change to YAML, parser, or module code in tools/modules/desktops/ # invalidates the desktop rootfs cache — the package list, browser - # mapping, tier overrides, or branding may have changed. + # mapping, tier overrides, or branding may have changed. Scoped to + # desktop builds and the desktop subtree because armbian-config is + # only invoked at build time for desktop installs + # (`module_desktops install mode=build`); for CLI builds the .deb + # is just installed and its contents don't affect the rootfs. if [[ "${BUILD_DESKTOP}" == "yes" ]]; then declare configng_desktops_hash="undetermined" local configng_dir="${SRC}/cache/sources/armbian-configng" if [[ -d "${configng_dir}/.git" ]]; then - configng_desktops_hash="$(git -C "${configng_dir}" log -1 --format=%H -- tools/modules/desktops/ 2>/dev/null || echo "unknown")" + # Capture stdout + stderr, then branch on exit status. This is + # a best-effort knob for cache-invalidation, not a build + # blocker - if git can't read this clone (torn checkout, + # stale files, broken HEAD, permissions), we warn and fall + # through to "unknown" rather than aborting an hour-long + # build. The downstream check in create-cache.sh skips the + # fingerprint fold on "unknown" / "undetermined" — the + # build still produces a valid image, it just doesn't get + # the configng-aware cache bust. + declare git_out git_rc + git_out="$(git -C "${configng_dir}" log -1 --format=%H -- tools/modules/desktops/ 2>&1)" + git_rc=$? + if (( git_rc == 0 )); then + configng_desktops_hash="${git_out}" + else + display_alert "configng_desktops hash: git log failed (rc=${git_rc}) in ${configng_dir}" "${git_out}" "warn" + configng_desktops_hash="unknown" + fi fi artifact_input_variables[CONFIGNG_DESKTOPS_HASH]="${configng_desktops_hash}" fi diff --git a/lib/functions/rootfs/create-cache.sh b/lib/functions/rootfs/create-cache.sh index eafd7aed5eb5..2c9f4905c1a5 100644 --- a/lib/functions/rootfs/create-cache.sh +++ b/lib/functions/rootfs/create-cache.sh @@ -57,7 +57,9 @@ function calculate_rootfs_cache_id() { # this, a configng commit that changes which packages a DE # installs leaves the existing rootfs tarball untouched in the # cache and every subsequent build cache-hits the pre-change - # version. + # version. Scoped to desktop builds: CLI images don't invoke + # armbian-config at build time, so configng content doesn't + # affect their rootfs. # # CONFIGNG_DESKTOPS_HASH is set by artifact_rootfs_config_dump # above from `git log -1 -- tools/modules/desktops/` in the