diff mbox

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

Message ID 1281963000-24423-1-git-send-email-apw@canonical.com
State Rejected
Delegated to: Leann Ogasawara
Headers show

Commit Message

Andy Whitcroft Aug. 16, 2010, 12:50 p.m. UTC
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@canonical.com>
---
 debian/control-scripts/prerm    |   23 ++++++++++-------------
 debian/rules.d/2-binary-arch.mk |    2 ++
 2 files changed, 12 insertions(+), 13 deletions(-)

Comments

Adam Conrad Aug. 16, 2010, 1:08 p.m. UTC | #1
On 10-08-16 01:50 PM, Andy Whitcroft wrote:
> +  # NOTE: need to keep this list in sync with rules.d/2-binary-arch.mk
> +  my %files_to_keep = (
[...]
> +    if (!defined $wanted{$short}) {

Surely, you wanted "wanted" to be "files_to_keep" (or vice versa)?

... Adam
Andy Whitcroft Aug. 16, 2010, 2:06 p.m. UTC | #2
On Mon, Aug 16, 2010 at 02:08:43PM +0100, Adam Conrad wrote:
> On 10-08-16 01:50 PM, Andy Whitcroft wrote:
> > +  # NOTE: need to keep this list in sync with rules.d/2-binary-arch.mk
> > +  my %files_to_keep = (
> [...]
> > +    if (!defined $wanted{$short}) {
> 
> Surely, you wanted "wanted" to be "files_to_keep" (or vice versa)?
> 
> ... Adam

Woh, now how did that not die in testing.  I would have removed files in
the package, before dpkg tried to do so.  I will respin that, but that
renders the testing strategy somewhat broken.  Hrm.

-apw
diff mbox

Patch

diff --git a/debian/control-scripts/prerm b/debian/control-scripts/prerm
index ae248dd..51bbbc0 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 $wanted{$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 \