aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/daemon.cc26
-rw-r--r--src/libstore/local-store.cc21
-rw-r--r--src/libstore/local-store.hh2
-rw-r--r--src/libstore/remote-store.cc12
-rw-r--r--src/libstore/remote-store.hh2
-rw-r--r--src/libstore/store-api.hh3
-rw-r--r--src/libstore/worker-protocol.hh1
7 files changed, 63 insertions, 4 deletions
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc
index 5b817c587..101aa13a5 100644
--- a/src/libstore/daemon.cc
+++ b/src/libstore/daemon.cc
@@ -468,10 +468,12 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
dontCheckSigs = false;
logger->startWork();
- FramedSource source(from);
- store->addMultipleToStore(source,
- RepairFlag{repair},
- dontCheckSigs ? NoCheckSigs : CheckSigs);
+ {
+ FramedSource source(from);
+ store->addMultipleToStore(source,
+ RepairFlag{repair},
+ dontCheckSigs ? NoCheckSigs : CheckSigs);
+ }
logger->stopWork();
break;
}
@@ -920,6 +922,22 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
break;
}
+ case wopAddBuildLog: {
+ StorePath path{readString(from)};
+ logger->startWork();
+ if (!trusted)
+ throw Error("you are not privileged to add logs");
+ {
+ FramedSource source(from);
+ StringSink sink;
+ source.drainInto(sink);
+ store->addBuildLog(path, sink.s);
+ }
+ logger->stopWork();
+ to << 1;
+ break;
+ }
+
default:
throw Error("invalid operation %1%", op);
}
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index d3cebe720..1807940d8 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -9,6 +9,7 @@
#include "callback.hh"
#include "topo-sort.hh"
#include "finally.hh"
+#include "compression.hh"
#include <iostream>
#include <algorithm>
@@ -1898,4 +1899,24 @@ FixedOutputHash LocalStore::hashCAPath(
};
}
+void LocalStore::addBuildLog(const StorePath & drvPath, std::string_view log)
+{
+ assert(drvPath.isDerivation());
+
+ auto baseName = drvPath.to_string();
+
+ auto logPath = fmt("%s/%s/%s/%s.bz2", logDir, drvsLogDir, baseName.substr(0, 2), baseName.substr(2));
+
+ if (pathExists(logPath)) return;
+
+ createDirs(dirOf(logPath));
+
+ auto tmpFile = fmt("%s.tmp.%d", logPath, getpid());
+
+ writeFile(tmpFile, compress("bzip2", log));
+
+ if (rename(tmpFile.c_str(), logPath.c_str()) != 0)
+ throw SysError("renaming '%1%' to '%2%'", tmpFile, logPath);
+}
+
} // namespace nix
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index c4d7b80bd..6d867d778 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -280,6 +280,8 @@ private:
const std::string_view pathHash
);
+ void addBuildLog(const StorePath & drvPath, std::string_view log) override;
+
friend struct LocalDerivationGoal;
friend struct PathSubstitutionGoal;
friend struct SubstitutionGoal;
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 6886103e1..aac2965e0 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -908,6 +908,18 @@ void RemoteStore::queryMissing(const std::vector<DerivedPath> & targets,
}
+void RemoteStore::addBuildLog(const StorePath & drvPath, std::string_view log)
+{
+ auto conn(getConnection());
+ conn->to << wopAddBuildLog << drvPath.to_string();
+ StringSource source(log);
+ conn.withFramedSink([&](Sink & sink) {
+ source.drainInto(sink);
+ });
+ readInt(conn->from);
+}
+
+
void RemoteStore::connect()
{
auto conn(getConnection());
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh
index 0fd67f371..4754ff45a 100644
--- a/src/libstore/remote-store.hh
+++ b/src/libstore/remote-store.hh
@@ -116,6 +116,8 @@ public:
StorePathSet & willBuild, StorePathSet & willSubstitute, StorePathSet & unknown,
uint64_t & downloadSize, uint64_t & narSize) override;
+ void addBuildLog(const StorePath & drvPath, std::string_view log) override;
+
void connect() override;
unsigned int getProtocol() override;
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 3567dcd1c..07f45d1e9 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -727,6 +727,9 @@ public:
virtual std::optional<std::string> getBuildLog(const StorePath & path)
{ return std::nullopt; }
+ virtual void addBuildLog(const StorePath & path, std::string_view log)
+ { unsupported("addBuildLog"); }
+
/* Hack to allow long-running processes like hydra-queue-runner to
occasionally flush their path info cache. */
void clearPathInfoCache()
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh
index 93cf546d2..ecf42a5d0 100644
--- a/src/libstore/worker-protocol.hh
+++ b/src/libstore/worker-protocol.hh
@@ -56,6 +56,7 @@ typedef enum {
wopRegisterDrvOutput = 42,
wopQueryRealisation = 43,
wopAddMultipleToStore = 44,
+ wopAddBuildLog = 45,
} WorkerOp;