diff --git a/debian/changelog b/debian/changelog index 72024415d..0bbc56777 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 46c709dd6..2c1b8cf16 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"; + } } }