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:
$dirs[0] =~ m#^([^/]+)/\.$# or die;
my $dir = $1;
changedir $dir;
- fail "source package contains .git directory" if stat '.git';
+ fail "source package contains .git directory" if stat_exists '.git';
die $! unless $!==&ENOENT;
runcmd qw(git init -q);
rmtree('.git/objects');
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";
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;
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;
}
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 $!;
}