Bladeren bron

dpkg-architecture: Add architecture restriction options for -L

This allows to select specific subsets of all valid known architectures,
matching by wildcard (-W), endianness (-E) or bits (-B). The restricting
options can be combined, or omitted altogether.

Closes: #762635
Guillem Jover 12 jaren geleden
bovenliggende
commit
1987e8e3e1
3 gewijzigde bestanden met toevoegingen van 38 en 2 verwijderingen
  1. 4 0
      debian/changelog
  2. 14 0
      man/dpkg-architecture.1
  3. 20 2
      scripts/dpkg-architecture.pl

+ 4 - 0
debian/changelog

@@ -96,6 +96,10 @@ dpkg (1.17.14) UNRELEASED; urgency=low
     if stdin is a pipe instead of the current terminal. Closes: #762391
     if stdin is a pipe instead of the current terminal. Closes: #762391
   * Add a new --hash option to enable generating only specific file checksums
   * Add a new --hash option to enable generating only specific file checksums
     in dpkg-scanpackages. Requested by Thorsten Glaser <tg@debian.org>.
     in dpkg-scanpackages. Requested by Thorsten Glaser <tg@debian.org>.
+  * Add architecture restriction options for dpkg-architecture -L. This allows
+    to select specific subsets of all valid known architectures, matching by
+    wildcard (-W), endianness (-E) or bits (-B). The restricting options can
+    be combined, or omitted altogether. Closes: #762635
 
 
   [ Raphaël Hertzog ]
   [ Raphaël Hertzog ]
   * Explain better in deb-triggers(5) why interest/activate-noawait should be
   * Explain better in deb-triggers(5) why interest/activate-noawait should be

+ 14 - 0
man/dpkg-architecture.1

@@ -81,6 +81,8 @@ the determined value.
 .TP
 .TP
 .B \-L
 .B \-L
 Print a list of valid architecture names.
 Print a list of valid architecture names.
+Possibly restricted by one or more of the matching options \fB\-W\fP,
+\fB\-B\fP or \fB\-E\fP (since dpkg 1.17.14).
 .TP
 .TP
 .BR \-? ", " \-\-help
 .BR \-? ", " \-\-help
 Show the usage message and exit.
 Show the usage message and exit.
@@ -104,6 +106,18 @@ run on the host architecture, and to build code for the target architecture.
 .BI \-T gnu-system-type
 .BI \-T gnu-system-type
 Set the target GNU system type.
 Set the target GNU system type.
 .TP
 .TP
+.BI \-W architecture-wildcard
+Restrict the architectures listed by \fB\-L\fP to ones matching the specified
+architecture wildcard (since dpkg 1.17.14).
+.TP
+.BI \-B architecture-bits
+Restrict the architectures listed by \fB\-L\fP to ones with the specified
+CPU bits (since dpkg 1.17.14). Either \fB32\fP or \fB64\fP.
+.TP
+.BI \-E architecture-endianness
+Restrict the architectures listed by \fB\-L\fP to ones with the specified
+endianness (since dpkg 1.17.14). Either \fBlittle\fP or \fBbig\fP.
+.TP
 .B \-f
 .B \-f
 Values set by existing environment variables with the same name as used by
 Values set by existing environment variables with the same name as used by
 the scripts are honored (i.e. used by \fBdpkg\-architecture\fP), except if
 the scripts are honored (i.e. used by \fBdpkg\-architecture\fP), except if

+ 20 - 2
scripts/dpkg-architecture.pl

@@ -48,7 +48,7 @@ sub usage {
     . "\n\n" . _g(
     . "\n\n" . _g(
 'Commands:
 'Commands:
   -l                 list variables (default).
   -l                 list variables (default).
-  -L                 list valid architectures.
+  -L                 list valid architectures (matching some criteria).
   -e<debian-arch>    compare with host Debian architecture.
   -e<debian-arch>    compare with host Debian architecture.
   -i<arch-alias>     check if host Debian architecture is <arch-alias>.
   -i<arch-alias>     check if host Debian architecture is <arch-alias>.
   -q<variable>       prints only the value of <variable>.
   -q<variable>       prints only the value of <variable>.
@@ -63,6 +63,9 @@ sub usage {
   -t<gnu-system>     set host GNU system type.
   -t<gnu-system>     set host GNU system type.
   -A<debian-arch>    set target Debian architecture.
   -A<debian-arch>    set target Debian architecture.
   -T<gnu-system>     set target GNU system type.
   -T<gnu-system>     set target GNU system type.
+  -W<arch-wildcard>  restrict listed architectures matching <arch-wildcard>.
+  -B<arch-bits>      restrict listed architectures matching <arch-bits>.
+  -E<arch-endian>    restrict listed architectures matching <arch-endian>.
   -f                 force flag (override variables set in environment).')
   -f                 force flag (override variables set in environment).')
     . "\n", $Dpkg::PROGNAME;
     . "\n", $Dpkg::PROGNAME;
 }
 }
@@ -151,6 +154,9 @@ my $req_target_arch = '';
 my $req_target_gnu_type = '';
 my $req_target_gnu_type = '';
 my $req_eq_arch = '';
 my $req_eq_arch = '';
 my $req_is_arch = '';
 my $req_is_arch = '';
+my $req_match_wildcard = '';
+my $req_match_bits = '';
+my $req_match_endian = '';
 my $req_variable_to_print;
 my $req_variable_to_print;
 my $action = 'l';
 my $action = 'l';
 my $force = 0;
 my $force = 0;
@@ -170,6 +176,12 @@ while (@ARGV) {
 	$req_target_arch = ${^POSTMATCH};
 	$req_target_arch = ${^POSTMATCH};
     } elsif (m/^-T/p) {
     } elsif (m/^-T/p) {
 	$req_target_gnu_type = ${^POSTMATCH};
 	$req_target_gnu_type = ${^POSTMATCH};
+    } elsif (m/^-W/p) {
+	$req_match_wildcard = ${^POSTMATCH};
+    } elsif (m/^-B/p) {
+	$req_match_bits = ${^POSTMATCH};
+    } elsif (m/^-E/p) {
+	$req_match_endian = ${^POSTMATCH};
     } elsif (m/^-e/p) {
     } elsif (m/^-e/p) {
 	$req_eq_arch = ${^POSTMATCH};
 	$req_eq_arch = ${^POSTMATCH};
 	$req_vars = $arch_vars{DEB_HOST_ARCH};
 	$req_vars = $arch_vars{DEB_HOST_ARCH};
@@ -334,6 +346,12 @@ if ($action eq 'l') {
     print "$v{$req_variable_to_print}\n";
     print "$v{$req_variable_to_print}\n";
 } elsif ($action eq 'L') {
 } elsif ($action eq 'L') {
     foreach my $arch (get_valid_arches()) {
     foreach my $arch (get_valid_arches()) {
-       print "$arch\n";
+        my ($bits, $endian) = debarch_to_cpuattrs($arch);
+
+        next if $req_match_endian and $endian ne $req_match_endian;
+        next if $req_match_bits and $bits ne $req_match_bits;
+        next if $req_match_wildcard and not debarch_is($arch, $req_match_wildcard);
+
+        print "$arch\n";
     }
     }
 }
 }