1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-02 17:41:48 +02:00

Store: Add a method for getting build logs

This allows various Store implementations to provide different ways to
get build logs. For example, BinaryCacheStore can get the build logs
from the binary cache.

Also, remove the log-servers option since we can use substituters for
this.
This commit is contained in:
Eelco Dolstra 2017-03-13 12:07:50 +01:00
parent 96443e94a1
commit 0afeb7f51e
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
9 changed files with 50 additions and 83 deletions

View file

@ -2,6 +2,8 @@
#include "fs-accessor.hh"
#include "store-api.hh"
#include "globals.hh"
#include "compression.hh"
#include "derivations.hh"
namespace nix {
@ -84,4 +86,37 @@ void LocalFSStore::narFromPath(const Path & path, Sink & sink)
dumpPath(getRealStoreDir() + std::string(path, storeDir.size()), sink);
}
const string LocalFSStore::drvsLogDir = "drvs";
std::shared_ptr<std::string> LocalFSStore::getBuildLog(const Path & path_)
{
auto path(path_);
assertStorePath(path);
if (!isDerivation(path)) {
path = queryPathInfo(path)->deriver;
if (path == "") return nullptr;
}
string baseName = baseNameOf(path);
for (int j = 0; j < 2; j++) {
Path logPath =
j == 0
? (format("%1%/%2%/%3%/%4%") % logDir % drvsLogDir % string(baseName, 0, 2) % string(baseName, 2)).str()
: (format("%1%/%2%/%3%") % logDir % drvsLogDir % baseName).str();
Path logBz2Path = logPath + ".bz2";
if (pathExists(logPath))
return std::make_shared<std::string>(readFile(logPath));
else if (pathExists(logBz2Path))
return decompress("bzip2", readFile(logBz2Path));
}
return nullptr;
}
}