From f5c74a6d7762bbf41b9b79c2d1c6784826b225a4 Mon Sep 17 00:00:00 2001 From: Harry Vine Date: Mon, 21 Sep 2026 08:50:52 +0100 Subject: [PATCH] Version output for 6.1 & 6.2 fix --- docs/building-images.md | 4 +- .../resolver/templates/rpm-resolution.sh.tpl | 38 ++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/docs/building-images.md b/docs/building-images.md index eb54f838..f612660f 100644 --- a/docs/building-images.md +++ b/docs/building-images.md @@ -111,7 +111,7 @@ operatingSystem: keymap: us packages: noGPGCheck: false - enableExtras: false + enableExtras: true packageList: - pkg1 - pkg2 @@ -617,4 +617,4 @@ podman run --rm -it -v $IMAGE_DIR:/eib \ $EIB_IMAGE \ build --definition-file $DEFINITION_FILE \ --cache=false -``` \ No newline at end of file +``` diff --git a/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl b/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl index c83807d6..612f111d 100644 --- a/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl +++ b/pkg/rpm/resolver/templates/rpm-resolution.sh.tpl @@ -15,7 +15,43 @@ set -euo pipefail {{ if ne .RegCode "" }} suseconnect -r {{ .RegCode }} {{ if $.EnableExtras -}} -VERSION=$(awk '/VERSION=/' /etc/os-release | cut -d'"' -f2) +VERSION=$( + + OS_RELEASE_FILE="${1:-/etc/os-release}" + +# Make sure the file actually exists before we try to read it. +if [[ ! -f "$OS_RELEASE_FILE" ]]; then + echo "Error: file not found: $OS_RELEASE_FILE" + exit 1 +fi + +# Step 1: try to read the new field first (SL Micro 6.2+). +new_version=$(grep '^SUSE_SUPPORT_PRODUCT_VERSION=' "$OS_RELEASE_FILE" | cut -d '=' -f2 | tr -d '"') + +# Step 2: if that field wasn't found, fall back to the old field. +old_version=$(grep '^VERSION_ID=' "$OS_RELEASE_FILE" | cut -d '=' -f2 | tr -d '"') + +if [[ -n "$new_version" ]]; then + version="$new_version" +else + version="$old_version" +fi + +# Step 3: make sure we actually got something. +if [[ -z "$version" ]]; then + echo "Error: could not find a version in $OS_RELEASE_FILE" + exit 1 +fi + +# Step 4: check that it looks like a real version number, e.g. "6.2". +if [[ ! "$version" =~ ^[0-9]+(\.[0-9]+)*$ ]]; then + echo "Error: found version '$version' but it doesn't look valid" + exit 1 +fi + +echo "Version is: $version" +) + suseconnect -p SL-Micro-Extras/$VERSION/{{ .Arch }} {{ end -}} zypper ref