chiark / gitweb /
Improve error message for .dsc having already been signed (iff using libdpkg-perl...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 4 Aug 2014 01:04:44 +0000 (02:04 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 4 Aug 2014 01:04:44 +0000 (02:04 +0100)
debian/changelog
dgit

index f5f7b38782aa4ba7b510517bb38b55a4da7c1fcd..eccb21aa9f8a7251d83d466ef47b9a1b1f9a1803 100644 (file)
@@ -33,6 +33,8 @@ dgit (0.22~experimental1) experimental; urgency=low
   * Provide `dgit clean'.  Closes:#736527.
   * When cloning, set up a remote `vcs-git' from the package's Vcs-Git
     (and put an appropriate caveat in the manpage).  Closes:#740687.
+  * Improve error message for .dsc having already been signed (iff
+    using libdpkg-perl 1.17.x)
 
   Major new feature, currently stalled awaiting server infrastructure:
   * dgit-repos-server: New program for receiving signed-tag-based
diff --git a/dgit b/dgit
index c8907cf6eb48739a2f53854c46cf54cb641ba79c..ebeb8807b4419ded8d33237d9b09061e9a907d9a 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -594,11 +594,30 @@ sub access_giturl () {
     return "$url/$package.git";
 }             
 
-sub parsecontrolfh ($$@) {
-    my ($fh, $desc, @opts) = @_;
-    my %opts = ('name' => $desc, @opts);
-    my $c = Dpkg::Control::Hash->new(%opts);
-    $c->parse($fh) or die "parsing of $desc failed";
+sub parsecontrolfh ($$;$) {
+    my ($fh, $desc, $allowsigned) = @_;
+    our $dpkgcontrolhash_noissigned;
+    my $c;
+    for (;;) {
+       my %opts = ('name' => $desc);
+       $opts{allow_pgp}= $allowsigned || !$dpkgcontrolhash_noissigned;
+print STDERR Dumper(\%opts);
+       $c = Dpkg::Control::Hash->new(%opts);
+       $c->parse($fh) or die "parsing of $desc failed";
+       last if $allowsigned;
+       last if $dpkgcontrolhash_noissigned;
+       my $issigned= $c->get_option('is_pgp_signed');
+       if (!defined $issigned) {
+           $dpkgcontrolhash_noissigned= 1;
+           seek $fh, 0,0 or die "seek $desc: $!";
+       } elsif ($issigned) {
+           fail "control file $desc is (already) PGP-signed. ".
+               " Note that dgit push needs to modify the .dsc and then".
+               " do the signature itself";
+       } else {
+           last;
+       }
+    }
     return $c;
 }
 
@@ -857,7 +876,7 @@ sub get_archive_dsc () {
        }
        my $dscfh = new IO::File \$dscdata, '<' or die $!;
        printdebug Dumper($dscdata) if $debug>1;
-       $dsc = parsecontrolfh($dscfh,$dscurl, allow_pgp=>1);
+       $dsc = parsecontrolfh($dscfh,$dscurl,1);
        printdebug Dumper($dsc) if $debug>1;
        my $fmt = getfield $dsc, 'Format';
        fail "unsupported source format $fmt, sorry" unless $format_ok{$fmt};