diff options
author | Guillem Jover <guillem@debian.org> | 2014-10-10 14:48:40 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2014-10-12 06:08:00 +0200 |
commit | a8e036317bc203372949315519ed9474fb504a16 (patch) | |
tree | 5ac981ca332ab3f10fb36b8c2c26d9482c435605 /scripts | |
parent | 0a2a1af94495be0b8204f827abc09e20a11dd447 (diff) | |
download | dpkg-a8e036317bc203372949315519ed9474fb504a16.tar.gz |
dpkg-architecture: Normalize ARGV parsing
This allows to accept «-ovalue», «-o value», «--option=value» and
«--option value», which are the common option formats people expect.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/dpkg-architecture.pl | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/scripts/dpkg-architecture.pl b/scripts/dpkg-architecture.pl index 431e07dd6..e6afa2ab1 100755 --- a/scripts/dpkg-architecture.pl +++ b/scripts/dpkg-architecture.pl @@ -24,6 +24,7 @@ use warnings; use Dpkg (); use Dpkg::Gettext; +use Dpkg::Getopt; use Dpkg::ErrorHandling; use Dpkg::Arch qw(get_raw_build_arch get_raw_host_arch get_gcc_host_gnu_type debarch_to_cpuattrs @@ -166,59 +167,63 @@ sub action_needs($) { return (($req_vars & $bits) == $bits); } +@ARGV = normalize_options(@ARGV); + while (@ARGV) { - $_=shift(@ARGV); - if (m/^-a/p) { - $req_host_arch = ${^POSTMATCH}; - } elsif (m/^-t/p) { - $req_host_gnu_type = ${^POSTMATCH}; - } elsif (m/^-A/p) { - $req_target_arch = ${^POSTMATCH}; - } elsif (m/^-T/p) { - $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) { - $req_eq_arch = ${^POSTMATCH}; + my $arg = shift; + + if ($arg eq '-a') { + $req_host_arch = shift; + } elsif ($arg eq '-t') { + $req_host_gnu_type = shift; + } elsif ($arg eq '-A') { + $req_target_arch = shift; + } elsif ($arg eq '-T') { + $req_target_gnu_type = shift; + } elsif ($arg eq '-W') { + $req_match_wildcard = shift; + } elsif ($arg eq '-B') { + $req_match_bits = shift; + } elsif ($arg eq '-E') { + $req_match_endian = shift; + } elsif ($arg eq '-e') { + $req_eq_arch = shift; $req_vars = $arch_vars{DEB_HOST_ARCH}; $action = 'e'; - } elsif (m/^-i/p) { - $req_is_arch = ${^POSTMATCH}; + } elsif ($arg eq '-i') { + $req_is_arch = shift; $req_vars = $arch_vars{DEB_HOST_ARCH}; $action = 'i'; - } elsif (m/^-u$/) { + } elsif ($arg eq '-u') { $req_vars = DEB_NONE; $action = 'u'; - } elsif (m/^-[ls]$/) { - $action = $_; - $action =~ s/^-//; - } elsif (m/^-f$/) { + } elsif ($arg eq '-l') { + $action = 'l'; + } elsif ($arg eq '-s') { + $action = 's'; + } elsif ($arg eq '-f') { $force=1; - } elsif (m/^-q/p) { - my $varname = ${^POSTMATCH}; + } elsif ($arg eq '-q') { + my $varname = shift; error(_g('%s is not a supported variable name'), $varname) unless (exists $arch_vars{$varname}); $req_variable_to_print = "$varname"; $req_vars = $arch_vars{$varname}; $action = 'q'; - } elsif (m/^-c$/) { + } elsif ($arg eq '-c') { $action = 'c'; last; - } elsif (m/^-L$/) { + } elsif ($arg eq '-L') { $req_vars = 0; $action = 'L'; - } elsif (m/^-(?:\?|-help)$/) { + } elsif ($arg eq '-?' or $arg eq '--help') { usage(); exit 0; - } elsif (m/^--version$/) { + } elsif ($arg eq '--version') { version(); exit 0; } else { - usageerr(_g("unknown option \`%s'"), $_); + usageerr(_g("unknown option \`%s'"), $arg); } } |