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

login
register
mail settings
Submitter Andy Whitcroft
Date Aug. 16, 2010, 4:45 p.m.
Message ID <1281977143-29205-1-git-send-email-apw@canonical.com>
Download mbox | patch
Permalink /patch/61818/
State Accepted
Delegated to: Leann Ogasawara
Headers show

Comments

Andy Whitcroft - Aug. 16, 2010, 4:45 p.m.
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(-)
Tim Gardner - Aug. 16, 2010, 5:41 p.m.
On 08/16/2010 10:45 AM, Andy Whitcroft wrote:
> 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(-)
>
> 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 \

I like this approach better, assuming I've read the perl code correctly.

Acked-by: Tim Gardner <tim.gardner@canonical.com>
Leann Ogasawara - Aug. 16, 2010, 11:28 p.m.
Applied to Maverick linux master.

Thanks,
Leann

On Mon, 2010-08-16 at 17:45 +0100, Andy Whitcroft wrote:
> 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(-)
> 
> 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
> 
>

Patch

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 \