Skip to content

Commit 7eaba04

Browse files
committed
configng: refresh clone once, early — fix matrix-prep cache fingerprint
Three coupled changes that together fix "I pushed to configng but the new image still has the old YAML": 1) New helper `fetch_armbian_configng()` in lib/functions/configuration/config-desktop.sh. Idempotent wrapper around `fetch_from_repo` (mirror-friendly via GITHUB_SOURCE), returns early if BUILD_DESKTOP != yes, save/restores PWD, declares the locals fetch_from_repo writes to so they don't leak. 2) Call the helper from BOTH prep_conf_main_build_single (line 31, right after do_main_configuration) AND prep_conf_main_minimal_ni (line 73, same position). Previously only the full-build path ran the fetch via interactive_desktop_main_configuration; the json-info / matrix-prep path (cli-jsoninfo) silently used a stale or absent clone. 3) Revert artifact_rootfs_config_dump to a read-only consumer of the now-guaranteed-fresh on-disk clone. No fetch in there, no mid-flow side effects per artifact. Keeps the info-level breadcrumb that logs short-hash + commit subject. Also fixes a latent bug in git_ensure_safe_directory (lib/functions/general/git.sh): the gate on `[[ -e "$1/.git" ]]` caused safe.directory to be silently skipped when fetch_from_repo prepared a fresh work tree before `git init`. The subsequent checkout/clean then failed with "fatal: detected dubious ownership" in Docker-volume-mounted setups where the parent directory has a non-matching uid. Dropping the gate makes the add unconditional; setting safe.directory on a non-git path is harmless. Net effect: every code path that reads CONFIGNG_DESKTOPS_HASH now sees the actual HEAD of armbian-configng, the artifact_full_oci_target resolves correctly, CI's remote-cache lookup hits the right (or correctly-missing) tag, and full builds under Docker stop hitting the safe-directory wall.
1 parent 657d31f commit 7eaba04

4 files changed

Lines changed: 74 additions & 23 deletions

File tree

lib/functions/artifacts/artifact-rootfs.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,23 @@ function artifact_rootfs_config_dump() {
2020
# invalidates the desktop rootfs cache — the package list, browser
2121
# mapping, tier overrides, or branding may have changed.
2222
if [[ "${BUILD_DESKTOP}" == "yes" ]]; then
23+
# Read CONFIGNG_DESKTOPS_HASH from the cache/sources/armbian-configng
24+
# clone. The clone is guaranteed fresh by the fetch_armbian_configng
25+
# call in prep_conf_main_{minimal_ni,build_single} — both build
26+
# entry points refresh it before this function ever runs. Keeping
27+
# the fetch out of here (it used to live here for a couple of
28+
# revisions) means the matrix-prep path and the full-build path
29+
# converge on the same authoritative state at the same point in
30+
# time, instead of each artifact's config_dump fetching mid-flow.
2331
declare configng_desktops_hash="undetermined"
2432
local configng_dir="${SRC}/cache/sources/armbian-configng"
2533
if [[ -d "${configng_dir}/.git" ]]; then
2634
configng_desktops_hash="$(git -C "${configng_dir}" log -1 --format=%H -- tools/modules/desktops/ 2>/dev/null || echo "unknown")"
35+
# Operator-facing breadcrumb: short hash + commit subject so
36+
# build logs make the cache fingerprint trivially traceable.
37+
local configng_desktops_subject
38+
configng_desktops_subject="$(git -C "${configng_dir}" log -1 --format=%s -- tools/modules/desktops/ 2>/dev/null || true)"
39+
display_alert "configng desktops HEAD" "${configng_desktops_hash:0:12} ${configng_desktops_subject}" "info"
2740
fi
2841
artifact_input_variables[CONFIGNG_DESKTOPS_HASH]="${configng_desktops_hash}"
2942
fi

lib/functions/configuration/config-desktop.sh

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,46 @@
2525
# DESKTOP_ENVIRONMENT_CONFIG_NAME
2626
# DESKTOP_APPGROUPS_SELECTED
2727

28+
# Ensure cache/sources/armbian-configng is a fresh clone of
29+
# https://github.com/armbian/configng#main. Idempotent and safe to call
30+
# multiple times (fetch_from_repo handles initial-clone and refresh).
31+
#
32+
# Called once per build from both prep_conf_main_minimal_ni (the json-
33+
# info / matrix-prep path used by armbian/os CI) AND
34+
# prep_conf_main_build_single (full image build). Having both paths
35+
# call this guarantees CONFIGNG_DESKTOPS_HASH is computed against the
36+
# real HEAD of configng, not a stale on-disk snapshot — which was the
37+
# root cause of the "I pushed to configng but the image still has the
38+
# old YAML" class of bug.
39+
#
40+
# Save/restore PWD because fetch_from_repo cd's into the work tree and
41+
# doesn't restore. Declare fetched_revision/_ts locals because
42+
# fetch_from_repo writes to them in caller scope.
43+
#
44+
# Non-fatal: failed fetch (offline, network blip, mirror down) logs a
45+
# warning and falls through with whatever is on disk — downstream
46+
# consumers handle the "stale or missing clone" case explicitly.
47+
function fetch_armbian_configng() {
48+
[[ "${BUILD_DESKTOP}" != "yes" ]] && return 0
49+
50+
declare _save_pwd="${PWD}"
51+
declare fetched_revision="" fetched_revision_ts=""
52+
fetch_from_repo "https://github.com/armbian/configng" "armbian-configng" "branch:main" || \
53+
display_alert "armbian-configng fetch_from_repo failed" "falling back to on-disk state if any" "wrn"
54+
cd "${_save_pwd}" || true
55+
}
56+
2857
function interactive_desktop_main_configuration() {
2958
[[ $BUILD_DESKTOP != "yes" ]] && return 0
3059

3160
display_alert "desktop-config" "DESKTOP_ENVIRONMENT entry: ${DESKTOP_ENVIRONMENT}" "debug"
3261

33-
# Refresh the armbian-configng clone on EVERY desktop build,
34-
# regardless of whether DESKTOP_ENVIRONMENT was pre-set. The
35-
# clone feeds two downstream consumers:
36-
#
37-
# 1. The interactive DE-selection dialog below — only fires
38-
# when DESKTOP_ENVIRONMENT is empty.
39-
# 2. artifact_rootfs_config_dump, which reads the clone's
40-
# `git log -1 -- tools/modules/desktops/` as the
41-
# CONFIGNG_DESKTOPS_HASH input that (via create-cache.sh's
42-
# cache_type) fingerprints the rootfs tarball filename.
43-
#
44-
# Keeping the fetch inside the `-z DESKTOP_ENVIRONMENT` branch
45-
# meant every non-interactive build (CI, items-from-inventory,
46-
# scripted local) skipped it — so the hash was computed against
47-
# whatever stale clone happened to be on disk and the build
48-
# happily cache-hit a pre-configng-change rootfs. Hoisting the
49-
# fetch up here makes the clone authoritative for every
50-
# BUILD_DESKTOP=yes invocation.
51-
fetch_from_repo "https://github.com/armbian/configng" "armbian-configng" "branch:main"
62+
# Refresh the armbian-configng clone before the DE-selection dialog
63+
# runs. fetch_armbian_configng is idempotent — typically already
64+
# invoked once by prep_conf_main_{minimal_ni,build_single} above
65+
# this in the call chain; re-calling here is a cheap no-op that
66+
# also handles standalone callers (e.g. plain config-only paths).
67+
fetch_armbian_configng
5268

5369
local configng_dir="${SRC}/cache/sources/armbian-configng"
5470
local yaml_dir="${configng_dir}/tools/modules/desktops/yaml"

lib/functions/general/git.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,16 @@ function improved_git_fetch() {
5555
function git_ensure_safe_directory() {
5656
if [[ -n "$(command -v git)" ]]; then
5757
local git_dir="$1"
58-
if [[ -e "$1/.git" ]]; then
59-
display_alert "git: Marking all directories as safe, which should include" "$git_dir" "debug"
60-
git config --global --get safe.directory "$1" > /dev/null || regular_git config --global --add safe.directory "$1"
61-
fi
58+
# Mark the directory safe unconditionally. The previous gate on
59+
# `-e "$1/.git"` was a bug: fetch_from_repo calls us BEFORE
60+
# running `git init`, so on a freshly-prepared work tree (no
61+
# .git yet) the safe.directory add was silently skipped — then
62+
# the subsequent `regular_git checkout/clean` after init blew
63+
# up with "fatal: detected dubious ownership". Setting
64+
# safe.directory on a non-git path is harmless; git only
65+
# consults the entry when an actual repo is accessed there.
66+
display_alert "git: Marking directory as safe" "$git_dir" "debug"
67+
git config --global --get safe.directory "$1" > /dev/null || regular_git config --global --add safe.directory "$1"
6268
else
6369
display_alert "git not installed" "a true wonder how you got this far without git - it will be installed for you" "warn"
6470
fi

lib/functions/main/config-prepare.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ function prep_conf_main_build_single() {
2828

2929
LOG_SECTION="do_main_configuration" do_with_conditional_logging do_main_configuration # This initializes the extension manager among a lot of other things, and call extension_prepare_config() hook
3030

31+
# Refresh armbian-configng once, early — needs BUILD_DESKTOP to be
32+
# authoritative (set by do_main_configuration above). The clone is a
33+
# build-wide input: feeds CONFIGNG_DESKTOPS_HASH (cache fingerprint)
34+
# AND the DE dialog AND the runtime YAML parser. Doing this here
35+
# means artifact_rootfs_config_dump can rely on a fresh on-disk
36+
# tree instead of fetching mid-flow per artifact.
37+
fetch_armbian_configng
38+
3139
interactive_desktop_main_configuration
3240
interactive_finish # cleans up vars used for interactive
3341

@@ -72,6 +80,14 @@ function prep_conf_main_minimal_ni() {
7280
allow_no_family="${allow_no_family:-"yes"}" \
7381
LOG_SECTION="do_main_configuration" do_with_conditional_logging do_main_configuration # This initializes the extension manager among a lot of other things, and call extension_prepare_config() hook
7482

83+
# Refresh armbian-configng for the non-interactive path too (matrix-
84+
# prep / json-info / cli-build's minimal config). Same rationale as
85+
# in prep_conf_main_build_single: every code path that ends up
86+
# reading CONFIGNG_DESKTOPS_HASH (from artifact_rootfs_config_dump)
87+
# needs the clone fresh, OR the OCI cache fingerprint resolves to
88+
# the wrong tag and CI ships the pre-change config.
89+
fetch_armbian_configng
90+
7591
# Required: does a lot of stuff and extension_prepare_config() hook
7692
LOG_SECTION="do_extra_configuration" do_with_conditional_logging do_extra_configuration
7793

0 commit comments

Comments
 (0)