our $our_version = 'UNRELEASED'; ###substituted###
+our $rpushprotovsn = 2;
+
our $isuite = 'unstable';
our $idistro;
our $package;
chdir $newdir or die "chdir: $newdir: $!";
}
+sub stat_exists ($) {
+ my ($f) = @_;
+ return 1 if stat $f;
+ return 0 if $!==&ENOENT;
+ die "stat $f: $!";
+}
+
#---------- remote protocol support, common ----------
# remote push initiator/responder protocol:
for (;;) {
my %opts = ('name' => $desc);
$opts{allow_pgp}= $allowsigned || !$dpkgcontrolhash_noissigned;
-print STDERR Dumper(\%opts);
$c = Dpkg::Control::Hash->new(%opts);
$c->parse($fh,$desc) or die "parsing of $desc failed";
last if $allowsigned;
$5 eq 'source' or die "$rmad ?";
push @out, [$vsn,pool_dsc_subpath($vsn,$component),$newsuite];
}
- return sort { -version_compare_string($a->[0],$b->[0]); } @out;
+ return sort { -version_compare($a->[0],$b->[0]); } @out;
}
sub canonicalise_suite_madison ($$) {
AND source.source='$package'
AND files.filename LIKE '%.dsc';
END
- @rows = sort { -version_compare_string($a->[0],$b->[0]) } @rows;
+ @rows = sort { -version_compare($a->[0],$b->[0]) } @rows;
my $digester = Digest::SHA->new(256);
@rows = map {
my ($vsn,$component,$filename,$sha256sum) = @$_;
}
C->error and die "$dpath: $!";
close C;
- return sort { -version_compare_string($a->[0],$b->[0]); } @rows;
+ return sort { -version_compare($a->[0],$b->[0]); } @rows;
}
sub canonicalise_suite () {
mkdir $ud or die $!;
}
+sub mktree_in_ud_here () {
+ runcmd qw(git init -q);
+ rmtree('.git/objects');
+ symlink '../../../../objects','.git/objects' or die $!;
+}
+
sub mktree_in_ud_from_only_subdir () {
# changes into the subdir
my (@dirs) = <*/.>;
$dirs[0] =~ m#^([^/]+)/\.$# or die;
my $dir = $1;
changedir $dir;
- fail "source package contains .git directory" if stat '.git';
- die $! unless $!==&ENOENT;
- runcmd qw(git init -q);
- rmtree('.git/objects');
- symlink '../../../../objects','.git/objects' or die $!;
+ fail "source package contains .git directory" if stat_exists '.git';
+ mktree_in_ud_here();
runcmd @git, qw(add -Af);
my $tree = cmdoutput @git, qw(write-tree);
$tree =~ m/^\w+$/ or die "$tree ?";
map { $_->{Filename} } dsc_files_info();
}
-sub is_orig_file ($) {
- local ($_) = @_;
- m/\.orig(?:-\w+)?\.tar\.\w+$/;
+sub is_orig_file ($;$) {
+ local ($_) = $_[0];
+ my $base = $_[1];
+ m/\.orig(?:-\w+)?\.tar\.\w+$/ or return 0;
+ defined $base or return 1;
+ return $` eq $base;
}
sub make_commit ($) {
my $oldclogp = parsecontrol('../changelogold.tmp','previous changelog');
my $oversion = getfield $oldclogp, 'Version';
my $vcmp =
- version_compare_string($oversion, $cversion);
+ version_compare($oversion, $cversion);
if ($vcmp < 0) {
# git upload/ is earlier vsn than archive, use archive
open C, ">../commit2.tmp" or die $!;
my $tf = "$dstdir/$f";
my $downloaded = 0;
- if (stat $tf) {
+ if (stat_exists $tf) {
progress "using existing $f";
} else {
- die "$tf $!" unless $!==&ENOENT;
-
my $furl = $dscurl;
$furl =~ s{/[^/]+$}{};
$furl .= "/$f";
my $gotclogp = parsechangelog("-l$clogf");
my $got_vsn = getfield $gotclogp, 'Version';
printdebug "SKEW CHECK GOT $got_vsn\n";
- if (version_compare_string($got_vsn, $skew_warning_vsn) < 0) {
+ if (version_compare($got_vsn, $skew_warning_vsn) < 0) {
print STDERR <<END or die $!;
Warning: archive skew detected. Using the available version:
}
}
+sub commit_admin ($) {
+ my ($m) = @_;
+ progress "$m";
+ runcmd_ordryrun_local @git, qw(commit -m), $m;
+}
+
sub commit_quilty_patch () {
my $output = cmdoutput @git, qw(status --porcelain);
my %adds;
return;
}
runcmd_ordryrun_local @git, qw(add), sort keys %adds;
- my $m = "Commit Debian 3.0 (quilt) metadata";
- progress "$m";
- runcmd_ordryrun_local @git, qw(commit -m), $m;
+ commit_admin "Commit Debian 3.0 (quilt) metadata";
+}
+
+sub get_source_format () {
+ if (!open F, "debian/source/format") {
+ die $! unless $!==&ENOENT;
+ return '';
+ }
+ $_ = <F>;
+ F->error and die $!;
+ chomp;
+ return $_;
}
sub madformat ($) {
push_parse_changelog("$clogpfn");
my $dscpath = "$buildproductsdir/$dscfn";
- stat $dscpath or
+ stat_exists $dscpath or
fail "looked for .dsc $dscfn, but $!;".
" maybe you forgot to build";
if (!$changesfile) {
my $multi = "$buildproductsdir/".
"${package}_".(stripepoch $cversion)."_multi.changes";
- if (stat "$multi") {
+ if (stat_exists "$multi") {
$changesfile = $multi;
} else {
- $!==&ENOENT or die "$multi: $!";
my $pat = "${package}_".(stripepoch $cversion)."_*.changes";
my @cs = glob "$buildproductsdir/$pat";
fail "failed to find unique changes file".
}
$dstdir ||= "$package";
- if (stat $dstdir) {
+ if (stat_exists $dstdir) {
fail "$dstdir already exists";
- } elsif ($! != &ENOENT) {
- die "$dstdir: $!";
}
my $cwd_remove;
#---------- remote commands' implementation ----------
-sub cmd_remote_push_responder {
+sub cmd_remote_push_build_host {
my ($nrargs) = shift @ARGV;
my (@rargs) = @ARGV[0..$nrargs-1];
@ARGV = @ARGV[$nrargs..$#ARGV];
die unless @rargs;
- my ($dir) = @rargs;
+ my ($dir,$vsnwant) = @rargs;
+ # vsnwant is a comma-separated list; we report which we have
+ # chosen in our ready response (so other end can tell if they
+ # offered several)
$debugprefix = ' ';
$we_are_responder = 1;
open STDOUT, ">&STDERR" or die $!;
autoflush STDOUT 1;
- responder_send_command("dgit-remote-push-ready");
+ $vsnwant //= 1;
+ fail "build host has dgit rpush protocol version".
+ " $rpushprotovsn but invocation host has $vsnwant"
+ unless grep { $rpushprotovsn eq $_ } split /,/, $vsnwant;
+
+ responder_send_command("dgit-remote-push-ready $rpushprotovsn");
changedir $dir;
&cmd_push;
}
+sub cmd_remote_push_responder { cmd_remote_push_build_host(); }
+# ... for compatibility with proto vsn.1 dgit (just so that user gets
+# a good error message)
+
our $i_tmp;
-our $i_child_pid;
sub i_cleanup {
- local ($@);
- if ($i_child_pid) {
- printdebug "(killing remote child $i_child_pid)\n";
+ local ($@, $?);
+ my $report = i_child_report();
+ if (defined $report) {
+ printdebug "($report)\n";
+ } elsif ($i_child_pid) {
+ printdebug "(killing build host child $i_child_pid)\n";
kill 15, $i_child_pid;
}
if (defined $i_tmp && !defined $initiator_tempdir) {
$dir = nextarg;
}
$dir =~ s{^-}{./-};
- my @rargs = ($dir);
+ my @rargs = ($dir,$rpushprotovsn);
my @rdgit;
push @rdgit, @dgit;
push @rdgit, @ropts;
- push @rdgit, qw(remote-push-responder), (scalar @rargs), @rargs;
+ push @rdgit, qw(remote-push-build-host), (scalar @rargs), @rargs;
push @rdgit, @ARGV;
my @cmd = (@ssh, $host, shellquote @rdgit);
printcmd \*DEBUG,$debugprefix."+",@cmd;
my ($keyword) = @_;
my $localname = i_method "i_localname", $keyword;
my $localpath = "$i_tmp/$localname";
- stat $localpath and badproto \*RO, "file $keyword ($localpath) twice";
+ stat_exists $localpath and
+ badproto \*RO, "file $keyword ($localpath) twice";
protocol_receive_file \*RO, $localpath;
i_method "i_file", $keyword;
}
our $fakeeditorenv = 'DGIT_FAKE_EDITOR_QUILT';
sub build_maybe_quilt_fixup () {
- if (!open F, "debian/source/format") {
- die $! unless $!==&ENOENT;
- return;
- }
- $_ = <F>;
- F->error and die $!;
- chomp;
- return unless madformat($_);
+ my $format=get_source_format;
+ return unless madformat $format;
# sigh
my @cmd = (@git, qw(ls-files --exclude-standard -iodm));
}
if (@vsns) {
@vsns = map { $_->[0] } @vsns;
- @vsns = sort { -version_compare_string($a, $b) } @vsns;
+ @vsns = sort { -version_compare($a, $b) } @vsns;
$changes_since_version = $vsns[0];
progress "changelog will contain changes since $vsns[0]";
} else {
changedir "..";
my $pat = "${package}_".(stripepoch $version)."_*.changes";
if (act_local()) {
- stat $dscfn or fail "$dscfn (in parent directory): $!";
- stat $sourcechanges or fail "$sourcechanges (in parent directory): $!";
+ stat_exist $dscfn or fail "$dscfn (in parent directory): $!";
+ stat_exists $sourcechanges
+ or fail "$sourcechanges (in parent directory): $!";
foreach my $cf (glob $pat) {
next if $cf eq $sourcechanges;
unlink $cf or fail "remove $cf: $!";
runcmd_ordryrun_local @mergechanges, @changesfiles;
my $multichanges = "${package}_".(stripepoch $version)."_multi.changes";
if (act_local()) {
- stat $multichanges or fail "$multichanges: $!";
+ stat_exists $multichanges or fail "$multichanges: $!";
}
printdone "build successful, results in $multichanges\n" or die $!;
}