chiark / gitweb /
fix local dsc name parse
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 60020fc2fe8d09ede9d17bc7d08c8900706b8037..3c89b37eff671dbb6e318d8e16f9f34aa732d41f 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -116,7 +116,7 @@ sub dscfn ($) {
 sub changesopts () { return @changesopts[1..$#changesopts]; }
 
 our $us = 'dgit';
-our $debugprefix = ' ';
+our $debugprefix = '';
 
 sub printdebug { print DEBUG $debugprefix, @_ or die $!; }
 
@@ -206,17 +206,19 @@ sub protocol_send_file ($$) {
        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 $!;
     }
+    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) = @_;
-    $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";
@@ -228,14 +230,16 @@ sub protocol_receive_file ($$) {
     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;
-       my $d = protocol_read_bytes $fh, $1;
+       my $d = protocol_read_bytes $fh, $l;
        print PF $d or die $!;
     }
-    printdebug "received into $ourfn\n";
+    close PF or die $!;
+    printdebug "() $ourfn\n";
 }
 
 #---------- remote protocol support, responder ----------
@@ -1109,7 +1113,7 @@ sub push_parse_changelog ($) {
     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';
@@ -1417,9 +1421,9 @@ sub cmd_remote_push_responder {
     @ARGV = @ARGV[$nrargs..$#ARGV];
     die unless @rargs;
     my ($dir) = @rargs;
+    $debugprefix = ' ';
     changedir $dir;
     $we_are_responder = 1;
-    $debugprefix = ' ';
     autoflush STDOUT 1;
     responder_send_command("dgit-remote-push-ready");
     &cmd_push;
@@ -1527,7 +1531,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) =
-       push_parse_changelog 'remote-changelog.822';
+       push_parse_changelog "$i_tmp/remote-changelog.822";
     die if $i_dscfn =~ m#/|^\W#;
     return $i_dscfn;
 }