From: Guillem Jover Date: Sun, 4 Nov 2007 00:12:41 +0000 (+0200) Subject: dpkg-architecture: Perform -L actions inside argument processing loop X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b07d03f0f0c6043916882a8d7ac704a67ce8341;p=dpkg dpkg-architecture: Perform -L actions inside argument processing loop To preserve the same behaviour move the initialization of host and build variables after the argument processing loop. --- diff --git a/ChangeLog b/ChangeLog index c46d2c9a..adad184a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-11-04 Guillem Jover + + * scripts/dpkg-architecture.pl: Move setting of host and build arch + variables after argument processing. Call list_arches from argument + processing loop. Move architecture listing to ... + (list_arches): ... here. New function. + 2007-11-04 Guillem Jover * scripts/Dpkg/Arch.pm (get_valid_arches): Return an array instead of diff --git a/scripts/dpkg-architecture.pl b/scripts/dpkg-architecture.pl index e44d50ff..3ea94994 100755 --- a/scripts/dpkg-architecture.pl +++ b/scripts/dpkg-architecture.pl @@ -67,47 +67,11 @@ Actions: "), $progname; } -# Check for -L -if (grep { m/^-L$/ } @ARGV) { +sub list_arches() +{ foreach my $arch (get_valid_arches()) { print "$arch\n"; } - exit unless $#ARGV; -} - -# Set default values: - -chomp (my $deb_build_arch = `dpkg --print-architecture`); -&syserr("dpkg --print-architecture failed") if $?>>8; -my $deb_build_gnu_type = debtriplet_to_gnutriplet(debarch_to_debtriplet($deb_build_arch)); - -# Default host: Current gcc. -my $gcc = `\${CC:-gcc} -dumpmachine`; -if ($?>>8) { - warning(_g("Couldn't determine gcc system type, falling back to default (native compilation)")); - $gcc = ''; -} else { - chomp $gcc; -} - -my $deb_host_arch = undef; -my $deb_host_gnu_type; - -if ($gcc ne '') { - my (@deb_host_archtriplet) = gnutriplet_to_debtriplet($gcc); - $deb_host_arch = debtriplet_to_debarch(@deb_host_archtriplet); - unless (defined $deb_host_arch) { - warning(_g("Unknown gcc system type %s, falling back to default " . - "(native compilation)"), $gcc); - $gcc = ''; - } else { - $gcc = $deb_host_gnu_type = debtriplet_to_gnutriplet(@deb_host_archtriplet); - } -} -if (!defined($deb_host_arch)) { - # Default host: Native compilation. - $deb_host_arch = $deb_build_arch; - $deb_host_gnu_type = $deb_build_gnu_type; } @@ -144,7 +108,8 @@ while (@ARGV) { $action = 'c'; last; } elsif (m/^-L$/) { - # Handled already + list_arches(); + exit unless @ARGV; } elsif (m/^-(h|-help)$/) { &usage; exit 0; @@ -156,6 +121,41 @@ while (@ARGV) { } } +# Set default values: + +chomp (my $deb_build_arch = `dpkg --print-architecture`); +&syserr("dpkg --print-architecture failed") if $?>>8; +my $deb_build_gnu_type = debtriplet_to_gnutriplet(debarch_to_debtriplet($deb_build_arch)); + +# Default host: Current gcc. +my $gcc = `\${CC:-gcc} -dumpmachine`; +if ($?>>8) { + warning(_g("Couldn't determine gcc system type, falling back to default (native compilation)")); + $gcc = ''; +} else { + chomp $gcc; +} + +my $deb_host_arch = undef; +my $deb_host_gnu_type; + +if ($gcc ne '') { + my (@deb_host_archtriplet) = gnutriplet_to_debtriplet($gcc); + $deb_host_arch = debtriplet_to_debarch(@deb_host_archtriplet); + unless (defined $deb_host_arch) { + warning(_g("Unknown gcc system type %s, falling back to default " . + "(native compilation)"), $gcc); + $gcc = ''; + } else { + $gcc = $deb_host_gnu_type = debtriplet_to_gnutriplet(@deb_host_archtriplet); + } +} +if (!defined($deb_host_arch)) { + # Default host: Native compilation. + $deb_host_arch = $deb_build_arch; + $deb_host_gnu_type = $deb_build_gnu_type; +} + if ($req_host_arch ne '' && $req_host_gnu_type eq '') { $req_host_gnu_type = debtriplet_to_gnutriplet(debarch_to_debtriplet($req_host_arch)); die (sprintf(_g("unknown Debian architecture %s, you must specify GNU system type, too"), $req_host_arch)) unless defined $req_host_gnu_type;