summaryrefslogtreecommitdiff
path: root/dh
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 /dh
parentbb822a1b2711203e6a6967f5e487444ba29e625a (diff)
dh: Optimise the case where the binary-arch or binary-indep sequence is run and there are no packages of that type.
Diffstat (limited to 'dh')
-rwxr-xr-xdh24
1 files changed, 17 insertions, 7 deletions
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;
}