Implement buildDerivation() via the daemon

This commit is contained in:
Eelco Dolstra 2015-09-03 12:56:59 +02:00
parent 6e06a18d1b
commit 71a5161365
5 changed files with 34 additions and 2 deletions

View file

@ -5,6 +5,7 @@
#include "archive.hh" #include "archive.hh"
#include "affinity.hh" #include "affinity.hh"
#include "globals.hh" #include "globals.hh"
#include "derivations.hh"
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -458,7 +459,14 @@ void RemoteStore::buildPaths(const PathSet & drvPaths, BuildMode buildMode)
BuildResult RemoteStore::buildDerivation(const Path & drvPath, const BasicDerivation & drv, BuildResult RemoteStore::buildDerivation(const Path & drvPath, const BasicDerivation & drv,
BuildMode buildMode) BuildMode buildMode)
{ {
throw Error("not implemented"); openConnection();
to << wopBuildDerivation << drvPath << drv << buildMode;
processStderr();
BuildResult res;
unsigned int status;
from >> status >> res.errorMsg;
res.status = (BuildResult::Status) status;
return res;
} }

View file

@ -43,7 +43,8 @@ typedef enum {
wopQuerySubstitutablePaths = 32, wopQuerySubstitutablePaths = 32,
wopQueryValidDerivers = 33, wopQueryValidDerivers = 33,
wopOptimiseStore = 34, wopOptimiseStore = 34,
wopVerifyStore = 35 wopVerifyStore = 35,
wopBuildDerivation = 36,
} WorkerOp; } WorkerOp;

View file

@ -248,6 +248,13 @@ Source & operator >> (Source & in, string & s)
} }
Source & operator >> (Source & in, unsigned int & n)
{
n = readInt(in);
return in;
}
template<class T> T readStrings(Source & source) template<class T> T readStrings(Source & source)
{ {
unsigned int count = readInt(source); unsigned int count = readInt(source);

View file

@ -143,6 +143,7 @@ string readString(Source & source);
template<class T> T readStrings(Source & source); template<class T> T readStrings(Source & source);
Source & operator >> (Source & in, string & s); Source & operator >> (Source & in, string & s);
Source & operator >> (Source & in, unsigned int & n);
MakeError(SerialisationError, Error) MakeError(SerialisationError, Error)

View file

@ -7,6 +7,7 @@
#include "affinity.hh" #include "affinity.hh"
#include "globals.hh" #include "globals.hh"
#include "monitor-fd.hh" #include "monitor-fd.hh"
#include "derivations.hh"
#include <algorithm> #include <algorithm>
@ -325,6 +326,20 @@ static void performOp(bool trusted, unsigned int clientVersion,
break; break;
} }
case wopBuildDerivation: {
Path drvPath = readStorePath(from);
BasicDerivation drv;
from >> drv;
BuildMode buildMode = (BuildMode) readInt(from);
startWork();
if (!trusted)
throw Error("you are not privileged to build derivations");
auto res = store->buildDerivation(drvPath, drv, buildMode);
stopWork();
to << res.status << res.errorMsg;
break;
}
case wopEnsurePath: { case wopEnsurePath: {
Path path = readStorePath(from); Path path = readStorePath(from);
startWork(); startWork();