Remove the logfile and logSize columns from the database

It's pointless to store these, since Nix knows where the logs are.
Also handle (in fact require) Nix's new log storage scheme.  Also some
cleanups in the build page.
This commit is contained in:
Eelco Dolstra
2013-01-22 22:48:02 +01:00
parent 36c2bf2f52
commit 30e5185acf
30 changed files with 299 additions and 229 deletions

View File

@ -17,7 +17,7 @@ use File::Temp;
our @ISA = qw(Exporter);
our @EXPORT = qw(
fetchInput evalJobs checkBuild inputsToArgs captureStdoutStderr
getReleaseName getBuildLog addBuildProducts restartBuild scmPath
getReleaseName addBuildProducts restartBuild scmPath
getPrevJobsetEval
);
@ -27,16 +27,6 @@ sub scmPath {
}
sub getBuildLog {
my ($drvPath) = @_;
my $logPath = ($ENV{NIX_LOG_DIR} || "/nix/var/log/nix"). "/drvs/" . basename $drvPath;
return $logPath if -e $logPath;
$logPath = "$logPath.bz2";
return $logPath if -e $logPath;
return undef;
}
sub getStorePathHash {
my ($storePath) = @_;
my $hash = `nix-store --query --hash $storePath`
@ -930,7 +920,6 @@ sub checkBuild {
, buildstatus => -f "$outPath/nix-support/failed" ? 6 : 0
, starttime => $time
, stoptime => $time
, logfile => getBuildLog($drvPath)
, errormsg => ""
, releasename => getReleaseName($outPath)
);

View File

@ -14,7 +14,7 @@ our @EXPORT = qw(
getPrimaryBuildsForView
getPrimaryBuildTotal
getViewResult getLatestSuccessfulViewResult
jobsetOverview removeAsciiEscapes logContents);
jobsetOverview removeAsciiEscapes getDrvLogPath logContents);
sub getHydraHome {
@ -238,19 +238,39 @@ sub getLatestSuccessfulViewResult {
return undef;
}
# Return the path of the build log of the given derivation, or undef
# if the log is gone.
sub getDrvLogPath {
my ($drvPath) = @_;
my $base = basename $drvPath;
my $fn =
($ENV{NIX_LOG_DIR} || "/nix/var/log/nix") . "/drvs/"
. substr($base, 0, 2) . "/"
. substr($base, 2);
return $fn if -f $fn;
$fn .= ".bz2";
return $fn if -f $fn;
return undef;
}
sub logContents {
my ($path, $tail) = @_;
my ($drvPath, $tail) = @_;
my $logPath = getDrvLogPath($drvPath);
die unless defined $logPath;
my $cmd;
if ($path =~ /.bz2$/) {
$cmd = "cat $path | bzip2 -d";
$cmd = $cmd . " | tail -$tail" if defined $tail;
if ($logPath =~ /.bz2$/) {
$cmd = "bzip2 -d < $logPath";
$cmd = $cmd . " | tail -n $tail" if defined $tail;
}
else {
$cmd = defined $tail ? "tail -$tail $path" : "cat $path";
$cmd = defined $tail ? "tail -$tail $logPath" : "cat $logPath";
}
return `$cmd` if -e $path;
return `$cmd`;
}
sub removeAsciiEscapes {
my ($logtext) = @_;
$logtext =~ s/\e\[[0-9]*[A-Za-z]//g;