&sourcepackage
&is_make_jobserver_unavailable &clean_jobserver_makeflags);
-my $max_compat=7;
+my $max_compat=8;
sub init {
my %params=@_;
# The kernel can accept command lines up to 20k worth of characters.
my $command_max=20000; # LINUX SPECIFIC!!
+ # (And obsolete; it's bigger now.)
# I could use POSIX::ARG_MAX, but that would be slow.
# Figure out length of static portion of command.
$filename="$dh{NAME}.$filename";
}
- my @try=("debian/$package.$filename.".buildarch(),
- "debian/$package.$filename.".buildos(),
- "debian/$package.$filename");
+ # First, check for files ending in buildarch and buildos.
+ my $match;
+ foreach my $file (glob("debian/$package.$filename.*")) {
+ next if ! -f $file;
+ next if $dh{IGNORE} && exists $dh{IGNORE}->{$file};
+ if ($file eq "debian/$package.$filename.".buildarch()) {
+ $match=$file;
+ # buildarch files are used in preference to buildos files.
+ last;
+ }
+ elsif ($file eq "debian/$package.$filename.".buildos()) {
+ $match=$file;
+ }
+ }
+ return $match if defined $match;
+
+ my @try=("debian/$package.$filename");
if ($package eq $dh{MAINPACKAGE}) {
push @try, "debian/$filename";
}
return 0;
}
-sub dpkg_architecture_value {
- my $var = shift;
- my $value=`dpkg-architecture -q$var` || error("dpkg-architecture failed");
- chomp $value;
- return $value;
-}
-
-# Returns the build architecture. (Memoized)
{
- my $arch;
-
- sub buildarch {
- if (!defined $arch) {
- $arch=dpkg_architecture_value('DEB_HOST_ARCH');
+ my %dpkg_arch_output;
+ sub dpkg_architecture_value {
+ my $var = shift;
+ if (! exists($dpkg_arch_output{$var})) {
+ local $_;
+ open(PIPE, '-|', 'dpkg-architecture')
+ or error("dpkg-architecture failed");
+ while (<PIPE>) {
+ chomp;
+ my ($k, $v) = split(/=/, $_, 2);
+ $dpkg_arch_output{$k} = $v;
+ }
+ close(PIPE);
}
- return $arch;
+ return $dpkg_arch_output{$var};
}
}
-# Returns the build OS. (Memoized)
-{
- my $os;
+# Returns the build architecture.
+sub buildarch {
+ dpkg_architecture_value('DEB_HOST_ARCH');
+}
- sub buildos {
- if (!defined $os) {
- $os=dpkg_architecture_value("DEB_HOST_ARCH_OS");
- }
- return $os;
- }
+# Returns the build OS.
+sub buildos {
+ dpkg_architecture_value("DEB_HOST_ARCH_OS");
}
# 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