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:
parent
96443e94a1
commit
0afeb7f51e
9 changed files with 50 additions and 83 deletions
|
|
@ -3048,9 +3048,6 @@ void DerivationGoal::registerOutputs()
|
|||
}
|
||||
|
||||
|
||||
string drvsLogDir = "drvs";
|
||||
|
||||
|
||||
Path DerivationGoal::openLogFile()
|
||||
{
|
||||
logSize = 0;
|
||||
|
|
@ -3060,7 +3057,7 @@ Path DerivationGoal::openLogFile()
|
|||
string baseName = baseNameOf(drvPath);
|
||||
|
||||
/* Create a log file. */
|
||||
Path dir = (format("%1%/%2%/%3%/") % worker.store.logDir % drvsLogDir % string(baseName, 0, 2)).str();
|
||||
Path dir = (format("%1%/%2%/%3%/") % worker.store.logDir % worker.store.drvsLogDir % string(baseName, 0, 2)).str();
|
||||
createDirs(dir);
|
||||
|
||||
Path logFileName = (format("%1%/%2%%3%")
|
||||
|
|
|
|||
|
|
@ -179,7 +179,6 @@ void Settings::update()
|
|||
_get(envKeepDerivations, "env-keep-derivations");
|
||||
_get(sshSubstituterHosts, "ssh-substituter-hosts");
|
||||
_get(useSshSubstituter, "use-ssh-substituter");
|
||||
_get(logServers, "log-servers");
|
||||
_get(enableImportNative, "allow-unsafe-native-code-during-evaluation");
|
||||
_get(useCaseHack, "use-case-hack");
|
||||
_get(preBuildHook, "pre-build-hook");
|
||||
|
|
|
|||
|
|
@ -181,9 +181,6 @@ struct Settings {
|
|||
/* Whether to show a stack trace if Nix evaluation fails. */
|
||||
bool showTrace;
|
||||
|
||||
/* A list of URL prefixes that can return Nix build logs. */
|
||||
Strings logServers;
|
||||
|
||||
/* Whether the importNative primop should be enabled */
|
||||
bool enableImportNative;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ namespace nix {
|
|||
const int nixSchemaVersion = 10;
|
||||
|
||||
|
||||
extern string drvsLogDir;
|
||||
|
||||
|
||||
struct Derivation;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -566,6 +566,11 @@ public:
|
|||
if they lack a signature. */
|
||||
virtual bool isTrusted() { return false; }
|
||||
|
||||
/* Return the build log of the specified store path, if available,
|
||||
or null otherwise. */
|
||||
virtual std::shared_ptr<std::string> getBuildLog(const Path & path)
|
||||
{ return nullptr; }
|
||||
|
||||
protected:
|
||||
|
||||
Stats stats;
|
||||
|
|
@ -579,6 +584,7 @@ public:
|
|||
const Path rootDir;
|
||||
const Path stateDir;
|
||||
const Path logDir;
|
||||
const static string drvsLogDir;
|
||||
|
||||
LocalFSStore(const Params & params);
|
||||
|
||||
|
|
@ -595,6 +601,8 @@ public:
|
|||
{
|
||||
return getRealStoreDir() + "/" + baseNameOf(storePath);
|
||||
}
|
||||
|
||||
std::shared_ptr<std::string> getBuildLog(const Path & path) override;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue