Comment 4 for bug 300773

Revision history for this message
Andy Whitcroft (apw) wrote : Re: [Bug 300773] Re: Removal does not clean up after dkms, l-r-m(?)

On Thu, Dec 04, 2008 at 03:01:47PM -0000, Matt Zimmerman wrote:

> The crux of my problem is the "updates" directory, which contains modules
> built by DKMS. Nothing cleans up these files when a kernel is removed, only
> when the entire module package (e.g. nvidia-173-kernel-source) is removed.
>
> I think what's needed is to add a "dkms remove" command to the kernel
> package postrm which removes all modules installed by dkms for the specified
> kernel version.

If I install the nvidia-173-kernel-source module on my system here then
I get a dkms postinstall script for both the headers and the kernel:

    $ ls -l /etc/kernel/*/dkms
    -rwxr-xr-x 1 root root 185 2008-07-08 16:19 /etc/kernel/header_postinst.d/dkms
    -rwxr-xr-x 1 root root 185 2008-07-08 16:19 /etc/kernel/postinst.d/dkms
    -rwxr-xr-x 1 root root 502 2008-07-08 16:19 /etc/kernel/prerm.d/dkms

When both kernel and headers are installed then the driver seems to get
built correctly:

    $ sudo dpkg -i linux-image-2.6.27-7-generic_2.6.27-7.16_amd64.deb
    Selecting previously deselected package linux-image-2.6.27-7-generic.
    (Reading database ... 161177 files and directories currently installed.)
    Unpacking linux-image-2.6.27-7-generic (from
    linux-image-2.6.27-7-generic_2.6.27-7.16_amd64.deb) ...
    Done.
    Setting up linux-image-2.6.27-7-generic (2.6.27-7.16) ...
    Running depmod.
    update-initramfs: Generating /boot/initrd.img-2.6.27-7-generic
    Running postinst hook script /sbin/update-grub.
    Searching for GRUB installation directory ... found: /boot/grub
    Searching for default file ... found: /boot/grub/default
    Testing for an existing GRUB menu.lst file ... found:
    /boot/grub/menu.lst
    Searching for splash image ... none found, skipping ...
    Found kernel: /boot/vmlinuz-TEST
    Found kernel: /boot/vmlinuz-2.6.27-10-generic
    Found kernel: /boot/vmlinuz-2.6.27-9-generic
    Found kernel: /boot/vmlinuz-2.6.27-8-generic
    Found kernel: /boot/vmlinuz-2.6.27-7-generic
    Found kernel: /boot/vmlinuz-2.6.24-21-generic
    Found kernel: /boot/memtest86+.bin
    Replacing config file /var/run/grub/menu.lst with new version
    Updating /boot/grub/menu.lst ... done

    Examining /etc/kernel/postinst.d.
    run-parts: executing /etc/kernel/postinst.d/dkms
     * Running DKMS auto installation service for kernel 2.6.27-7-generic
     * nvidia (173.14.12)...
     * nvidia (173.14.12): Installing module.
      Kernel source for 2.6.27-7-generic not installed. Cannot install this module.
             [fail]
    run-parts: executing /etc/kernel/postinst.d/nvidia-common

    (reverse-i-search)`0': less
    ./ubuntu-intrepid/debian/linux-image-2.6.27-10-generic/DEBIAN/postrm
    (reverse-i-search)`-r': sudo dpkg -r
    linux-restricted-modules-2.6.27-7-generic$ sudo dpkg -i
    linux-headers-2.6.27-7-generic_2.6.27-7.16_amd64.deb Selecting
    previously deselected package linux-headers-2.6.27-7-generic.
    (Reading database ... 163749 files and directories currently installed.)
    Unpacking linux-headers-2.6.27-7-generic (from
    linux-headers-2.6.27-7-generic_2.6.27-7.16_amd64.deb) ...
    Setting up linux-headers-2.6.27-7-generic (2.6.27-7.16) ...
    Examining /etc/kernel/header_postinst.d.
    run-parts: executing /etc/kernel/header_postinst.d/dkms
     * Running DKMS auto installation service for kernel 2.6.27-7-generic
     * nvidia (173.14.12)...
     * nvidia (173.14.12): Installing module.
    ...........
    ......
             [ OK ]
    run-parts: executing /etc/kernel/header_postinst.d/nvidia-common

    $ ls /lib/modules/2.6.27-7-generic/build modules.alias
    modules.ieee1394map modules.ofmap modules.symbols
    initrd modules.ccwmap modules.inputmap modules.pcimap
    modules.usbmap
    kernel modules.dep modules.isapnpmap modules.seriomap updates
    $ ls /lib/modules/2.6.27-7-generic/updates/dkms/
    nvidia.ko

And indeed removed correctly, as in a dkms remove occurs:

    $ sudo dpkg -r linux-image-2.6.27-7-generic
    (Reading database ... 169361 files and directories currently installed.)
    Removing linux-image-2.6.27-7-generic ...
    Examining /etc/kernel/prerm.d.
    run-parts: executing /etc/kernel/prerm.d/dkms
    Uninstalling: nvidia 173.14.12 (2.6.27-7-generic) (x86_64)

    -------- Uninstall Beginning --------
    Module: nvidia
    Version: 173.14.12
    Kernel: 2.6.27-7-generic (x86_64)
    -------------------------------------

    Status: Before uninstall, this module version was ACTIVE on this kernel.

    nvidia.ko:
     - Uninstallation
       - Deleting from: /lib/modules/2.6.27-7-generic/updates/dkms/
     - Original module
       - No original module was found for this module on this kernel.
       - Use the dkms install command to reinstall any previous module
  version.
    depmod....

    DKMS: uninstall Completed.
    run-parts: executing /etc/kernel/prerm.d/last-good-boot
    Running postrm hook script /sbin/update-grub.
    Searching for GRUB installation directory ... found: /boot/grub
    Searching for default file ... found: /boot/grub/default
    Testing for an existing GRUB menu.lst file ... found:
    /boot/grub/menu.lst
    Searching for splash image ... none found, skipping ...
    Found kernel: /boot/vmlinuz-TEST
    Found kernel: /boot/vmlinuz-2.6.27-10-generic
    Found kernel: /boot/vmlinuz-2.6.27-9-generic
    Found kernel: /boot/vmlinuz-2.6.27-8-generic
    Found kernel: /boot/vmlinuz-2.6.24-21-generic
    Found kernel: /boot/memtest86+.bin
    Replacing config file /var/run/grub/menu.lst with new version
    Updating /boot/grub/menu.lst ... done

    The link /vmlinuz is a damaged link
    Removing symbolic link vmlinuz
     you may need to re-run your boot loader[grub]
    The link /initrd.img is a damaged link
    Removing symbolic link initrd.img
     you may need to re-run your boot loader[grub]
    $ sudo dpkg -r linux-headers-2.6.27-7-generic
    linux-headers-2.6.27-7(Reading database ... 166786 files and directories
    currently installed.)
    Removing linux-headers-2.6.27-7-generic ...
    dpkg - warning: while removing linux-headers-2.6.27-7-generic, directory
    `/lib/modules/2.6.27-7-generic' not empty so not removed.
    Removing linux-headers-2.6.27-7 ...

What does go wrong is that dkms is leaving the empty directories behind:

    $ ls /lib/modules/2.6.27-7-generic
    modules.alias modules.inputmap modules.pcimap modules.usbmap
    modules.ccwmap modules.isapnpmap modules.seriomap updates
    modules.ieee1394map modules.ofmap modules.symbols
    $ ls /lib/modules/2.6.27-7-generic/updates/dkms/
    $ ls /lib/modules/2.6.27-7-generic/updates/
    dkms

So it appears that if all the other bugs are fixed then it is DKMS which
is 'wrong' here, it needs to clean out its directory when its done
removing everything. Will look at sorting that out.