summaryrefslogtreecommitdiffstats
path: root/debian/patches/0006-dkms_autoinstaller-skip-autoinstall-if-headers-are-m.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/0006-dkms_autoinstaller-skip-autoinstall-if-headers-are-m.patch')
-rw-r--r--debian/patches/0006-dkms_autoinstaller-skip-autoinstall-if-headers-are-m.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/debian/patches/0006-dkms_autoinstaller-skip-autoinstall-if-headers-are-m.patch b/debian/patches/0006-dkms_autoinstaller-skip-autoinstall-if-headers-are-m.patch
new file mode 100644
index 0000000..4a403f2
--- /dev/null
+++ b/debian/patches/0006-dkms_autoinstaller-skip-autoinstall-if-headers-are-m.patch
@@ -0,0 +1,62 @@
+From 2e65ddb5449a18602eb81776e87e048adfb5f114 Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe@debian.org>
+Date: Wed, 22 Mar 2023 18:16:03 +0100
+Subject: [PATCH] dkms_autoinstaller: skip autoinstall if headers are missing
+
+align the behavior with dkms_common.postinst which also skips the build
+step if headers are not available
+
+Before this change the following installation order succeeds (while
+linux-headers-... is *not* installed) (Debian syntax):
+ apt install linux-image-... && apt install ...-dkms
+while the opposite order causes a failure:
+ apt install ...-dkms && apt install linux-image-...
+After this change both ways succeed.
+---
+ dkms_autoinstaller | 23 +++++++++++++++++++++++
+ 1 file changed, 23 insertions(+)
+
+diff --git a/dkms_autoinstaller b/dkms_autoinstaller
+index 8c9450c..1b54c51 100755
+--- a/dkms_autoinstaller
++++ b/dkms_autoinstaller
+@@ -38,6 +38,27 @@ test -f $exec || exit 0
+
+ [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
++uname_s=$(uname -s)
++
++_get_kernel_dir() {
++ KVER=$1
++ case ${uname_s} in
++ Linux) DIR="/lib/modules/$KVER/build" ;;
++ GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
++ esac
++ echo $DIR
++}
++
++_check_kernel_dir() {
++ DIR=$(_get_kernel_dir $1)
++ case ${uname_s} in
++ Linux) test -e $DIR/include ;;
++ GNU/kFreeBSD) test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;;
++ *) return 1 ;;
++ esac
++ return $?
++}
++
+ case "$1" in
+ start)
+ if [ -n "$2" ]; then
+@@ -47,6 +68,8 @@ case "$1" in
+ fi
+ if [ -f /etc/dkms/no-autoinstall ]; then
+ log_action_msg "$prog: autoinstall for dkms modules has been disabled"
++ elif ! _check_kernel_dir $kernel; then
++ log_action_msg "$prog: autoinstall for kernel $kernel was skipped since the kernel headers for this kernel do not seem to be installed"
+ else
+ log_daemon_msg "$prog: running auto installation service for kernel $kernel"
+ dkms autoinstall --kernelver $kernel
+--
+2.20.1
+