[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 04:15:22PM +0100, Raphael Hertzog wrote:
> To be fully multi-arch compliant, you should in theory use
> "${binary:Package}" instead of ${Package}. That way multi-arch: same
> package will be arch-qualified.

Fair enough.  Amended patch attached.

Thanks,

-- 
Colin Watson                                       [cjwatson@debian.org]
>From fd822639c3cb49fe1f0d7fe004834c27e02dba8a Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@debian.org>
Date: Fri, 9 Mar 2012 14:32:07 +0000
Subject: [PATCH 3/3] Process any newly pending triggers after running
 maintainer scripts

---
 dpkg-reconfigure |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/dpkg-reconfigure b/dpkg-reconfigure
index daa7bee..4bb1525 100755
--- a/dpkg-reconfigure
+++ b/dpkg-reconfigure
@@ -159,6 +159,8 @@ else {
 # hysterical raisens.
 $ENV{DEBCONF_RECONFIGURE}=1;
 
+my %initial_triggers=map { $_ => 1 } triggers_pending();
+
 foreach my $pkg (@packages) {
 	# Set default title.
 	$frontend->default_title($pkg);
@@ -255,6 +257,23 @@ foreach my $pkg (@packages) {
 	}
 }
 
+# Maintainer scripts may have activated triggers.  If so, try to process
+# them.
+my @new_triggers;
+do {
+	@new_triggers=();
+	foreach my $trigpend (triggers_pending()) {
+		push @new_triggers, $trigpend
+			if not exists $initial_triggers{$trigpend};
+	}
+	if (@new_triggers) {
+		my $ret=system("dpkg", "--configure", @new_triggers);
+		if (int($ret / 256) != 0) {
+			exit int($ret / 256);
+		}
+	}
+} while (@new_triggers);
+
 $frontend->shutdown;
 
 Debconf::Db->save;
@@ -275,6 +294,26 @@ sub allpackages {
 	return sort @ret;
 }
 
+# Returns a list of all packages with pending triggers.
+sub triggers_pending {
+	my @ret;
+	local $_;
+
+	open (QUERY, '-|', 'dpkg-query', '-W',
+		'-f', '${Package} ${binary:Package}\t${Triggers-Pending}\n');
+	while (<QUERY>) {
+		my ($pkgnames, $triggers) = split /\t/;
+		if (length $triggers) {
+			# Handle multiarch.
+			my ($pkg, $binpkg) = split ' ', $pkgnames;
+			push @ret, (length $binpkg ? $binpkg : $pkg);
+		}
+	}
+	close QUERY;
+
+	return @ret;
+}
+
 =head1 AUTHOR
 
 Joey Hess <joeyh@debian.org>
-- 
1.7.9.1


Reply to: