From: Ian Jackson Date: Mon, 4 Aug 2014 01:04:44 +0000 (+0100) Subject: Improve error message for .dsc having already been signed (iff using libdpkg-perl... X-Git-Tag: debian/0.22~13 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=commitdiff_plain;h=6b0c4982c4d3aa25970e87df150162e7cd4160c1;hp=e4fb7e9b2592d0a80ca213c94f3a462abd31c6c8 Improve error message for .dsc having already been signed (iff using libdpkg-perl 1.17.x) --- diff --git a/debian/changelog b/debian/changelog index f5f7b387..eccb21aa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 c8907cf6..ebeb8807 100755 --- 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};