[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#560317: dpkg-reconfigure does not set DPKG_MAINTSCRIPT_PACKAGE (et al)

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@debian.org]

Reply to: