From f8c68a38afe75ae8e40194f13fa6b097e0432491 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 29 Jun 2026 18:36:17 +0200 Subject: [PATCH 1/2] version: derive OS version from git describe, not the release label On weekly builds INFIX_RELEASE is "latest", and it fed straight into INFIX_VERSION, so the keyword showed up as VERSION, VERSION_ID and PRETTY_NAME in /etc/os-release, in /etc/version (show version), in the ietf-system os-version operational leaf, and in the mDNS advertisement. None of those pinned down the source revision; only BUILD_ID did. Tie INFIX_VERSION to INFIX_BUILD_ID (git describe). INFIX_RELEASE now only labels the release channel (IMAGE_VERSION) and names the published artifacts. Also exclude the moving 'latest*' tags from git describe, so the build id can never resolve to "latest" should that tag land on, or nearest to, the built commit. Fixes #1524 Signed-off-by: Joachim Wiberg --- Config.in | 7 ++++--- infix.mk | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Config.in b/Config.in index 49f37390..f2875807 100644 --- a/Config.in +++ b/Config.in @@ -110,9 +110,10 @@ config INFIX_OEM_PATH directory (absolute path) and the Infix post-build.sh will call `git describe -C $INFIX_OEM_PATH`. - Note: for release builds the global variable INFIX_RELEASE overrides - the version information derived from `git describe`. However, the - GIT version is always saved as the BUILD_ID in /etc/os-releases. + Note: the OS version (VERSION, VERSION_ID, BUILD_ID in + /etc/os-release) is always derived from `git describe`. The global + variable INFIX_RELEASE does not change it; it only labels the release + channel (IMAGE_VERSION) and names the published artifacts. endmenu diff --git a/infix.mk b/infix.mk index 788134c7..31fc52f1 100644 --- a/infix.mk +++ b/infix.mk @@ -4,10 +4,12 @@ oem-dir := $(call qstrip,$(INFIX_OEM_PATH)) INFIX_TOPDIR = $(if $(oem-dir),$(oem-dir),$(BR2_EXTERNAL_INFIX_PATH)) # Unless the user specifies an explicit build id, source it from git. -# The build id also becomes the image version, unless an official -# release is being built. -export INFIX_BUILD_ID ?= $(shell git -C $(INFIX_TOPDIR) describe --dirty --always --tags) -export INFIX_VERSION = $(if $(INFIX_RELEASE),$(INFIX_RELEASE),$(INFIX_BUILD_ID)) +# Exclude the moving 'latest*' tags so the version always resolves to a +# real release tag, see issue #1524. The build id is also the version +# shown to users; INFIX_RELEASE only labels the release channel and names +# artifacts (see INFIX_ARTIFACT below). +export INFIX_BUILD_ID ?= $(shell git -C $(INFIX_TOPDIR) describe --dirty --always --tags --exclude 'latest*') +export INFIX_VERSION = $(INFIX_BUILD_ID) export INFIX_ARTIFACT = $(call qstrip,$(INFIX_IMAGE_ID)$(if $(INFIX_RELEASE),-$(INFIX_RELEASE))) INFIX_CFLAGS:=-Wall -Werror -Wextra -Wno-unused-parameter -Wformat=2 -Wformat-overflow=2 -Winit-self -Wstrict-overflow=4 -Wno-format-truncation -Wno-format-nonliteral From 208f7c9f083359bce9f5b51fb4a7fd67647997f7 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 29 Jun 2026 19:35:04 +0200 Subject: [PATCH 2/2] confd: simplify gen-hostname, defer MAC expansion to confd gen-hostname baked the last three MAC octets straight into the generated hostname, so the actual MAC ended up stored in the configuration. Copy that config to another device and its hostname no longer matched the hardware. Emit the %h and %m format specifiers and let confd expand them when the config is applied, so the MAC is resolved per device and never written to a saved config. This also drops the /run/system.json lookup. Closes #1554 Signed-off-by: Joachim Wiberg --- src/confd/bin/gen-hostname | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/confd/bin/gen-hostname b/src/confd/bin/gen-hostname index 092ef24a..eb777220 100755 --- a/src/confd/bin/gen-hostname +++ b/src/confd/bin/gen-hostname @@ -2,26 +2,20 @@ # Generate ietf-system.yang hostname based on: # 1. Command line argument + MAC suffix # 2. Specific hostname from qemu_fw_cfg, from Qeneth -# 3. /etc/hostname from squashfs + MAC suffix +# 3. Default hostname + MAC suffix +# +# The MAC suffix is emitted as the %m format specifier, expanded by confd +# at apply time, so the actual MAC never ends up baked into a saved +# configuration (issue #1554). # set -e -gen() -{ - base_mac=$(jq -r '.["mac-address"]' /run/system.json) - if [ -z "$base_mac" ] || [ "$base_mac" = "null" ]; then - base_mac=00:00:00:00:00:00 - fi - - echo "$1-$(echo $base_mac | tail -c 9 | tr ':' '-')" -} - if [ "$1" ]; then - sysname=$(gen "$1") + sysname="$1-%m" elif [ -f "/sys/firmware/qemu_fw_cfg/by_name/opt/hostname/raw" ]; then sysname="$(cat /sys/firmware/qemu_fw_cfg/by_name/opt/hostname/raw)" else - sysname=$(gen "$(cat /etc/hostname)") + sysname="%h-%m" fi cat <