[Debconf-devel] Bug#560317: dpkg-reconfigure does not set DPKG_MAINTSCRIPT_PACKAGE (et al)

Colin Watson cjwatson at debian.org
Mon Mar 12 10:44:49 UTC 2012


On Fri, Mar 09, 2012 at 12:36:06PM -0400, Joey Hess wrote:
> It's a shame that dpkg-query is so slow. Cold cache (which will be
> typical), it takes something like a second to run; warm cache around .3
> seconds. Overhead includes reading the entire status file. The above
> code runs it 5 times in all.
> 
> So, it would be worth only running it once and picking out the
> appropriate filenames from its output.

How about this, then?

diff --git a/dpkg-reconfigure b/dpkg-reconfigure
index 4bb1525..9e27fde 100755
--- a/dpkg-reconfigure
+++ b/dpkg-reconfigure
@@ -183,10 +183,18 @@ foreach my $pkg (@packages) {
 		}
 	}
 	
+	my @control_paths=`dpkg-query --control-path $pkg`;
+	map chomp, @control_paths;
+	sub control_path {
+		my $file = shift;
+		my $path = (grep /\.\Q$file\E$/, @control_paths)[0];
+		chomp($path) if defined $path;
+		return $path;
+	}
+
 	if ($reload) {
 		# Load up templates just in case they aren't already.
-		my $templates=`dpkg-query --control-path $pkg templates`;
-		chomp($templates);
+		my $templates=control_path('templates');
 		if ($templates and -e $templates) {
 			Debconf::Template->load($templates, $pkg);
 		}
@@ -201,8 +209,7 @@ foreach my $pkg (@packages) {
 		          ['config',   'reconfigure', $version],
 			  ['postinst', 'configure',   $version]) {
 		my $script=shift @$info;
-		my $path_script=`dpkg-query --control-path $pkg $script`;
-		chomp($path_script);
+		my $path_script=control_path($script);
 
 		next unless $path_script and -x $path_script;
 
> PS, cdebconf includes a dpkg-reconfigure now and will need the same
> changes. Probably we need to make sure to communicate substantial
> changes like this with Regis at least until cdebconf takes over from
> debconf.

cdebconf is actually ahead of debconf on this right now: it already has
the 'dpkg-query --control-path' thing (and just runs it once per
script), and it also already sets the DPKG_MAINTSCRIPT_* variables.  It
does need the triggers work, though.  CCing Regis here.

-- 
Colin Watson                                       [cjwatson at debian.org]





More information about the Debconf-devel mailing list