From f420775701f97a369784f42c0fdc78ad9ec06ba3 Mon Sep 17 00:00:00 2001 From: Pratham Patel Date: Sat, 10 Feb 2024 09:23:25 +0530 Subject: [PATCH] read version from /etc/os-release --- create-image.sh | 2 +- includes/post/rpm-repos-enable.ksi | 12 ++++++------ scripts/validate-kickstart.sh | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/create-image.sh b/create-image.sh index f4d5a48..6b7a9e8 100755 --- a/create-image.sh +++ b/create-image.sh @@ -10,7 +10,7 @@ fi KICKSTART_BASE="Rocky" TODAY="$(TZ='UTC' date +%Y.%m.%d)" KICKSTART_FILE="${KICKSTART_BASE}.ks" -APPLIANCE_NAME="${KICKSTART_BASE}-$(dnf config-manager --dump-variables | grep releasever | awk '{print $3}')-$(uname -m)-minimal-${TODAY}" +APPLIANCE_NAME="${KICKSTART_BASE}-$(source <(grep VERSION_ID /etc/os-release) && awk -F '.' '{print $1}' <<< $VERSION_ID)-$(uname -m)-minimal-${TODAY}" IMAGE_NAME="${APPLIANCE_NAME}.raw" COMMANDS_TO_CHECK=('appliance-creator' 'hdparm' 'shasum' 'zstd') diff --git a/includes/post/rpm-repos-enable.ksi b/includes/post/rpm-repos-enable.ksi index a1b0829..0866cdb 100644 --- a/includes/post/rpm-repos-enable.ksi +++ b/includes/post/rpm-repos-enable.ksi @@ -2,17 +2,17 @@ set -x MACHINE_ARCH="$(uname -m)" -DNF_RELEASEVER="$(dnf config-manager --dump-variables | grep 'releasever' | awk '{print $3}')" +VERSION_ID="$(source <(grep VERSION_ID /etc/os-release) && awk -F '.' '{print $1}' <<< $VERSION_ID)" # This repository is a given since it provides 'uboot-images-armv8' and # 'uboot-tools', which are **required**. -dnf config-manager --assumeyes --add-repo "https://download.rockylinux.org/pub/sig/${DNF_RELEASEVER}/altarch/${MACHINE_ARCH}/altarch-common" -if ! dnf repolist --enabled | grep "download.rockylinux.org_pub_sig_${DNF_RELEASEVER}_altarch_${MACHINE_ARCH}_altarch-common" > /dev/null; then - dnf config-manager --set-enabled "download.rockylinux.org_pub_sig_${DNF_RELEASEVER}_altarch_${MACHINE_ARCH}_altarch-common" || exit 1 +dnf config-manager --assumeyes --add-repo "https://download.rockylinux.org/pub/sig/${VERSION_ID}/altarch/${MACHINE_ARCH}/altarch-common" +if ! dnf repolist --enabled | grep "download.rockylinux.org_pub_sig_${VERSION_ID}_altarch_${MACHINE_ARCH}_altarch-common" > /dev/null; then + dnf config-manager --set-enabled "download.rockylinux.org_pub_sig_${VERSION_ID}_altarch_${MACHINE_ARCH}_altarch-common" || exit 1 fi # import the SIG/AltArch key manually, since it does not get automatically get imported... -wget "https://download.rockylinux.org/pub/sig/${DNF_RELEASEVER}/altarch/${MACHINE_ARCH}/altarch-common/RPM-GPG-KEY-Rocky-SIG-AltArch" +wget "https://download.rockylinux.org/pub/sig/${VERSION_ID}/altarch/${MACHINE_ARCH}/altarch-common/RPM-GPG-KEY-Rocky-SIG-AltArch" rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9 rpm --import RPM-GPG-KEY-Rocky-SIG-AltArch rm RPM-GPG-KEY-Rocky-SIG-AltArch @@ -31,7 +31,7 @@ if dnf list installed | grep '@epel' > /dev/null || dnf list installed | grep 'e fi # SIG/kernel's kernel-mainline-sbc -dnf copr enable --assumeyes prathampatel/kernel-rocky "rhel-${DNF_RELEASEVER}-${MACHINE_ARCH}" +dnf copr enable --assumeyes prathampatel/kernel-rocky "rhel-${VERSION_ID}-${MACHINE_ARCH}" if ! dnf repolist --enabled | grep 'copr:copr.fedorainfracloud.org:prathampatel:kernel-rocky' > /dev/null; then dnf config-manager --set-enabled 'copr:copr.fedorainfracloud.org:prathampatel:kernel-rocky' || exit 1 fi diff --git a/scripts/validate-kickstart.sh b/scripts/validate-kickstart.sh index 8c27161..1d18554 100755 --- a/scripts/validate-kickstart.sh +++ b/scripts/validate-kickstart.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash KICKSTART_FILE='../Rocky.ks' -KICKSTART_VERSION="RHEL$(dnf config-manager --dump-variables | grep releasever | awk '{print $3}')" +KICKSTART_VERSION="RHEL$(source <(grep VERSION_ID /etc/os-release) && awk -F '.' '{print $1}' <<< $VERSION_ID)" if ! command -v ksvalidator > /dev/null; then >&2 echo "$0: error: unable to find command 'ksvalidator'"