The following commit has been merged in the master branch:
commit 8631936c537335d66bb685dab55844d5fde262b5
Author: James McCoy <[email protected]>
Date:   Thu Jun 28 22:09:22 2012 -0400

    dscverify: Use GetOptions to handle argument parsing.
    
    Closes: #679148
    Signed-off-by: James McCoy <[email protected]>

diff --git a/debian/changelog b/debian/changelog
index b32bef1..539295e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,7 @@ devscripts (2.11.10) UNRELEASED; urgency=low
   [ James McCoy ]
   * build-rdeps, chdist, debsnap, dpkg-depcheck, rc-alert: Exit when unknown
     options are provided.  (Closes: #679374)
+  * dscverify: Use GetOptions to handle argument parsing.  (Closes: #679148)
 
  -- Benjamin Drung <[email protected]>  Sun, 17 Jun 2012 23:33:41 +0200
 
diff --git a/scripts/dscverify.pl b/scripts/dscverify.pl
index e7af118..1a3ec1c 100755
--- a/scripts/dscverify.pl
+++ b/scripts/dscverify.pl
@@ -26,6 +26,7 @@ use strict;
 use Cwd;
 use File::Basename;
 use POSIX      qw(:errno_h);
+use Getopt::Long qw(:config gnu_getopt);
 
 BEGIN {
     eval { require Digest::MD5; };
@@ -346,52 +347,22 @@ sub main {
        @rings = split /\s*:\s*/, $config_vars{'DSCVERIFY_KEYRINGS'};
     }
 
-    ## handle command-line options
-    while (@ARGV > 0) {
-       if ($ARGV[0] eq '--help') { usage; exit 0; }
-       if ($ARGV[0] eq '--version') { print $version; exit 0; }
-       if ($ARGV[0] =~ /^(--no(sig|-sig-)check|-u)$/) { $verify_sigs = 0; 
shift @ARGV; }
-       if ($ARGV[0] =~ /^--no-?conf$/) {
-           xdie "$ARGV[0] is only acceptable as the first command-line 
option!\n";
-       }
-       if ($ARGV[0] eq '--no-default-keyrings') {
-           $use_default_keyrings = 0;
-           shift @ARGV;
-       }
-       if ($ARGV[0] eq '--keyring') {
-           shift @ARGV;
-           if (@ARGV > 0) {
-               my $ring = shift @ARGV;
-               if (-r $ring) {
-                   push @rings, $ring;
-               }
-               else {
-                   xwarn "Keyring $ring unreadable\n";
-               }
-           }
-           # Don't need an 'else' here; a trailing --keyring will cause
-           # the program to die anyway (no .changes file)
-           next;
-       }
-       if ($ARGV[0] =~ s/^--keyring=//) {
-           my $ring = shift @ARGV;
-           if (-r $ring) {
-               push @rings, $ring;
-           }
-           else {
-               xwarn "Keyring $ring unreadable\n";
-           }
-           next;
-       }
-       if ($ARGV[0] eq '--verbose') {
-           shift @ARGV;
-           $verbose = 1;
-       }
-       if ($ARGV[0] eq '--') {
-           shift @ARGV; last;
-       }
-       last;
-    }
+    GetOptions(
+       'help' => sub { usage; exit 0; },
+       'version' => sub { print $version; exit 0; },
+       'sigcheck|sig-check!' => \$verify_sigs,
+       'u' => sub { $verify_sigs = 0 },
+       'noconf|no-conf' => sub {
+           die "--$_[0] is only acceptable as the first command-line 
option!\n";
+       },
+       'default-keyrings!' => \$use_default_keyrings,
+       'keyring=s@' => sub {
+           my $ring = $_[1];
+           if (-r $ring) { push @rings, $ring; }
+           else { die "Keyring $ring unreadable\n" }
+       },
+       'verbose' => \$verbose,
+    ) or do { usage; exit 1 };
 
     @ARGV or xdie "no .changes or .dsc files specified\n";
 

-- 
Git repository for devscripts

_______________________________________________
devscripts-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/devscripts-devel

Reply via email to