Package: dkms
Version: 2.8.7-2
Severity: important
Tags: patch

Hi,

Due to two typos in /etc/kernel/prerm.d/dkms, modules built with DKMS are not deleted anymore when a kernel package is removed.

The script fails to build the two variables "$name" and "$vers" because the final pipe to "cut -d" is put outside the backquotes. The call to "dkms remove" then fails with an error.

Attached is a small patch to fix the problem in the prerm script.

It would also be nice to advise users (with a note on package upgrade for example) to clean up old leftover modules, or even better, run a script to do it automatically (basically the logic would list the installed modules with dkms status, and clear them if that's the only file left in /lib/modules/<kernel_version>/). I can write it for you if you want.

Regards,

--
Raphaël Halimi
--- /etc/kernel/prerm.d/dkms.orig	2021-10-01 11:34:34.000000000 +0200
+++ /etc/kernel/prerm.d/dkms	2022-02-15 15:19:49.616611838 +0100
@@ -13,8 +13,8 @@
 
 if [ -x /usr/sbin/dkms ]; then
 while read line; do
-   name=`echo "$line" | awk '{print $1}' | sed 's/,$//'` | cut -d'/' -f1
-   vers=`echo "$line" | awk '{print $1}' | sed 's/,$//'` | cut -d'/' -f2
+   name=`echo "$line" | awk '{print $1}' | sed 's/,$//' | cut -d'/' -f1`
+   vers=`echo "$line" | awk '{print $1}' | sed 's/,$//' | cut -d'/' -f2`
    arch=`echo "$line" | awk '{print $3}' | sed 's/:$//'`
    echo "dkms: removing: $name $vers ($inst_kern) ($arch)" >&2
    dkms remove -m $name -v $vers -k $inst_kern -a $arch

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to