Package: module-assistant
Version: 0.11.8
Severity: wishlist
Tags: patch

Hi,

if m-a is ordered to (auto-)install a package it will do so via "dpkg -i
module.deb"[0]. This causes apt and friends to believe that this package
was manually installed and hence never considers it for autoremoval.

apt (and hence his libapt based friends) have for a while now special
support for kernels allowing old kernels to be autoremoved after they
aren't used anymore. That works good, but m-a is raining on this parade:
Module packages tend to depend on the kernel images they were built for
(as they become quite useless without them) hence breaking autoremoval.

apt actually not only prevents the kernel itself, but also out-of-tree
modules (as long as their name matches '^.*-modules-KERNELVERSION$' or
'^.*-kernel-KERNELVERSION$') belonging to those kernels from being
autoremoved, so it would be great if m-a would declare these module
packages as auto-installed to let autoremoval kick in as intended for
kernel images, headers and modules alike.

The attached simple patch implements this auto marking (but probably not
in the greatest of perl as my knowledge in it is very limited).


Best regards

David Kalnischkies


[0] That could be improved upon by now, but that requires a recent apt,
so in the interest of backports I will leave that slide for the moment
– and it doesn't change the manual vs auto part discussed here anyhow.
From fbb1d6e1d19496c52b208fe155fa6eb3bebbaab5 Mon Sep 17 00:00:00 2001
From: David Kalnischkies <da...@kalnischkies.de>
Date: Fri, 1 Jul 2016 12:02:08 +0200
Subject: [PATCH] mark build packages as auto-installed in apt

In the way kernel packages are shipped they are always auto-installed,
but apt protects a reasonable set of them from being autoremoved and it
also protects the modules built for these kernels from being autoremoved.
In this way old kernels can leave the system without requiring users to
manually remove them (before they fill up their disks).

So by marking all modules installed by m-a we can let apt do its kernel
magic as otherwise apt believes these modules were manually installed
and hence never considered for autoremoval (along with the kernel they
are built for as the modules depend on the kernel image).
---
 module-assistant | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/module-assistant b/module-assistant
index 5d36f0e..c83c0c9 100755
--- a/module-assistant
+++ b/module-assistant
@@ -1023,6 +1023,11 @@ sub install {
       print STDERR "\nI: " . gettext("Direct installation failed, trying to post-install the dependencies") . "\n\n";
       $ret += withecho($sudo, $aptcmd, $opt_noninter?"-fy":"-f","install");
    }
+   foreach $deb (@debs) {
+      my @scores = split "_", File::Basename::fileparse($deb);
+      push(@buildpkgs, $scores[0]);
+   }
+   withecho ($sudo, "apt-mark", "auto", @buildpkgs) if($#buildpkgs >= 0);
 }
 
 sub clean {
-- 
2.8.1

Attachment: signature.asc
Description: PGP signature

Reply via email to