From 3123f567653309bedb513b3d6c71b7bbe2287279 Mon Sep 17 00:00:00 2001 From: Nikita Dubrovskii Date: Thu, 5 Feb 2026 13:18:32 +0100 Subject: [PATCH] scripts/cpictl: Detect RHCOS using VARIANT_ID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CoreOS uses VARIANT_ID instead of a unique ID in /etc/os-release. Extend distro detection to identify RHCOS, other CoreOS variants may be added later if needed. RHCOS is showing in HMC as RHEL, because `system_level' is: ``` [core@cosa-devsh ~]$ cat /sys/firmware/cpi/system_level 0x010906023a050e00 ``` But should be: ``` [core@cosa-devsh ~]$ cat /sys/firmware/cpi/system_level 0x070906023a050e00 ``` Issue: https://jsw.ibm.com/browse/OCPVIP-1471 Closes: https://github.com/ibm-s390-linux/s390-tools/pull/199 Signed-off-by: Nikita Dubrovskii Reviewed-by: Marc Hartmayer Reviewed-by: Hendrik Brueckner Signed-off-by: Jan Höppner --- scripts/cpictl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/cpictl b/scripts/cpictl index ab74ce62..d7922d23 100755 --- a/scripts/cpictl +++ b/scripts/cpictl @@ -346,12 +346,17 @@ get_distro() { local line ID="linux" VERSION_ID="0" VERSION="" update + # CoreOS variants don’t have a unique ID in /etc/os-release, so use VARIANT_ID instead. + # https://github.com/coreos/rhel-coreos-config/blob/main/common.yaml#L85 + # https://github.com/coreos/fedora-coreos-config/blob/testing-devel/tests/kola/data/commonlib.sh#L43 + local VARIANT_ID="" + [[ ! -e "$OS_RELEASE" ]] && return # Only import required variables while read -r line ; do if [[ "$line" =~ ^ID= ]] || [[ "$line" =~ ^VERSION_ID= ]] || - [[ "$line" =~ ^VERSION= ]] ; then + [[ "$line" =~ ^VERSION= ]] || [[ "$line" =~ ^VARIANT_ID= ]] ; then eval "$line" fi done <"$OS_RELEASE" @@ -364,6 +369,12 @@ get_distro() VERSION_ID="$VERSION_ID$update" fi + if [[ "$ID" == "rhel" ]] && [[ "$VARIANT_ID" == "coreos" ]] ; then + # CoreOS detection via VARIANT_ID (RHCOS only for now) + # FCOS and SCOS may be added in the future. + ID="rhcos" + fi + echo "$ID:$VERSION_ID" }