RedHatOfficial / rhelai-dev-preview

Red Hat Enterprise Linux AI -- Developer Preview
Apache License 2.0
135 stars 47 forks source link

Use newer kernel version when there are multiple available #17

Closed markmc closed 3 months ago

markmc commented 3 months ago

Cherry-picks containers/ai-lab-recipes#488

Without this, make nvidia was failing for me because the kernel version detection code assumes dnf info will only return details of one kernel package, but currently it shows two - the one installed (5.14.0-427.16.1.el9_4), and a newer one available (5.14.0-427.18.1.el9_4)

$ make nvidia FROM=registry.redhat.io/rhel9/rhel-bootc:9.4 REGISTRY=quay.io REGISTRY_ORG=markmc
...
STEP 5/7: RUN if [ "${KERNEL_VERSION}" == "" ]; then         RELEASE=$(dnf info kernel-core | grep Release | awk -F: '{print $2}' | tr -d '[:blank:]')         && VERSION=$(dnf info kernel-core | grep Version 
| awk -F: '{print $2}' | tr -d '[:blank:]')         && export KERNEL_VERSION="${VERSION}-${RELEASE}" ;        fi     && echo "${KERNEL_VERSION}"     && dnf -y install dnf-plugin-config-manager     && dnf conf
ig-manager --best --nodocs --setopt=install_weak_deps=False --save     && dnf -y install         kernel-devel-${KERNEL_VERSION}         kernel-modules-${KERNEL_VERSION}         kernel-modules-extra-${KERNEL_V
ERSION}     && if [ "${ENABLE_RT}" ] && [ $(arch) == "x86_64" ]; then         dnf -y --enablerepo=rt install             kernel-rt-devel-${KERNEL_VERSION}             kernel-rt-modules-${KERNEL_VERSION}      
       kernel-rt-modules-extra-${KERNEL_VERSION};     fi     && export INSTALLED_KERNEL=$(rpm -q --qf "%{VERSION}-%{RELEASE}.%{ARCH}" kernel-core-${KERNEL_VERSION})     && export GCC_VERSION=$(cat /lib/module
s/${INSTALLED_KERNEL}/config | grep -Eo "gcc \(GCC\) ([0-9\.]+)" | grep -Eo "([0-9\.]+)")     && dnf -y install         binutils         diffutils         elfutils-libelf-devel         jq         kabi-dw kern
el-abi-stablelists         keyutils         kmod         gcc-${GCC_VERSION}         git         make         mokutil         openssl         pinentry         rpm-build         xz     && dnf clean all     && u
seradd -u 1001 -m -s /bin/bash builder
5.14.0
5.14.0-427.16.1.el9_4
427.18.1.el9_4
...
No match for argument: 5.14.0-427.16.1.el9_4
No match for argument: 427.18.1.el9_4
Package kernel-modules-5.14.0-427.16.1.el9_4.x86_64 is already installed.
Error: Unable to find a match: 5.14.0-427.16.1.el9_4 427.18.1.el9_4