2006-11-30 21:19:59 +02:00
|
|
|
#include "shared.hh"
|
|
|
|
#include "local-store.hh"
|
|
|
|
#include "util.hh"
|
2006-11-30 21:54:43 +02:00
|
|
|
#include "serialise.hh"
|
2006-11-30 21:19:59 +02:00
|
|
|
|
|
|
|
using namespace nix;
|
|
|
|
|
|
|
|
|
2006-11-30 21:54:43 +02:00
|
|
|
void processConnection(Source & from, Sink & to)
|
2006-11-30 21:19:59 +02:00
|
|
|
{
|
2006-11-30 21:54:43 +02:00
|
|
|
store = boost::shared_ptr<StoreAPI>(new LocalStore(true));
|
2006-11-30 21:19:59 +02:00
|
|
|
|
2006-11-30 21:54:43 +02:00
|
|
|
unsigned int magic = readInt(from);
|
2006-11-30 21:19:59 +02:00
|
|
|
if (magic != 0x6e697864) throw Error("protocol mismatch");
|
|
|
|
|
2006-11-30 21:54:43 +02:00
|
|
|
writeInt(0x6478696e, to);
|
|
|
|
|
|
|
|
debug("greeting exchanged");
|
2006-11-30 21:19:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void run(Strings args)
|
|
|
|
{
|
|
|
|
bool slave = false;
|
|
|
|
bool daemon = false;
|
|
|
|
|
|
|
|
for (Strings::iterator i = args.begin(); i != args.end(); ) {
|
|
|
|
string arg = *i++;
|
|
|
|
if (arg == "--slave") slave = true;
|
|
|
|
}
|
|
|
|
|
2006-11-30 21:54:43 +02:00
|
|
|
if (slave) {
|
|
|
|
FdSource source(STDIN_FILENO);
|
|
|
|
FdSink sink(STDOUT_FILENO);
|
|
|
|
processConnection(source, sink);
|
|
|
|
}
|
2006-11-30 21:19:59 +02:00
|
|
|
|
|
|
|
else if (daemon)
|
|
|
|
throw Error("daemon mode not implemented");
|
|
|
|
|
|
|
|
else
|
|
|
|
throw Error("must be run in either --slave or --daemon mode");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void printHelp()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string programId = "nix-store";
|