summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2022-12-11 18:15:59 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2022-12-11 19:59:00 +0000
commitc55e536c63dd0d42c6391a40cc0506d864637963 (patch)
tree01ff4850eaa9c5b58d803133cbf0de884f0b7bf1 /dgit
parentefa2ddb065afb2c7b4edaf8b345e67e10916e1b9 (diff)
dgit: implement rpush-source
Closes: #974012 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit47
1 files changed, 34 insertions, 13 deletions
diff --git a/dgit b/dgit
index 66efa2c..7e773d4 100755
--- a/dgit
+++ b/dgit
@@ -60,6 +60,7 @@ $SIG{INT} = 'DEFAULT'; # work around #932841
our @rpushprotovsn_support = qw(6 5 4); # Reverse order!
our $protovsn;
+our $rpush_verb; # "push" or "push-source"
our $cmd;
our $subcommand;
@@ -461,8 +462,12 @@ sub branch_is_gdr ($) {
#---------- remote protocol support, common ----------
# remote push initiator/responder protocol:
-# $ dgit remote-push-build-host <n-rargs> <rargs>... <push-args>...
+# $ dgit remote-push-source-build-host <n-rargs> <rargs>... <push-args>...
# where <rargs> is <push-host-dir> <supported-proto-vsn>,... ...
+# < dgit-remote-push-source-ready <actual-proto-vsn>
+#
+# Or for push-built,
+# $ dgit remote-push-build-host <n-rargs> <rargs>... <push-args>...
# < dgit-remote-push-ready <actual-proto-vsn>
#
# occasionally:
@@ -496,6 +501,7 @@ sub branch_is_gdr ($) {
#
# > param buildinfo-filename P_V_X.buildinfo # zero or more times
# > file buildinfo # for buildinfos to sign
+# # not for push-source
#
# > previously REFNAME=OBJNAME # if --deliberately-not-fast-forward
# # goes into tag, for replay prevention
@@ -5126,7 +5132,10 @@ END
#---------- remote commands' implementation ----------
-sub pre_remote_push_build_host {
+sub pre_remote_push_build_host { core_pre_rpush_bh('push'); }
+sub pre_remote_push_source_build_host { core_pre_rpush_bh('push-source'); }
+sub core_pre_rpush_bh ($) {
+ ($rpush_verb) = @_;
my ($nrargs) = shift @ARGV;
my (@rargs) = @ARGV[0..$nrargs-1];
@ARGV = @ARGV[$nrargs..$#ARGV];
@@ -5158,12 +5167,12 @@ sub pre_remote_push_build_host {
changedir $dir;
- responder_send_command("dgit-remote-push-ready $protovsn");
-}
-sub cmd_remote_push_build_host {
- &cmd_push_built;
+ responder_send_command("dgit-remote-$rpush_verb-ready $protovsn");
}
+sub cmd_remote_push_build_host { &cmd_push_built; }
+sub cmd_remote_push_source_build_host { &cmd_push_source; }
+
sub pre_remote_push_responder { pre_remote_push_build_host(); }
sub cmd_remote_push_responder { cmd_remote_push_build_host(); }
# ... for compatibility with proto vsn.1 dgit (just so that user gets
@@ -5200,10 +5209,14 @@ sub i_method {
{ no strict qw(refs); &{"${base}_${selector}"}(@args); }
}
-sub pre_rpush () {
- not_necessarily_a_tree();
-}
-sub cmd_rpush {
+sub pre_rpush () { not_necessarily_a_tree(); }
+sub pre_rpush_source () { not_necessarily_a_tree(); }
+
+sub cmd_rpush { rpush_core('push'); }
+sub cmd_rpush_source { rpush_core('push-source'); }
+sub rpush_core ($) {
+ ($rpush_verb) = @_;
+
my $host = nextarg;
my $dir;
if ($host =~ m/^((?:[^][]|\[[^][]*\])*)\:/) {
@@ -5218,7 +5231,7 @@ sub cmd_rpush {
my @rdgit;
push @rdgit, @dgit;
push @rdgit, @ropts;
- push @rdgit, qw(remote-push-build-host), (scalar @rargs), @rargs;
+ push @rdgit, "remote-$rpush_verb-build-host", (scalar @rargs), @rargs;
push @rdgit, @ARGV;
my @cmd = (@ssh, $host, shellquote @rdgit);
debugcmd "+",@cmd;
@@ -5235,7 +5248,7 @@ sub cmd_rpush {
}
$i_child_pid = open2(\*RO, \*RI, @cmd);
changedir $i_tmp;
- ($protovsn) = initiator_expect { m/^dgit-remote-push-ready (\S+)/ };
+ ($protovsn) = initiator_expect { m/^dgit-remote-$rpush_verb-ready (\S+)/ };
die "$protovsn ?" unless grep { $_ eq $protovsn } @rpushprotovsn_support;
for (;;) {
@@ -5352,6 +5365,9 @@ sub i_localname_buildinfo ($) {
return $&;
}
sub i_file_buildinfo {
+ $rpush_verb eq 'push'
+ or badproto \*RO, "buildinfo file but verb is $rpush_verb";
+
my $bi = $i_param{'buildinfo-filename'};
my $bd = parsecontrol "$i_tmp/$bi", $bi;
my $ch = parsecontrol "$i_tmp/$i_changesfn", 'changes';
@@ -5374,7 +5390,12 @@ sub i_localname_changes {
$i_changesfn =~ s/\.dsc$/_dgit.changes/ or die;
return $i_changesfn;
}
-sub i_file_changes { }
+sub i_file_changes {
+ my $ch = parsecontrol "$i_tmp/$i_changesfn", 'changes';
+ unless ($rpush_verb eq 'push' || test_source_only_changes($ch)) {
+ fail __ "build-host-supplied changes file is not source-only";
+ }
+}
sub i_want_signed_tag {
printdebug Dumper(\%i_param, $i_dscfn);