diskimage-builder/diskimage_builder/elements/dkms/post-install.d/97-dkms
Denys Mischenko abc2524a5c Adopted dkms element to work on Ubuntu Jammy and nvidia drivers
Previously a module version was splitted from the module name:

  nvidia, 510.47.03, 5.4.0-109-generic, x86_64: installed

In Jammy it is now a part of the name:

  nvidia/510.47.03, 5.15.0-27-generic, x86_64: installed

Assuming the fact that it would be threatted as a path this change
doesn't brake anything which was working before. But at the same
time it allows to pass last step where dkms is requested to build all
modules.

Change-Id: Ic1bb2b45f9db906b64ca03ae5c4e05b2114f2a74
2022-05-12 10:20:25 +00:00

32 lines
833 B
Bash
Executable file

#!/bin/bash
# Trigger a run of dkms for all the modules installed
# to ensure we have valid modules build for all.
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
modules=$(dkms status | tr ',:/' ' ' | awk '{ print $1 "/" $2 }')
kernels=$(ls /usr/src/linux-headers-*-*-* -d | sed -e 's|/usr/src/linux-headers-||' || echo "")
# NOTE(bnemec): On Fedora, the versions can be found in /usr/src/kernels
if [ -z "$kernels" ]; then
kernels=$(ls /usr/src/kernels/* -d | sed -e 's|/usr/src/kernels/||' || echo "")
fi
if [ -z "$kernels" ]; then
echo "Warning: No kernel versions found for DKMS"
fi
__ARCH=$ARCH
unset ARCH
for module in $modules ; do
for kernel in $kernels ; do
dkms build $module -k $kernel
dkms install $module -k $kernel
done
done
ARCH=$__ARCH
dkms status