RemoteStore / nix-daemon: Drop support for Nix < 1.0

This commit is contained in:
Eelco Dolstra 2016-07-27 15:03:20 +02:00
parent 6601e46567
commit be64fbb501
2 changed files with 33 additions and 44 deletions

View file

@ -94,6 +94,8 @@ ref<RemoteStore::Connection> RemoteStore::openConnection()
conn->daemonVersion = readInt(conn->from); conn->daemonVersion = readInt(conn->from);
if (GET_PROTOCOL_MAJOR(conn->daemonVersion) != GET_PROTOCOL_MAJOR(PROTOCOL_VERSION)) if (GET_PROTOCOL_MAJOR(conn->daemonVersion) != GET_PROTOCOL_MAJOR(PROTOCOL_VERSION))
throw Error("Nix daemon protocol version not supported"); throw Error("Nix daemon protocol version not supported");
if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 10)
throw Error("the Nix daemon version is too old");
conn->to << PROTOCOL_VERSION; conn->to << PROTOCOL_VERSION;
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 14) { if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 14) {
@ -127,17 +129,13 @@ void RemoteStore::setOptions(ref<Connection> conn)
<< settings.tryFallback << settings.tryFallback
<< verbosity << verbosity
<< settings.maxBuildJobs << settings.maxBuildJobs
<< settings.maxSilentTime; << settings.maxSilentTime
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 2) << settings.useBuildHook
conn->to << settings.useBuildHook; << (settings.verboseBuild ? lvlError : lvlVomit)
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 4)
conn->to << (settings.verboseBuild ? lvlError : lvlVomit)
<< 0 // obsolete log type << 0 // obsolete log type
<< 0 /* obsolete print build trace */; << 0 /* obsolete print build trace */
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 6) << settings.buildCores
conn->to << settings.buildCores; << settings.useSubstitutes;
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 10)
conn->to << settings.useSubstitutes;
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 12) { if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 12) {
Settings::SettingsMap overrides = settings.getOverrides(); Settings::SettingsMap overrides = settings.getOverrides();
@ -213,8 +211,6 @@ void RemoteStore::querySubstitutablePathInfos(const PathSet & paths,
auto conn(connections->get()); auto conn(connections->get());
if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 3) return;
if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 12) { if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 12) {
for (auto & i : paths) { for (auto & i : paths) {
@ -227,7 +223,7 @@ void RemoteStore::querySubstitutablePathInfos(const PathSet & paths,
if (info.deriver != "") assertStorePath(info.deriver); if (info.deriver != "") assertStorePath(info.deriver);
info.references = readStorePaths<PathSet>(*this, conn->from); info.references = readStorePaths<PathSet>(*this, conn->from);
info.downloadSize = readLongLong(conn->from); info.downloadSize = readLongLong(conn->from);
info.narSize = GET_PROTOCOL_MINOR(conn->daemonVersion) >= 7 ? readLongLong(conn->from) : 0; info.narSize = readLongLong(conn->from);
infos[i] = info; infos[i] = info;
} }
@ -481,11 +477,11 @@ void RemoteStore::collectGarbage(const GCOptions & options, GCResults & results)
{ {
auto conn(connections->get()); auto conn(connections->get());
conn->to << wopCollectGarbage << options.action << options.pathsToDelete << options.ignoreLiveness conn->to
<< options.maxFreed << 0; << wopCollectGarbage << options.action << options.pathsToDelete << options.ignoreLiveness
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 5) << options.maxFreed
/* removed options */ /* removed options */
conn->to << 0 << 0; << 0 << 0 << 0;
conn->processStderr(); conn->processStderr();
@ -562,7 +558,7 @@ void RemoteStore::Connection::processStderr(Sink * sink, Source * source)
} }
if (msg == STDERR_ERROR) { if (msg == STDERR_ERROR) {
string error = readString(from); string error = readString(from);
unsigned int status = GET_PROTOCOL_MINOR(daemonVersion) >= 8 ? readInt(from) : 1; unsigned int status = readInt(from);
throw Error(format("%1%") % error, status); throw Error(format("%1%") % error, status);
} }
else if (msg != STDERR_LAST) else if (msg != STDERR_LAST)

View file

@ -413,12 +413,10 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe
options.pathsToDelete = readStorePaths<PathSet>(*store, from); options.pathsToDelete = readStorePaths<PathSet>(*store, from);
options.ignoreLiveness = readInt(from); options.ignoreLiveness = readInt(from);
options.maxFreed = readLongLong(from); options.maxFreed = readLongLong(from);
readInt(from); // obsolete field // obsolete fields
if (GET_PROTOCOL_MINOR(clientVersion) >= 5) { readInt(from);
/* removed options */
readInt(from); readInt(from);
readInt(from); readInt(from);
}
GCResults results; GCResults results;
@ -440,16 +438,11 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe
verbosity = (Verbosity) readInt(from); verbosity = (Verbosity) readInt(from);
settings.set("build-max-jobs", std::to_string(readInt(from))); settings.set("build-max-jobs", std::to_string(readInt(from)));
settings.set("build-max-silent-time", std::to_string(readInt(from))); settings.set("build-max-silent-time", std::to_string(readInt(from)));
if (GET_PROTOCOL_MINOR(clientVersion) >= 2)
settings.useBuildHook = readInt(from) != 0; settings.useBuildHook = readInt(from) != 0;
if (GET_PROTOCOL_MINOR(clientVersion) >= 4) {
settings.verboseBuild = lvlError == (Verbosity) readInt(from); settings.verboseBuild = lvlError == (Verbosity) readInt(from);
readInt(from); // obsolete logType readInt(from); // obsolete logType
readInt(from); // obsolete printBuildTrace readInt(from); // obsolete printBuildTrace
}
if (GET_PROTOCOL_MINOR(clientVersion) >= 6)
settings.set("build-cores", std::to_string(readInt(from))); settings.set("build-cores", std::to_string(readInt(from)));
if (GET_PROTOCOL_MINOR(clientVersion) >= 10)
settings.set("build-use-substitutes", readInt(from) ? "true" : "false"); settings.set("build-use-substitutes", readInt(from) ? "true" : "false");
if (GET_PROTOCOL_MINOR(clientVersion) >= 12) { if (GET_PROTOCOL_MINOR(clientVersion) >= 12) {
unsigned int n = readInt(from); unsigned int n = readInt(from);
@ -478,9 +471,7 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe
if (i == infos.end()) if (i == infos.end())
to << 0; to << 0;
else { else {
to << 1 << i->second.deriver << i->second.references << i->second.downloadSize; to << 1 << i->second.deriver << i->second.references << i->second.downloadSize << i->second.narSize;
if (GET_PROTOCOL_MINOR(clientVersion) >= 7)
to << i->second.narSize;
} }
break; break;
} }
@ -585,10 +576,12 @@ static void processConnection(bool trusted)
to.flush(); to.flush();
unsigned int clientVersion = readInt(from); unsigned int clientVersion = readInt(from);
if (clientVersion < 0x10a)
throw Error("the Nix client version is too old");
if (GET_PROTOCOL_MINOR(clientVersion) >= 14 && readInt(from)) if (GET_PROTOCOL_MINOR(clientVersion) >= 14 && readInt(from))
setAffinityTo(readInt(from)); setAffinityTo(readInt(from));
if (GET_PROTOCOL_MINOR(clientVersion) >= 11)
readInt(from); // obsolete reserveSpace readInt(from); // obsolete reserveSpace
/* Send startup error messages to the client. */ /* Send startup error messages to the client. */
@ -636,10 +629,10 @@ static void processConnection(bool trusted)
during addTextToStore() / importPath(). If that during addTextToStore() / importPath(). If that
happens, just send the error message and exit. */ happens, just send the error message and exit. */
bool errorAllowed = canSendStderr; bool errorAllowed = canSendStderr;
stopWork(false, e.msg(), GET_PROTOCOL_MINOR(clientVersion) >= 8 ? e.status : 0); stopWork(false, e.msg(), e.status);
if (!errorAllowed) throw; if (!errorAllowed) throw;
} catch (std::bad_alloc & e) { } catch (std::bad_alloc & e) {
stopWork(false, "Nix daemon out of memory", GET_PROTOCOL_MINOR(clientVersion) >= 8 ? 1 : 0); stopWork(false, "Nix daemon out of memory", 1);
throw; throw;
} }
@ -653,7 +646,7 @@ static void processConnection(bool trusted)
printMsg(lvlDebug, format("%1% operations") % opCount); printMsg(lvlDebug, format("%1% operations") % opCount);
} catch (Error & e) { } catch (Error & e) {
stopWork(false, e.msg(), GET_PROTOCOL_MINOR(clientVersion) >= 8 ? 1 : 0); stopWork(false, e.msg(), 1);
to.flush(); to.flush();
return; return;
} }