X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=dgit;h=6c1477cc1a2affccefb882dbda8550577096bae9;hb=fb64dcd0b68b73fa8f59edac53855dd303a7562f;hp=bac0baf0237880ce10948c60a9a6258af278fb5e;hpb=874b84944d26794d2d8031c44bc28c22ed9ca3f3;p=dgit.git diff --git a/dgit b/dgit index bac0baf0..6c1477cc 100755 --- a/dgit +++ b/dgit @@ -144,6 +144,8 @@ sub fetchspec () { # > file begin changes # [etc] # +# > param head HEAD +# # > want signed-tag # [indicates that signed tag is wanted] # < data-block NBYTES @@ -152,11 +154,11 @@ sub fetchspec () { # < data-end # < files-end # -# > want signed-changes-dsc -# < data-block NBYTES [transfer of signed changes] -# [etc] +# > want signed-dsc-changes # < data-block NBYTES [transfer of signed dsc] # [etc] +# < data-block NBYTES [transfer of signed changes] +# [etc] # < files-end # # > complete @@ -225,7 +227,7 @@ sub responder_send_command ($) { sub responder_send_file ($$) { my ($keyword, $ourfn) = @_; return unless $we_are_responder; - responder_send_command "file begin $cmdprefix"; + responder_send_command "file-begin $keyword"; protocol_send_file \*STDOUT, $ourfn; } @@ -1127,6 +1129,16 @@ END return ($tagobjfn); } +sub sign_changes ($) { + my ($changesfile) = @_; + if ($sign) { + my @debsign_cmd = @debsign; + push @debsign_cmd, "-k$keyid" if defined $keyid; + push @debsign_cmd, $changesfile; + runcmd_ordryrun @debsign_cmd; + } +} + sub dopush () { print DEBUG "actually entering push\n"; prep_ud(); @@ -1222,19 +1234,15 @@ sub dopush () { } } - if ($sign) { - if ($we_are_responder) { - my $dryrunsuffix = $dryrun ? ".tmp" : ""; - responder_receive_files('signed-changes-dsc', - "$changesfile$dryrunsuffix", - "../$dscfn$dryrunsuffix"); - } else { - my @debsign_cmd = @debsign; - push @debsign_cmd, "-k$keyid" if defined $keyid; - push @debsign_cmd, $changesfile; - runcmd_ordryrun @debsign_cmd; - } + if ($we_are_responder) { + my $dryrunsuffix = $dryrun ? ".tmp" : ""; + responder_receive_files('signed-dsc-changes', + "../$dscfn$dryrunsuffix", + "$changesfile$dryrupnsuffix"); + } else { + sign_changes $changesfile; } + runcmd_ordryrun @git, qw(push),access_giturl(),"refs/tags/$tag"; my $host = access_cfg('upload-host','RETURN-UNDEF'); my @hostarg = defined($host) ? ($host,) : (); @@ -1370,6 +1378,12 @@ sub i_cleanup { eval { rmtree $i_tmp; }; } +sub i_method { + my ($base,$selector,@args) = @_; + $selector =~ s/\-/_/g; + { no strict qw(refs); &{"${base}_${selector}"}(@args); } +} + sub cmd_rpush { my $host = nextarg; my $dir; @@ -1400,7 +1414,77 @@ sub cmd_rpush { }; i_cleanup(); die $@; +} + +sub i_resp_progress ($) { + my ($rhs) = @_; + my $msg = protocol_read_bytes \*RO, $rhs; + progress $msg; +} + +sub i_resp_complete { + i_cleanup(); + exit 0; +} + +sub i_resp_file ($) { + my ($keyword) = @_; + my $localname = i_method "i_localname_", $keyword; + my $localpath = "$i_tmp/$localname"; + stat $localpath and badproto \*RO, "file $keyword ($localpath) twice"; + protocol_receive_file \*RO, $localpath; +} + +our %i_param; + +sub i_param ($) { + $_[0] =~ m/^(\S+) (.*)$/; + $i_param{$1} = $2; +} + +our %i_wanted; + +sub i_resp_want ($) { + my ($keyword) = @_; + die "$keyword ?" if $i_wanted{$keyword}++; + my @localpaths = i_method "i_want_", $keyword; + foreach my $localpath (@localpaths) { + protocol_send_file \*RI, $localpath; } + print RI "end-files\n" or die $!; +} + +our ($i_clogp, $i_version, $i_tag, $i_dscfn); + +sub i_localname_parsed_changelog { return "remote-changelog.822"; } +sub i_localname_changes { return "remote.changes"; } +sub i_localname_dsc { + ($i_clogp, $i_version, $i_tag, $i_dscfn) = + push_parse_changelog 'remote-changelog.822'; + die if $i_dscfn =~ m#/|^\W#; + return $dscfn; +} + +sub i_want_signed_tag { + defined $i_param{'head'} && defined $dscfn + or badproto \*RO, "sequencing error"; + my $head = $i_param{'head'}; + die if $head =~ m/[^0-9a-f]/ || $head !~ m/^../; + + push_parse_dsc $i_dscfn, 'remote dsc', + + push_mktag $head, $i_clogp, $i_tag, + $dsc, $i_dscfn, + 'remote.changes', 'remote changes', + 'tag.tag'; + + return 'tag.tag'; +} + +sub i_want_signed_dsc_changes { + rename "$i_dscfn.tmp","$i_dscfn" or die "$i_dscfn $!"; + sign_changes 'remote.changes'; + return ($i_dscfn, 'remote.changes'); } #---------- building etc. ----------