Package: dpkg
Version: 1.10.26
Author: Guillem Jover <guillem@debian.org>
Status: fixed
Debbug: 291939
Description:
 Implement Debian architecture alias support, and normalization via the new
 dpkg-architecture -n option.
 .
 Will take a virtual arch like <kernel>-any or any-<cpu> and expand to all
 available arches. And will also normalize linux-<cpu> to <cpu> for
 consistency.

diff -Naur dpkg-1.10.26/scripts/controllib.pl dpkg-1.10.26.alias/scripts/controllib.pl
--- dpkg-1.10.26/scripts/controllib.pl	2005-01-11 17:55:11.000000000 +0100
+++ dpkg-1.10.26.alias/scripts/controllib.pl	2005-01-24 09:21:44.000000000 +0100
@@ -79,6 +79,14 @@
     $substvar{'Arch'}= $arch;
 }
 
+sub normalize_archlist {
+    my ($archstr) = @_;
+    my @archlist = map(split(/\s+/, `dpkg-architecture -n$_`),
+                       split(/\s+/, $archstr));
+    chomp @archlist;
+    return @archlist;
+}
+
 sub substvars {
     my ($v) = @_;
     my ($lhs,$vn,$rhs,$count);
@@ -181,7 +189,7 @@
             my ($package, $relation, $version);
             $package = $1 if ($dep_or =~ s/^([a-zA-Z0-9][a-zA-Z0-9+._-]*)\s*//m);
             ($relation, $version) = ($1, $2) if ($dep_or =~ s/^\((=|<=|>=|<<?|>>?)\s*([^)]+).*\)\s*//m);
-            my @arches = split(/\s+/m, $1) if ($use_arch && $dep_or =~ s/^\[([^]]+)\]\s*//m);
+            my @arches = normalize_archlist($1) if ($use_arch && $dep_or =~ s/^\[([^]]+)\]\s*//m);
             if ($reduce_arch && @arches) {
 
                 my $seen_arch='';
diff -Naur dpkg-1.10.26/scripts/dpkg-architecture.pl dpkg-1.10.26.alias/scripts/dpkg-architecture.pl
--- dpkg-1.10.26/scripts/dpkg-architecture.pl	2005-01-11 17:55:11.000000000 +0100
+++ dpkg-1.10.26.alias/scripts/dpkg-architecture.pl	2005-01-24 09:06:45.000000000 +0100
@@ -92,6 +92,7 @@
        -s                 print command to set environment variables
        -u                 print command to unset environment variables
        -c <command>       set environment and run the command in it.
+       -n<debian-arch>    normalize Debian architecture
 
 Known Debian Architectures are ".join(", ",keys %archtable)."
 Known GNU System Types are ".join(", ",map ($archtable{$_},keys %archtable))."
@@ -122,6 +123,32 @@
 	return @list;
 }
 
+sub debian_arch_normalize
+{
+  my ($arch) = @_;
+  my @list;
+
+  if ($arch =~ /^any(-any)?$/) {
+    @list = keys %archtable;
+  } elsif ($arch =~ /^any-(.*)/) {
+    foreach my $cpu (@cpu) {
+      push @list, $cpu if $cpu eq $1;
+    }
+  } elsif ($arch =~ /(.*)-any$/) {
+    foreach my $os (@os) {
+      push @list, $os if $os eq $1;
+    }
+  } else {
+    $arch =~ s/^linux-//;
+    push @list, $arch;
+  }
+
+  return @list;
+}
+
+
 # Set default values:
 
 $deb_build_arch = `dpkg --print-installation-architecture`;
@@ -169,6 +203,7 @@
 
 $req_host_arch = '';
 $req_host_gnu_type = '';
+$req_normalize_arch = '';
 $action='l';
 $force=0;
 
@@ -178,6 +213,9 @@
 	$req_host_arch = $';
     } elsif (m/^-t/) {
 	$req_host_gnu_type = &rewrite_gnu($');
+    } elsif (m/^-n/) {
+	$req_normalize_arch = $';
+	$action = 'n';
     } elsif (m/^-[lsu]$/) {
 	$action = $_;
 	$action =~ s/^-//;
@@ -270,6 +308,9 @@
     } else {
         die "$req_variable_to_print is not a supported variable name";
     }
+} elsif ($action eq 'n') {
+  @arch_list = debian_arch_normalize($req_normalize_arch);
+  print "@arch_list\n";
 }
 
 __END__
diff -Naur dpkg-1.10.26/scripts/dpkg-gencontrol.pl dpkg-1.10.26.alias/scripts/dpkg-gencontrol.pl
--- dpkg-1.10.26/scripts/dpkg-gencontrol.pl	2005-01-11 17:55:11.000000000 +0100
+++ dpkg-1.10.26.alias/scripts/dpkg-gencontrol.pl	2005-01-24 09:02:47.000000000 +0100
@@ -138,7 +138,7 @@
             } elsif ($v eq 'any') {
                 $f{$_}= $arch;
             } else {
-                @archlist= split(/\s+/,$v);
+                @archlist= normalize_archlist($v);
                 grep($arch eq $_, @archlist) ||
                     &error("current build architecture $arch does not".
                            " appear in package's list (@archlist)");
diff -Naur dpkg-1.10.26/scripts/dpkg-source.pl dpkg-1.10.26.alias/scripts/dpkg-source.pl
--- dpkg-1.10.26/scripts/dpkg-source.pl	2005-01-11 17:55:11.000000000 +0100
+++ dpkg-1.10.26.alias/scripts/dpkg-source.pl	2005-01-24 09:03:40.000000000 +0100
@@ -175,7 +175,7 @@
 		    if (grep($sourcearch[0] eq $_, 'any','all'))  {
 			@sourcearch= ('any');
 		    } else {
-                        for $a (split(/\s+/,$v)) {
+                        for $a (normalize_archlist($v)) {
                             &error("architecture $a only allowed on its own".
                                    " (list for package $p is \`$a')")
                                    if grep($a eq $_, 'any','all');
