diff options
author | Joey Hess <joey@kitenet.net> | 2010-04-26 19:45:04 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-04-26 19:45:04 -0400 |
commit | ea6ba7479b984b770df7f9325ab6035e1a2f5b13 (patch) | |
tree | 072cf518428cecab0f3a4ba48b2e2278d40e99da | |
parent | e74b1d8fa271f761ffbfda8207806b2a153735b7 (diff) |
Memoize architecture comparisons in samearch, and avoid calling dpkg-architecture at all for simple comparisons not involving architecture wildcards. Closes:# 579317
-rw-r--r-- | Debian/Debhelper/Dh_Lib.pm | 33 | ||||
-rw-r--r-- | debian/changelog | 8 |
2 files changed, 34 insertions, 7 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm index d9c1d389..421dd996 100644 --- a/Debian/Debhelper/Dh_Lib.pm +++ b/Debian/Debhelper/Dh_Lib.pm @@ -638,15 +638,34 @@ sub dpkg_architecture_value { } # Passed an arch and a list of arches to match against, returns true if matched -sub samearch { - my $arch=shift; - my @archlist=split(/\s+/,shift); +{ + my %knownsame; - foreach my $a (@archlist) { - system("dpkg-architecture", "-a$arch", "-i$a") == 0 && return 1; + sub samearch { + my $arch=shift; + my @archlist=split(/\s+/,shift); + + foreach my $a (@archlist) { + # Avoid expensive dpkg-architecture call to compare + # with a simple architecture name. "linux-any" and + # other architecture wildcards are (currently) + # always hypenated. + if ($a !~ /-/) { + return 1 if $arch eq $a; + } + elsif (exists $knownsame{$arch}{$a}) { + return 1 if $knownsame{$arch}{$a}; + } + elsif (system("dpkg-architecture", "-a$arch", "-i$a") == 0) { + return $knownsame{$arch}{$a}=1; + } + else { + $knownsame{$arch}{$a}=0; + } + } + + return 0; } - - return 0; } # Returns source package name diff --git a/debian/changelog b/debian/changelog index 970d7644..23f76c8b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +debhelper (7.4.19) UNRELEASED; urgency=low + + * Memoize architecture comparisons in samearch, and avoid calling + dpkg-architecture at all for simple comparisons not involving + architecture wildcards. Closes:# 579317 + + -- Joey Hess <joeyh@debian.org> Mon, 26 Apr 2010 19:35:53 -0400 + debhelper (7.4.18) unstable; urgency=low * dh_gconf: Depend on new gconf2 that uses triggers, and stop |