[PATCH 1/1] [Maverick] [V2] UBUNTU: debian -- more agressivly clean up after depmod on purge

Andy Whitcroft apw at canonical.com
Mon Aug 16 16:45:43 UTC 2010


BugLink: http://bugs.launchpad.net/bugs/618591

During install we execute depmod to ensure we have the appropriate module
supper indexes for the installed system, we are however required to clean
up after it on uninstall.  As depmod is provided by an external package
changes in that package can lead to the kernel leaking files on uninstall,
preventing a successful purge.

Though we cannot know what files depmod does generate they (so far) all
are prefixed with "modules." in /lib/modules/<version>/.  The kernel
binary packages do intentionally include two files with this prefix
(modules.builtin and modules.order).  As we know exactly which files we
are carrying move to removing all other modules.* files when uninstalling
to ensure we cleanup comprehensivly behind depmod.  Also adds linkage
between the two places where these files are now listed to ensure we keep
them in lock-step.  This should ensure that should new files be added to
depmod's output set we should purge them automatically.

Signed-off-by: Andy Whitcroft <apw at canonical.com>
---
 debian/control-scripts/prerm    |   23 ++++++++++-------------
 debian/rules.d/2-binary-arch.mk |    2 ++
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/debian/control-scripts/prerm b/debian/control-scripts/prerm
index ae248dd..c214842 100644
--- a/debian/control-scripts/prerm
+++ b/debian/control-scripts/prerm
@@ -278,19 +278,16 @@ if (-d "/etc/kernel/prerm.d/$version") {
 }
 
 sub success () {
-  my @files_to_remove = qw{
-    modules.dep modules.isapnpmap modules.pcimap
-    modules.usbmap modules.parportmap
-    modules.generic_string modules.ieee1394map
-    modules.ieee1394map modules.pnpbiosmap
-    modules.alias modules.ccwmap modules.inputmap
-    modules.symbols modules.ofmap modules.seriomap
-    modules.alias.bin modules.builtin.bin modules.dep.bin modules.symbols.bin
-  };
-
-  foreach my $extra_file (@files_to_remove) {
-    if (-f "/lib/modules/$version/$extra_file") {
-      unlink "/lib/modules/$version/$extra_file";
+  # NOTE: need to keep this list in sync with rules.d/2-binary-arch.mk
+  my %files_to_keep = (
+	'modules.builtin'	=> 1,
+	'modules.order'		=> 1,
+  );
+  my $short;
+  for my $file (</lib/modules/$version/modules.*>) {
+    $short = $file; $short =~ s,.*/,,;
+    if (!defined $files_to_keep{$short}) {
+      unlink "$file";
     }
   }
   exit 0;
diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index 6777b5e..16656c0 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -201,6 +201,8 @@ endif
 	#
 	# Remove files which are generated at installation by postinst,
 	# except for modules.order and modules.builtin
+	# 
+	# NOTE: need to keep this list in sync with postrm
 	#
 	mkdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
 	mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.order \
-- 
1.7.0.4





More information about the kernel-team mailing list