summaryrefslogtreecommitdiffstats
path: root/debian/patches/rebuild-modules-on-header-upgrade.patch
blob: 437bd23fc2be1e87a2d8198d41b48f87c4d98af1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--- a/kernel_postinst.d_dkms.in
+++ b/kernel_postinst.d_dkms.in
@@ -34,6 +34,19 @@ case "${uname_s}" in
     ;;
 esac
 
+case $0 in *header_postinst.d*)
+    # unbuild all autoinstalled modules for this kernel to ensure they get
+    # rebuilt against the updated headers by the next autoinstall below
+    for mod_ver in $(dkms status -k "$inst_kern" 2>/dev/null | grep ': installed' | cut -d, -f1 | sort -u)
+    do
+        dkms_conf="/var/lib/dkms/$mod_ver/source/dkms.conf"
+        autoinstall=$(bash -c 'AUTOINSTALL=; . "'"$dkms_conf"'" >/dev/null 2>&1; echo $AUTOINSTALL')
+        test -n "$autoinstall" || continue
+        dkms unbuild -k "$inst_kern" "$mod_ver"
+    done
+    ;;
+esac
+
 if [ -x @LIBDIR@/dkms_autoinstaller ]; then
     exec @LIBDIR@/dkms_autoinstaller start "$inst_kern"
 fi