X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=dgit;h=58567498f8ca50032cb67e1db29345d107c04c00;hb=5ed00ff3ed9037f29a6718888525e32731947da2;hp=562cef08f913eab9dbf2910dccf6da94c00372a7;hpb=7c57131ff6c444187b09ed9be5b58e5c0112a5e2;p=dgit.git diff --git a/dgit b/dgit index 562cef08..58567498 100755 --- a/dgit +++ b/dgit @@ -49,6 +49,9 @@ our (@git) = qw(git); our (@dget) = qw(dget); our (@dput) = qw(dput); our (@debsign) = qw(debsign); +our (@gpg) = qw(gpg); +fixme should be in manual +fixme should pass this to debsign our (@sbuild) = qw(sbuild -A); our (@dpkgbuildpackage) = qw(dpkg-buildpackage -i\.git/ -I.git); our (@dpkgsource) = qw(dpkg-source -i\.git/ -I.git); @@ -59,6 +62,7 @@ our (@changesopts) = (''); our %opts_opt_map = ('dget' => \@dget, 'dput' => \@dput, 'debsign' => \@debsign, + 'gpg' => \@gpg, 'sbuild' => \@sbuild, 'dpkg-source' => \@dpkgsource, 'dpkg-buildpackage' => \@dpkgbuildpackage, @@ -131,7 +135,7 @@ sub url_get { return $r->decoded_content(); } -our ($dscdata,$dscurl,$dsc); +our ($dscdata,$dscurl,$dsc,$skew_warning_vsn); sub printcmd { my $fh = shift @_; @@ -209,6 +213,11 @@ sub runcmd_ordryrun { } } +sub shell_cmd { + my ($first_shell, @cmd) = @_; + return qw(sh -ec), $first_shell.'; exec "$@"', 'x', @cmd; +} + our $helpmsg = <new(); my $p = new IO::Handle; - my @cmd = (qw(dpkg-parsechangelog)); + my @cmd = (qw(dpkg-parsechangelog), @_); open $p, '-|', @cmd or die $!; $c->parse($p); $?=0; $!=0; close $p or failedcmd @cmd; @@ -445,16 +454,19 @@ sub get_archive_dsc () { my ($vsn,$subpath) = @$vinfo; $dscurl = access_cfg('mirror').$subpath; $dscdata = url_get($dscurl); - next unless defined $dscdata; + if (!$dscdata) { + $skew_warning_vsn = $vsn if !defined $skew_warning_vsn; + next; + } my $dscfh = new IO::File \$dscdata, '<' or die $!; print DEBUG Dumper($dscdata) if $debug>1; $dsc = parsecontrolfh($dscfh,$dscurl, allow_pgp=>1); print DEBUG Dumper($dsc) if $debug>1; my $fmt = getfield $dsc, 'Format'; fail "unsupported source format $fmt, sorry" unless $format_ok{$fmt}; - return $dsc; + return; } - return undef; + $dsc = undef; } sub check_for_git () { @@ -660,8 +672,7 @@ sub ensure_we_have_orig () { $origurl .= "/$f"; die "$f ?" unless $f =~ m/^${package}_/; die "$f ?" if $f =~ m#/#; - runcmd_ordryrun qw(sh -ec),'cd ..; exec "$@"','x', - @dget,'--',$origurl; + runcmd_ordryrun shell_cmd 'cd ..', @dget,'--',$origurl; } } @@ -688,17 +699,22 @@ sub git_fetch_us () { sub fetch_from_archive () { # ensures that lrref() is what is actually in the archive, # one way or another - get_archive_dsc() or return 0; - foreach my $field (@ourdscfield) { - $dsc_hash = $dsc->{$field}; - last if defined $dsc_hash; - } - if (defined $dsc_hash) { - $dsc_hash =~ m/\w+/ or fail "invalid hash in .dsc \`$dsc_hash'"; - $dsc_hash = $&; - print "last upload to archive specified git hash\n"; + get_archive_dsc(); + + if ($dsc) { + foreach my $field (@ourdscfield) { + $dsc_hash = $dsc->{$field}; + last if defined $dsc_hash; + } + if (defined $dsc_hash) { + $dsc_hash =~ m/\w+/ or fail "invalid hash in .dsc \`$dsc_hash'"; + $dsc_hash = $&; + print "last upload to archive specified git hash\n"; + } else { + print "last upload to archive has NO git hash\n"; + } } else { - print "last upload to archive has NO git hash\n"; + print "no version available from the archive\n"; } my $lrref_fn = ".git/".lrref(); @@ -734,8 +750,28 @@ END fail "archive's .dsc refers to ".$dsc_hash. " but this is an ancestor of ".$lastpush_hash; } - } else { + } elsif ($dsc) { $hash = generate_commit_from_dsc(); + } elsif ($lastpush_hash) { + # only in git, not in the archive yet + $hash = $lastpush_hash; + print STDERR <$clogf", + @git, qw(cat-file blob), "$hash:debian/changelog"; + my $gotclogp = parsechangelog("-l$clogf"); + my $got_vsn = getfield $gotclogp, 'Version'; + print DEBUG "SKEW CHECK GOT $got_vsn\n"; + if (version_compare_string($got_vsn, $skew_warning_vsn) < 0) { + print STDERR <{$ourdscfield[0]} = rev_parse('HEAD'); + my $head = rev_parse('HEAD'); + $dsc->{$ourdscfield[0]} = $head; $dsc->save("../$dscfn.tmp") or die $!; if (!$changesfile) { my $multi = "../${package}_".(stripepoch $cversion)."_multi.changes"; @@ -909,6 +965,7 @@ sub dopush () { " does not match changelog \`$clogp->{$field}'"; } my $tag = debiantag($dversion); + runcmd @git, qw(check-ref-format), $tag; if (!check_for_git()) { create_remote_git_repo(); } @@ -923,11 +980,15 @@ sub dopush () { if (!defined $keyid) { $keyid = access_cfg('keyid','RETURN-UNDEF'); } - my @tag_cmd = (@git, qw(tag -s -m), + my @tag_cmd = (@git, qw(tag -a -m), "$package release $dversion for $csuite [dgit]"); - push @tag_cmd, qw(-u),$keyid if defined $keyid; push @tag_cmd, $tag; runcmd_ordryrun @tag_cmd; + + + push @tag_cmd, qw(-u),$keyid if defined $keyid; + push @tag_cmd, qw(-u),$keyid if defined $keyid; + my @debsign_cmd = @debsign; push @debsign_cmd, "-k$keyid" if defined $keyid; push @debsign_cmd, $changesfile;