[linux] 05/08: linux-image: prerm: Allow removal of running kernel if we can't ask debconf questions

debian-kernel at lists.debian.org debian-kernel at lists.debian.org
Fri May 27 13:53:04 UTC 2016


This is an automated email from the git hooks/post-receive script.

benh pushed a commit to branch master
in repository linux.

commit 49b5fbab507dc526003725fb29bb6f3f912d9766
Author: Ben Hutchings <ben at decadent.org.uk>
Date:   Thu May 26 23:15:54 2016 +0100

    linux-image: prerm: Allow removal of running kernel if we can't ask debconf questions
    
    Closes: #825423
---
 debian/changelog                |  2 ++
 debian/templates/image.prerm.in | 52 +++++++++++++++++++++++------------------
 2 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 7202441..0bbc567 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -22,6 +22,8 @@ linux (4.6-1~exp2) UNRELEASED; urgency=medium
   * [mips*/*-malta] udeb: Add ata-modules package
   * linux-image: Stop setting $STEM in environment for maintainer script hooks
   * linux-image: Add workaround for bug #817083 in debconf
+  * linux-image: prerm: Allow removal of running kernel if we can't ask debconf
+    questions (Closes: #825423)
 
   [ Aurelien Jarno ]
   * [mips64{,el}] Set CPU to MIPS64 R2.
diff --git a/debian/templates/image.prerm.in b/debian/templates/image.prerm.in
index 46c709d..2c1b8cf 100755
--- a/debian/templates/image.prerm.in
+++ b/debian/templates/image.prerm.in
@@ -43,37 +43,43 @@ if (-r "$CONF_LOC" && -f "$CONF_LOC"  ) {
 }
 
 
-#check to see if we are trying to remove a running kernel
-# if so we abort right now.
+# Check to see if we are trying to remove a running kernel.
 chop($running=`uname -r`);
 if ($running eq $version) {
-  my $question = "${package_name}/prerm/removing-running-kernel-$version";
+  # If we can ask debconf questions, ask whether that's intended
+  # and abort if not.
+  if (exists($ENV{'DEBIAN_FRONTEND'}) &&
+      $ENV{'DEBIAN_FRONTEND'} eq 'noninteractive') {
+    print STDERR "W: removing running kernel image.\n";
+  } else {
+    my $question = "${package_name}/prerm/removing-running-kernel-$version";
 
-  ($ret,$seen) = fset ("$question", 'seen', 'false');
-  die "Error setting debconf flags in $question: $seen" if $ret;
+    ($ret,$seen) = fset ("$question", 'seen', 'false');
+    die "Error setting debconf flags in $question: $seen" if $ret;
 
-  $ret = subst("$question", 'running', "$running");
-  die "Error setting debconf substitutions in $question: $seen" if $ret;
+    $ret = subst("$question", 'running', "$running");
+    die "Error setting debconf substitutions in $question: $seen" if $ret;
 
-  ($ret,$seen) = input('critical', "$question");
-  if ($ret && $ret != 30 ) {
-    die "Error setting debconf question $question: $seen";
-  }
+    ($ret,$seen) = input('critical', "$question");
+    if ($ret && $ret != 30 ) {
+      die "Error setting debconf question $question: $seen";
+    }
 
-  ($ret,$seen) = go ();
-  if ($ret && $ret != 30 ) {
-    die "Error asking debconf question $question: $seen";
-  }
+    ($ret,$seen) = go ();
+    if ($ret && $ret != 30 ) {
+      die "Error asking debconf question $question: $seen";
+    }
 
-  ($ret,$answer) = get("$question");
-  die "Error retreiving answer for $question: $answer" if $ret;
+    ($ret,$answer) = get("$question");
+    die "Error retreiving answer for $question: $answer" if $ret;
 
-  if ($answer =~ /^(y|t)/i) {
-    print STDERR "Aborting removal of running kernel image.\n";
-    exit 1; #Operation not permitted
-  }
-  else {
-     print STDERR "Ok, proceeding with removing running kernel image.\n";
+    if ($answer =~ /^(y|t)/i) {
+      print STDERR "Aborting removal of running kernel image.\n";
+      exit 1; #Operation not permitted
+    }
+    else {
+       print STDERR "Ok, proceeding with removing running kernel image.\n";
+    }
   }
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux.git



More information about the Kernel-svn-changes mailing list