chiark
/
gitweb
/
~ianmdlvl
/
dgit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
run i_cleanup unconditionall
[dgit.git]
/
dgit
diff --git
a/dgit
b/dgit
index d31b9b1db9d306338896fa6dfae01a4b719fd672..2972a9ece86a8e52db94e2bf73fe7e8734e2493b 100755
(executable)
--- a/
dgit
+++ b/
dgit
@@
-46,6
+46,7
@@
our $noquilt = 0;
our $existing_package = 'dpkg';
our $cleanmode = 'dpkg-source';
our $we_are_responder;
our $existing_package = 'dpkg';
our $cleanmode = 'dpkg-source';
our $we_are_responder;
+our $initiator_tempdir;
our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
@@
-115,7
+116,7
@@
sub dscfn ($) {
sub changesopts () { return @changesopts[1..$#changesopts]; }
our $us = 'dgit';
sub changesopts () { return @changesopts[1..$#changesopts]; }
our $us = 'dgit';
-our $debugprefix = '
';
+our $debugprefix = '';
sub printdebug { print DEBUG $debugprefix, @_ or die $!; }
sub printdebug { print DEBUG $debugprefix, @_ or die $!; }
@@
-205,17
+206,19
@@
sub protocol_send_file ($$) {
my $d;
my $got = read PF, $d, 65536;
die "$ourfn: $!" unless defined $got;
my $d;
my $got = read PF, $d, 65536;
die "$ourfn: $!" unless defined $got;
- last if $got;
+ last if
!
$got;
print $fh "data-block ".length($d)."\n" or die $!;
print $d or die $!;
}
print $fh "data-block ".length($d)."\n" or die $!;
print $d or die $!;
}
+ PF->eof or die "$ourfn $!";
+ PF->error and die "$ourfn $!";
print $fh "data-end\n" or die $!;
close PF;
}
sub protocol_read_bytes ($$) {
my ($fh, $nbytes) = @_;
print $fh "data-end\n" or die $!;
close PF;
}
sub protocol_read_bytes ($$) {
my ($fh, $nbytes) = @_;
- $nbytes =~ m/^
\d{1,6
}$/ or badproto \*RO, "bad byte count";
+ $nbytes =~ m/^
[1-9]\d{0,5
}$/ or badproto \*RO, "bad byte count";
my $d;
my $got = read $fh, $d, $nbytes;
$got==$nbytes or badproto $fh, "eof during data block";
my $d;
my $got = read $fh, $d, $nbytes;
$got==$nbytes or badproto $fh, "eof during data block";
@@
-227,14
+230,16
@@
sub protocol_receive_file ($$) {
open PF, ">", $ourfn or die "$ourfn: $!";
for (;;) {
my ($y,$l) = protocol_expect {
open PF, ">", $ourfn or die "$ourfn: $!";
for (;;) {
my ($y,$l) = protocol_expect {
- m/^data-block (.*})$|data-end$/;
- length $1 ? (1,$1) : (0);
+ m/^data-block (.*)$/ ? (1,$1) :
+ m/^data-end$/ ? (0,) :
+ ();
} $fh;
last unless $y;
} $fh;
last unless $y;
- my $d = protocol_read_bytes $fh, $
1
;
+ my $d = protocol_read_bytes $fh, $
l
;
print PF $d or die $!;
}
print PF $d or die $!;
}
- printdebug "received into $ourfn\n";
+ close PF or die $!;
+ printdebug "() $ourfn\n";
}
#---------- remote protocol support, responder ----------
}
#---------- remote protocol support, responder ----------
@@
-1108,7
+1113,7
@@
sub push_parse_changelog ($) {
my ($clogpfn) = @_;
my $clogp = Dpkg::Control::Hash->new();
my ($clogpfn) = @_;
my $clogp = Dpkg::Control::Hash->new();
- $clogp->load($clogpfn);
+ $clogp->load($clogpfn)
or die
;
$package = getfield $clogp, 'Source';
my $cversion = getfield $clogp, 'Version';
$package = getfield $clogp, 'Source';
my $cversion = getfield $clogp, 'Version';
@@
-1416,9
+1421,9
@@
sub cmd_remote_push_responder {
@ARGV = @ARGV[$nrargs..$#ARGV];
die unless @rargs;
my ($dir) = @rargs;
@ARGV = @ARGV[$nrargs..$#ARGV];
die unless @rargs;
my ($dir) = @rargs;
+ $debugprefix = ' ';
changedir $dir;
$we_are_responder = 1;
changedir $dir;
$we_are_responder = 1;
- $debugprefix = ' ';
autoflush STDOUT 1;
responder_send_command("dgit-remote-push-ready");
&cmd_push;
autoflush STDOUT 1;
responder_send_command("dgit-remote-push-ready");
&cmd_push;
@@
-1429,10
+1434,13
@@
our $i_tmp;
sub i_cleanup {
local ($@);
return unless defined $i_tmp;
sub i_cleanup {
local ($@);
return unless defined $i_tmp;
+ return if defined $initiator_tempdir;
changedir "/";
eval { rmtree $i_tmp; };
}
changedir "/";
eval { rmtree $i_tmp; };
}
+END { i_cleanup(); }
+
sub i_method {
my ($base,$selector,@args) = @_;
$selector =~ s/\-/_/g;
sub i_method {
my ($base,$selector,@args) = @_;
$selector =~ s/\-/_/g;
@@
-1458,7
+1466,13
@@
sub cmd_rpush {
my @cmd = (@ssh, $host, shellquote @rdgit);
printcmd \*DEBUG,$debugprefix."+",@cmd;
eval {
my @cmd = (@ssh, $host, shellquote @rdgit);
printcmd \*DEBUG,$debugprefix."+",@cmd;
eval {
- $i_tmp = tempdir();
+ if (defined $initiator_tempdir) {
+ rmtree $initiator_tempdir;
+ mkdir $initiator_tempdir, 0700 or die "$initiator_tempdir: $!";
+ $i_tmp = $initiator_tempdir;
+ } else {
+ $i_tmp = tempdir();
+ }
my $pid = open2(\*RO, \*RI, @cmd);
changedir $i_tmp;
initiator_expect { m/^dgit-remote-push-ready/ };
my $pid = open2(\*RO, \*RI, @cmd);
changedir $i_tmp;
initiator_expect { m/^dgit-remote-push-ready/ };
@@
-1519,7
+1533,7
@@
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) =
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'
;
+ push_parse_changelog
"$i_tmp/remote-changelog.822"
;
die if $i_dscfn =~ m#/|^\W#;
return $i_dscfn;
}
die if $i_dscfn =~ m#/|^\W#;
return $i_dscfn;
}
@@
-1767,6
+1781,11
@@
sub parseopts () {
} elsif (m/^--existing-package=(.*)/s) {
push @ropts, $_;
$existing_package = $1;
} elsif (m/^--existing-package=(.*)/s) {
push @ropts, $_;
$existing_package = $1;
+ } elsif (m/^--initiator-tempdir=(.*)/s) {
+ $initiator_tempdir = $1;
+ $initiator_tempdir =~ m#^/# or
+ badusage "--initiator-tempdir must be used specify an".
+ " absolute, not relative, directory."
} elsif (m/^--distro=(.*)/s) {
push @ropts, $_;
$idistro = $1;
} elsif (m/^--distro=(.*)/s) {
push @ropts, $_;
$idistro = $1;