diff --git a/ubuntu16.04/nvidia-driver b/ubuntu16.04/nvidia-driver index 7786b22df..22dbc2f53 100755 --- a/ubuntu16.04/nvidia-driver +++ b/ubuntu16.04/nvidia-driver @@ -26,12 +26,21 @@ _cleanup_package_cache() { # Resolve the kernel version to the form major.minor.patch-revision-flavor where flavor defaults to generic. _resolve_kernel_version() { + echo "Resolving Linux kernel version..." + + # If headers for the exact running kernel exist, use KERNEL_VERSION as-is. + # This supports non-standard kernel naming (e.g. custom/distro kernels) + # where the upstream version regex would fail. + if apt-cache show "linux-headers-${KERNEL_VERSION}" > /dev/null 2>&1; then + echo "Proceeding with Linux kernel version ${KERNEL_VERSION}" + return 0 + fi + local version=$(apt-cache show "linux-headers-${KERNEL_VERSION}" 2> /dev/null | \ sed -nE 's/^Version:\s+(([0-9]+\.){2}[0-9]+)[-.]([0-9]+).*/\1-\3/p' | head -1) local kernel_flavor=$(echo ${KERNEL_VERSION} | sed 's/[^a-z]*//') kernel_flavor="${kernel_flavor//virtual/generic}" - echo "Resolving Linux kernel version..." if [ -z "${version}" ]; then echo "Could not resolve Linux kernel version" >&2 return 1 diff --git a/ubuntu18.04/nvidia-driver b/ubuntu18.04/nvidia-driver index c61c8454c..a78caa37f 100755 --- a/ubuntu18.04/nvidia-driver +++ b/ubuntu18.04/nvidia-driver @@ -29,12 +29,21 @@ _cleanup_package_cache() { # Resolve the kernel version to the form major.minor.patch-revision-flavor where flavor defaults to generic. _resolve_kernel_version() { + echo "Resolving Linux kernel version..." + + # If headers for the exact running kernel exist, use KERNEL_VERSION as-is. + # This supports non-standard kernel naming (e.g. custom/distro kernels) + # where the upstream version regex would fail. + if apt-cache show "linux-headers-${KERNEL_VERSION}" > /dev/null 2>&1; then + echo "Proceeding with Linux kernel version ${KERNEL_VERSION}" + return 0 + fi + local version=$(apt-cache show "linux-headers-${KERNEL_VERSION}" 2> /dev/null | \ sed -nE 's/^Version:\s+(([0-9]+\.){2}[0-9]+)[-.]([0-9]+).*/\1-\3/p' | head -1) local kernel_flavor=$(echo ${KERNEL_VERSION} | sed 's/[^a-z]*//') kernel_flavor="${kernel_flavor//virtual/generic}" - echo "Resolving Linux kernel version..." if [ -z "${version}" ]; then echo "Could not resolve Linux kernel version" >&2 return 1 diff --git a/ubuntu20.04/nvidia-driver b/ubuntu20.04/nvidia-driver index 6222e3506..0574db8bc 100755 --- a/ubuntu20.04/nvidia-driver +++ b/ubuntu20.04/nvidia-driver @@ -46,12 +46,21 @@ _update_ca_certificates() { # Resolve the kernel version to the form major.minor.patch-revision-flavor where flavor defaults to generic. _resolve_kernel_version() { + echo "Resolving Linux kernel version..." + + # If headers for the exact running kernel exist, use KERNEL_VERSION as-is. + # This supports non-standard kernel naming (e.g. custom/distro kernels) + # where the upstream version regex would fail. + if apt-cache show "linux-headers-${KERNEL_VERSION}" > /dev/null 2>&1; then + echo "Proceeding with Linux kernel version ${KERNEL_VERSION}" + return 0 + fi + local version=$(apt-cache show "linux-headers-${KERNEL_VERSION}" 2> /dev/null | \ sed -nE 's/^Version:\s+(([0-9]+\.){2}[0-9]+)[-.]([0-9]+).*/\1-\3/p' | head -1) local kernel_flavor=$(echo ${KERNEL_VERSION} | sed 's/[^a-z]*//') kernel_flavor="${kernel_flavor//virtual/generic}" - echo "Resolving Linux kernel version..." if [ -z "${version}" ]; then echo "Could not resolve Linux kernel version" >&2 return 1 diff --git a/ubuntu22.04/nvidia-driver b/ubuntu22.04/nvidia-driver index 0039a674d..48f81f848 100755 --- a/ubuntu22.04/nvidia-driver +++ b/ubuntu22.04/nvidia-driver @@ -62,12 +62,21 @@ _update_ca_certificates() { # Resolve the kernel version to the form major.minor.patch-revision-flavor where flavor defaults to generic. _resolve_kernel_version() { + echo "Resolving Linux kernel version..." + + # If headers for the exact running kernel exist, use KERNEL_VERSION as-is. + # This supports non-standard kernel naming (e.g. custom/distro kernels) + # where the upstream version regex would fail. + if apt-cache show "linux-headers-${KERNEL_VERSION}" > /dev/null 2>&1; then + echo "Proceeding with Linux kernel version ${KERNEL_VERSION}" + return 0 + fi + local version=$(apt-cache show "linux-headers-${KERNEL_VERSION}" 2> /dev/null | \ sed -nE 's/^Version:\s+(([0-9]+\.){2}[0-9]+)[-.]([0-9]+).*/\1-\3/p' | head -1) local kernel_flavor=$(echo ${KERNEL_VERSION} | sed 's/[^a-z]*//') kernel_flavor="${kernel_flavor//virtual/generic}" - echo "Resolving Linux kernel version..." if [ -z "${version}" ]; then echo "Could not resolve Linux kernel version" >&2 return 1 diff --git a/ubuntu24.04/nvidia-driver b/ubuntu24.04/nvidia-driver index b272fcd86..29852b5a9 100755 --- a/ubuntu24.04/nvidia-driver +++ b/ubuntu24.04/nvidia-driver @@ -72,12 +72,21 @@ _update_ca_certificates() { # Resolve the kernel version to the form major.minor.patch-revision-flavor where flavor defaults to generic. _resolve_kernel_version() { + echo "Resolving Linux kernel version..." + + # If headers for the exact running kernel exist, use KERNEL_VERSION as-is. + # This supports non-standard kernel naming (e.g. custom/distro kernels) + # where the upstream version regex would fail. + if apt-cache show "linux-headers-${KERNEL_VERSION}" > /dev/null 2>&1; then + echo "Proceeding with Linux kernel version ${KERNEL_VERSION}" + return 0 + fi + local version=$(apt-cache show "linux-headers-${KERNEL_VERSION}" 2> /dev/null | \ sed -nE 's/^Version:\s+(([0-9]+\.){2}[0-9]+)[-.]([0-9]+).*/\1-\3/p' | head -1) local kernel_flavor=$(echo ${KERNEL_VERSION} | sed 's/[^a-z]*//') kernel_flavor="${kernel_flavor//virtual/generic}" - echo "Resolving Linux kernel version..." if [ -z "${version}" ]; then echo "Could not resolve Linux kernel version" >&2 return 1 diff --git a/vgpu-manager/ubuntu20.04/nvidia-driver b/vgpu-manager/ubuntu20.04/nvidia-driver index bce3d1caa..088f71e29 100755 --- a/vgpu-manager/ubuntu20.04/nvidia-driver +++ b/vgpu-manager/ubuntu20.04/nvidia-driver @@ -27,12 +27,21 @@ _cleanup_package_cache() { # Resolve the kernel version to the form major.minor.patch-revision-flavor where flavor defaults to generic. _resolve_kernel_version() { + echo "Resolving Linux kernel version..." + + # If headers for the exact running kernel exist, use KERNEL_VERSION as-is. + # This supports non-standard kernel naming (e.g. custom/distro kernels) + # where the upstream version regex would fail. + if apt-cache show "linux-headers-${KERNEL_VERSION}" > /dev/null 2>&1; then + echo "Proceeding with Linux kernel version ${KERNEL_VERSION}" + return 0 + fi + local version=$(apt-cache show "linux-headers-${KERNEL_VERSION}" 2> /dev/null | \ sed -nE 's/^Version:\s+(([0-9]+\.){2}[0-9]+)[-.]([0-9]+).*/\1-\3/p' | head -1) local kernel_flavor=$(echo ${KERNEL_VERSION} | sed 's/[^a-z]*//') kernel_flavor="${kernel_flavor//virtual/generic}" - echo "Resolving Linux kernel version..." if [ -z "${version}" ]; then echo "Could not resolve Linux kernel version" >&2 return 1 diff --git a/vgpu-manager/ubuntu22.04/nvidia-driver b/vgpu-manager/ubuntu22.04/nvidia-driver index 5a12f0a6f..1ce4dd1de 100755 --- a/vgpu-manager/ubuntu22.04/nvidia-driver +++ b/vgpu-manager/ubuntu22.04/nvidia-driver @@ -29,12 +29,21 @@ _cleanup_package_cache() { # Resolve the kernel version to the form major.minor.patch-revision-flavor where flavor defaults to generic. _resolve_kernel_version() { + echo "Resolving Linux kernel version..." + + # If headers for the exact running kernel exist, use KERNEL_VERSION as-is. + # This supports non-standard kernel naming (e.g. custom/distro kernels) + # where the upstream version regex would fail. + if apt-cache show "linux-headers-${KERNEL_VERSION}" > /dev/null 2>&1; then + echo "Proceeding with Linux kernel version ${KERNEL_VERSION}" + return 0 + fi + local version=$(apt-cache show "linux-headers-${KERNEL_VERSION}" 2> /dev/null | \ sed -nE 's/^Version:\s+(([0-9]+\.){2}[0-9]+)[-.]([0-9]+).*/\1-\3/p' | head -1) local kernel_flavor=$(echo ${KERNEL_VERSION} | sed 's/[^a-z]*//') kernel_flavor="${kernel_flavor//virtual/generic}" - echo "Resolving Linux kernel version..." if [ -z "${version}" ]; then echo "Could not resolve Linux kernel version" >&2 return 1 diff --git a/vgpu-manager/ubuntu24.04/nvidia-driver b/vgpu-manager/ubuntu24.04/nvidia-driver index b16bc2ef2..5d5288f12 100644 --- a/vgpu-manager/ubuntu24.04/nvidia-driver +++ b/vgpu-manager/ubuntu24.04/nvidia-driver @@ -29,12 +29,21 @@ _cleanup_package_cache() { # Resolve the kernel version to the form major.minor.patch-revision-flavor where flavor defaults to generic. _resolve_kernel_version() { + echo "Resolving Linux kernel version..." + + # If headers for the exact running kernel exist, use KERNEL_VERSION as-is. + # This supports non-standard kernel naming (e.g. custom/distro kernels) + # where the upstream version regex would fail. + if apt-cache show "linux-headers-${KERNEL_VERSION}" > /dev/null 2>&1; then + echo "Proceeding with Linux kernel version ${KERNEL_VERSION}" + return 0 + fi + local version=$(apt-cache show "linux-headers-${KERNEL_VERSION}" 2> /dev/null | \ sed -nE 's/^Version:\s+(([0-9]+\.){2}[0-9]+)[-.]([0-9]+).*/\1-\3/p' | head -1) local kernel_flavor=$(echo ${KERNEL_VERSION} | sed 's/[^a-z]*//') kernel_flavor="${kernel_flavor//virtual/generic}" - echo "Resolving Linux kernel version..." if [ -z "${version}" ]; then echo "Could not resolve Linux kernel version" >&2 return 1