summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2014-08-04 02:04:44 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2014-08-04 02:04:44 +0100
commit6b0c4982c4d3aa25970e87df150162e7cd4160c1 (patch)
treece61d14cd426aedc9db1fec9209c0432c8292638 /dgit
parente4fb7e9b2592d0a80ca213c94f3a462abd31c6c8 (diff)
Improve error message for .dsc having already been signed (iff using libdpkg-perl 1.17.x)
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit31
1 files changed, 25 insertions, 6 deletions
diff --git a/dgit b/dgit
index c8907cf..ebeb880 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};