summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-04-24 14:14:45 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-04-24 14:14:45 -0400
commit28d8588b35d3f165d3ece6635b2416c8b818bf38 (patch)
tree40d63749e8f80813cec5d594e90d224df4bcd725
parentbb822a1b2711203e6a6967f5e487444ba29e625a (diff)
dh: Optimise the case where the binary-arch or binary-indep sequence is run and there are no packages of that type.
-rw-r--r--debian/changelog7
-rwxr-xr-xdh24
2 files changed, 24 insertions, 7 deletions
diff --git a/debian/changelog b/debian/changelog
index 23f7535..23d9b27 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+debhelper (7.0.2) UNRELEASED; urgency=low
+
+ * dh: Optimise the case where the binary-arch or binary-indep sequence is
+ run and there are no packages of that type.
+
+ -- Joey Hess <joeyh@debian.org> Thu, 24 Apr 2008 14:10:56 -0400
+
debhelper (7.0.1) unstable; urgency=low
* I lied, one more v7 change slipped in..
diff --git a/dh b/dh
index 793180a..d4c4f9c 100755
--- a/dh
+++ b/dh
@@ -254,10 +254,10 @@ $sequences{'binary-arch'} = [@{$sequences{binary}}];
# Third-party commands can be listed in the sequences, but should be
# listed here as well. They will not be run if not present.
-my %thirdparty=(
- dh_pycompat => 1,
- dh_pysupport => 1,
-);
+my %thirdparty=map { $_ => 1 } qw{
+ dh_pycompat
+ dh_pysupport
+};
# Get the sequence of commands to run.
if (! @ARGV) {
@@ -270,14 +270,24 @@ if (! exists $sequences{$sequence}) {
}
my @sequence=@{$sequences{$sequence}};
+# The list of all packages that can be acted on.
+my @packages=@{$dh{DOPACKAGES}};
+
# Get the options to pass to commands in the sequence.
# Filter out options intended only for this program.
my @options;
if ($sequence eq 'binary-arch') {
push @options, "-a";
+ # as an optimisation, remove from the list any packages
+ # that are not arch dependent
+ my %arch_packages = map { $_ => 1 } getpackages("arch");
+ @packages = grep { $arch_packages{$_} } @packages;
}
elsif ($sequence eq 'binary-indep') {
push @options, "-i";
+ # ditto optimisation for arch indep
+ my %indep_packages = map { $_ => 1 } getpackages("indep");
+ @packages = grep { $indep_packages{$_} } @packages;
}
while (@ARGV_orig) {
my $opt=shift @ARGV_orig;
@@ -295,7 +305,7 @@ while (@ARGV_orig) {
# Figure out at what point in the sequence to start for each package.
my %logged;
my %startpoint;
-foreach my $package (@{$dh{DOPACKAGES}}) {
+foreach my $package (@packages) {
my @log=loadlog($package);
if ($dh{AFTER}) {
# Run commands in the sequence that come after the
@@ -342,14 +352,14 @@ elsif ($dh{BEFORE}) {
foreach my $i (0..$stoppoint) {
# Figure out which packages need to run this command.
my @exclude;
- foreach my $package (@{$dh{DOPACKAGES}}) {
+ foreach my $package (@packages) {
if ($startpoint{$package} > $i ||
$logged{$package}{$sequence[$i]}) {
push @exclude, $package;
}
}
- if (@exclude eq @{$dh{DOPACKAGES}}) {
+ if (@exclude eq @packages) {
# Command already done for all packages.
next;
}