diff --git a/rhel8/nvidia-driver b/rhel8/nvidia-driver index cda0cb4e..adff7aba 100755 --- a/rhel8/nvidia-driver +++ b/rhel8/nvidia-driver @@ -47,9 +47,9 @@ _cleanup_package_cache() { _get_rhel_version_from_kernel() { local rhel_version_underscore rhel_version_arr - rhel_version_underscore=$(echo "${KERNEL_VERSION}" | sed 's/.*el\([0-9]_[0-9]\).*/\1/g') - # For the Kernel version 4.18.0-513.9.1.el8_9, we expect to extract the string "8_9" - if [[ ${#rhel_version_underscore} -ne 3 ]]; then + rhel_version_underscore=$(echo "${KERNEL_VERSION}" | sed 's/.*el\([0-9]\+_[0-9]\+\).*/\1/g') + # For e.g. :- from the kernel version 4.18.0-513.9.1.el8_9, we expect to extract the string "8_9" + if [[ ! ${rhel_version_underscore} =~ ^[0-9]+_[0-9]+$ ]]; then echo "Unable to resolve RHEL version from kernel version" >&2 return 1 fi @@ -59,6 +59,7 @@ _get_rhel_version_from_kernel() { return 1 fi RHEL_VERSION="${rhel_version_arr[0]}.${rhel_version_arr[1]}" + echo "RHEL VERSION successfully resolved from kernel: ${RHEL_VERSION}" return 0 } diff --git a/rhel8/precompiled/nvidia-driver b/rhel8/precompiled/nvidia-driver index dd7f5324..de85549b 100755 --- a/rhel8/precompiled/nvidia-driver +++ b/rhel8/precompiled/nvidia-driver @@ -44,9 +44,9 @@ _cleanup_package_cache() { _get_rhel_version_from_kernel() { local rhel_version_underscore rhel_version_arr - rhel_version_underscore=$(echo "${KERNEL_VERSION}" | sed 's/.*el\([0-9]_[0-9]\).*/\1/g') + rhel_version_underscore=$(echo "${KERNEL_VERSION}" | sed 's/.*el\([0-9]\+_[0-9]\+\).*/\1/g') # For the Kernel version 4.18.0-513.9.1.el8_9, we expect to extract the string "8_9" - if [[ ${#rhel_version_underscore} -ne 3 ]]; then + if [[ ! ${rhel_version_underscore} =~ ^[0-9]+_[0-9]+$ ]]; then echo "Unable to resolve RHEL version from kernel version" >&2 return 1 fi @@ -56,6 +56,7 @@ _get_rhel_version_from_kernel() { return 1 fi RHEL_VERSION="${rhel_version_arr[0]}.${rhel_version_arr[1]}" + echo "RHEL VERSION successfully resolved from kernel: ${RHEL_VERSION}" return 0 }