From e7bd5e3c621fd64a7cf682967ce4c9a77c4eb7bc Mon Sep 17 00:00:00 2001 From: Igal Tsoiref Date: Wed, 10 Jul 2024 19:20:37 +0300 Subject: [PATCH] Adding rhel ai version Set github hash by defautl as image version. Add RHEL_AI_VERSION into /etc/os-release in order to use it in insights Signed-off-by: Igal Tsoiref --- training/common/Makefile.common | 1 + training/nvidia-bootc/Containerfile | 5 +++++ training/nvidia-bootc/Makefile | 2 ++ 3 files changed, 8 insertions(+) diff --git a/training/common/Makefile.common b/training/common/Makefile.common index 9234278a..fb76514a 100644 --- a/training/common/Makefile.common +++ b/training/common/Makefile.common @@ -16,6 +16,7 @@ CONTAINER_TOOL_EXTRA_ARGS ?= EXTRA_RPM_PACKAGES ?= GRAPH_ROOT=$(shell podman info --format '{{ .Store.GraphRoot }}') UMASK=$(shell umask) +IMAGE_VERSION := $(or ${IMAGE_VERSION},$(shell git rev-parse --short HEAD)) AUTH_JSON ?= diff --git a/training/nvidia-bootc/Containerfile b/training/nvidia-bootc/Containerfile index e60a6d59..96ff966f 100644 --- a/training/nvidia-bootc/Containerfile +++ b/training/nvidia-bootc/Containerfile @@ -99,6 +99,8 @@ COPY --from=builder --chmod=444 /home/builder/yum-packaging-precompiled-kmod/tmp # Temporary workaround until the permanent fix for libdnf is merged COPY nvidia-toolkit-firstboot.service /usr/lib/systemd/system/nvidia-toolkit-firstboot.service +ARG IMAGE_VERSION + # TODO: rework this monstrosity into a build.sh (or even not shell script) # The need for the `cp /etc/dnf/dnf.conf` is a workaround for https://github.com/containers/bootc/issues/637 RUN mv /etc/selinux /etc/selinux.tmp \ @@ -146,6 +148,9 @@ RUN mv /etc/selinux /etc/selinux.tmp \ # Install rhc connect for insights telemetry gathering && . /etc/os-release && if [ "${ID}" == "rhel" ]; then \ dnf install -y rhc rhc-worker-playbook; \ + sed -i -e "/^VARIANT=/ {s/^VARIANT=.*/VARIANT=\"RHEL AI\"/; t}" -e "\$aVARIANT=\"RHEL AI\"\"" /etc/os-release; + sed -i -e "/^VARIANT_ID=/ {s/^VARIANT_ID=.*/VARIANT_ID=rhel_ai/; t}" -e "\$aVARIANT_ID=rhel_ai" /etc/os-release; + sed -i -e "/^BUILD_ID=/ {s/^BUILD_ID=.*/BUILD_ID='${IMAGE_VERSION}'/; t}" -e "\$aBUILD_ID='${IMAGE_VERSION}'" /etc/os-release; fi \ && dnf clean all \ && ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants \ diff --git a/training/nvidia-bootc/Makefile b/training/nvidia-bootc/Makefile index 24a1cc8e..2a7d99ee 100644 --- a/training/nvidia-bootc/Makefile +++ b/training/nvidia-bootc/Makefile @@ -16,6 +16,8 @@ bootc: driver-toolkit check-sshkey prepare-files $(DRIVER_TOOLKIT_IMAGE:%=--build-arg DRIVER_TOOLKIT_IMAGE=%) \ $(DRIVER_VERSION:%=--build-arg DRIVER_VERSION=%) \ $(DRIVER_VERSION:%=--label driver-version=%) \ + $(IMAGE_VERSION:%=--label image_version=%) \ + $(IMAGE_VERSION:%=--build-arg IMAGE_VERSION=%) \ $(EXTRA_RPM_PACKAGES:%=--build-arg EXTRA_RPM_PACKAGES=%) \ $(FROM:%=--build-arg BASEIMAGE=%) \ $(INSTRUCTLAB_IMAGE:%=--build-arg INSTRUCTLAB_IMAGE=%) \