[Debconf-devel] Bug#817083: Bug#817083: debconf templates are not loaded in prerm

Colin Watson cjwatson at debian.org
Tue Mar 8 10:17:40 UTC 2016


On Tue, Mar 08, 2016 at 01:04:06AM +0000, Ben Hutchings wrote:
> It appears that using debconf in a preinst or postinst script causes
> debconf templates to be loaded automagically.  However, since version
> 4.4.1-1~exp1 the linux-image-* packages only use debconf in the prerm
> script.  In the case where the script asks a question, debconf does
> not find the template and the prerm script fails.
> 
> The manual page for debconf-loadtemplate says it should never be used
> from maintainer scripts, so I don't see how we're supposed to make
> this work.

Can you see if this patch works?  (If you're applying this directly to
/usr/share/debconf/frontend, note that comments are stripped on
installation, but it should be reasonably obvious what to do.)

diff --git a/frontend b/frontend
index 690bedc..0e90cd1 100755
--- a/frontend
+++ b/frontend
@@ -96,6 +96,15 @@ debug developer => "frontend running, package name is $package";
 $frontend->default_title($package) if length $package and !$no_title;
 $frontend->info(undef);
 
+# Load any associated templates if we're being run from a package maintainer
+# script.
+if ($ARGV[0] =~/^(.*[.\/])(?:preinst|postinst|prerm|postrm)$/) {
+	my $base=$1;
+	my $templates=$base."templates";
+	Debconf::Template->load($templates, $package)
+		if -e $templates;
+}
+
 # See if the preinst or postinst of the package is being run, and if there
 # is a config script associated with this package. If so, run it first as a
 # confmodule (also loading the templates). This is a bit of a nasty hack, that
@@ -106,11 +115,6 @@ $frontend->info(undef);
 if ($ARGV[0] =~/^(.*[.\/])(?:postinst|preinst)$/) {
 	my $base=$1;
 
-	# Load templates, if any.
-	my $templates=$base."templates";
-	Debconf::Template->load($templates, $package)
-		if -e $templates;
-
 	# Run config script, if any.
 	my $config=$base."config";
 	if (-e $config) {

Thanks,

-- 
Colin Watson                                       [cjwatson at debian.org]



More information about the Debconf-devel mailing list