Ensure STATUS_FILE always a valid filehandle.

There was a bug with printing to STATUS_FILE that wasn't guarded by
checking to see if $outfile was defined, which was causing errors when
printing that a module failed to update/build in --pretend mode.

I could have fixed it by adding that check but it's probably better to
have it always valid.

We can't set $outfile to '/dev/null' unconditionally since we decide
whether to create log/latest symlinks based on whether $outfile is set
or not. So instead I use a defined-or (//) operator in the open call.
wilder
Michael Pyne 14 years ago
parent 2a8959033e
commit 610cce2385
  1. 19
      kdesrc-build

@ -7945,19 +7945,16 @@ sub handle_build
# build.
$ipc->waitForStreamStart();
my $outfile = undef;
my $outfile = pretending() ? undef
: $ctx->getLogDir() . '/build-status';
if (not pretending())
{
$outfile = $ctx->getLogDir() . '/build-status';
open STATUS_FILE, ">$outfile" or do {
error (<<EOF);
open (STATUS_FILE, '>', $outfile // '/dev/null') or do {
error (<<EOF);
Unable to open output status file r[b[$outfile]
You won't be able to use the g[--resume] switch next run.\n";
EOF
$outfile = undef;
};
}
$outfile = undef;
};
my $num_modules = scalar @modules;
my $i = 1;
@ -8028,7 +8025,7 @@ EOF
if ($module->build())
{
my $elapsed = prettify_seconds(time - $start_time);
print STATUS_FILE "$module: Succeeded after $elapsed.\n" if $outfile;
print STATUS_FILE "$module: Succeeded after $elapsed.\n";
$module->setPersistentOption('last-build-rev', $module->currentScmRevision());
$module->setPersistentOption('failure-count', 0);
@ -8038,7 +8035,7 @@ EOF
else
{
my $elapsed = prettify_seconds(time - $start_time);
print STATUS_FILE "$module: Failed after $elapsed.\n" if $outfile;
print STATUS_FILE "$module: Failed after $elapsed.\n";
info ("\tOverall time for r[$module] was g[$elapsed].");
$ctx->markModulePhaseFailed('build', $module);

Loading…
Cancel
Save