forked from lix-project/lix
* Support queryDeriver() in multi-user installations.
This commit is contained in:
parent
9d9e1c5c41
commit
6d1a1191b0
|
@ -1065,7 +1065,7 @@ static string makeValidityRegistration(const PathSet & paths,
|
||||||
for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i) {
|
for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i) {
|
||||||
s += *i + "\n";
|
s += *i + "\n";
|
||||||
|
|
||||||
Path deriver = showDerivers ? queryDeriver(noTxn, *i) : "";
|
Path deriver = showDerivers ? store->queryDeriver(*i) : "";
|
||||||
s += deriver + "\n";
|
s += deriver + "\n";
|
||||||
|
|
||||||
PathSet references;
|
PathSet references;
|
||||||
|
|
|
@ -482,7 +482,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||||
/* Note that the deriver need not be valid (e.g., if we
|
/* Note that the deriver need not be valid (e.g., if we
|
||||||
previously ran the collector with `gcKeepDerivations'
|
previously ran the collector with `gcKeepDerivations'
|
||||||
turned off). */
|
turned off). */
|
||||||
Path deriver = queryDeriver(noTxn, *i);
|
Path deriver = store->queryDeriver(*i);
|
||||||
if (deriver != "" && store->isValidPath(deriver))
|
if (deriver != "" && store->isValidPath(deriver))
|
||||||
computeFSClosure(deriver, livePaths);
|
computeFSClosure(deriver, livePaths);
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,7 +399,7 @@ void setDeriver(const Transaction & txn, const Path & storePath,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path queryDeriver(const Transaction & txn, const Path & storePath)
|
static Path queryDeriver(const Transaction & txn, const Path & storePath)
|
||||||
{
|
{
|
||||||
if (!isRealisablePath(txn, storePath))
|
if (!isRealisablePath(txn, storePath))
|
||||||
throw Error(format("path `%1%' is not valid") % storePath);
|
throw Error(format("path `%1%' is not valid") % storePath);
|
||||||
|
@ -411,6 +411,12 @@ Path queryDeriver(const Transaction & txn, const Path & storePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Path LocalStore::queryDeriver(const Path & path)
|
||||||
|
{
|
||||||
|
return nix::queryDeriver(noTxn, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const int substituteVersion = 2;
|
const int substituteVersion = 2;
|
||||||
|
|
||||||
|
|
||||||
|
@ -756,7 +762,7 @@ void LocalStore::exportPath(const Path & path, bool sign,
|
||||||
nix::queryReferences(txn, path, references);
|
nix::queryReferences(txn, path, references);
|
||||||
writeStringSet(references, hashAndWriteSink);
|
writeStringSet(references, hashAndWriteSink);
|
||||||
|
|
||||||
Path deriver = queryDeriver(txn, path);
|
Path deriver = nix::queryDeriver(txn, path);
|
||||||
writeString(deriver, hashAndWriteSink);
|
writeString(deriver, hashAndWriteSink);
|
||||||
|
|
||||||
if (sign) {
|
if (sign) {
|
||||||
|
|
|
@ -49,6 +49,8 @@ public:
|
||||||
|
|
||||||
void queryReferrers(const Path & path, PathSet & referrers);
|
void queryReferrers(const Path & path, PathSet & referrers);
|
||||||
|
|
||||||
|
Path queryDeriver(const Path & path);
|
||||||
|
|
||||||
Path addToStore(const Path & srcPath, bool fixed = false,
|
Path addToStore(const Path & srcPath, bool fixed = false,
|
||||||
bool recursive = false, string hashAlgo = "",
|
bool recursive = false, string hashAlgo = "",
|
||||||
PathFilter & filter = defaultPathFilter);
|
PathFilter & filter = defaultPathFilter);
|
||||||
|
@ -136,10 +138,6 @@ void setReferences(const Transaction & txn, const Path & path,
|
||||||
void setDeriver(const Transaction & txn, const Path & path,
|
void setDeriver(const Transaction & txn, const Path & path,
|
||||||
const Path & deriver);
|
const Path & deriver);
|
||||||
|
|
||||||
/* Query the deriver of a store path. Return the empty string if no
|
|
||||||
deriver has been set. */
|
|
||||||
Path queryDeriver(const Transaction & txn, const Path & path);
|
|
||||||
|
|
||||||
/* Delete a value from the nixStore directory. */
|
/* Delete a value from the nixStore directory. */
|
||||||
void deleteFromStore(const Path & path, unsigned long long & bytesFreed);
|
void deleteFromStore(const Path & path, unsigned long long & bytesFreed);
|
||||||
|
|
||||||
|
|
|
@ -212,6 +212,15 @@ void RemoteStore::queryReferrers(const Path & path,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Path RemoteStore::queryDeriver(const Path & path)
|
||||||
|
{
|
||||||
|
writeInt(wopQueryDeriver, to);
|
||||||
|
writeString(path, to);
|
||||||
|
processStderr();
|
||||||
|
return readStorePath(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Path RemoteStore::addToStore(const Path & _srcPath, bool fixed,
|
Path RemoteStore::addToStore(const Path & _srcPath, bool fixed,
|
||||||
bool recursive, string hashAlgo, PathFilter & filter)
|
bool recursive, string hashAlgo, PathFilter & filter)
|
||||||
{
|
{
|
||||||
|
@ -224,8 +233,7 @@ Path RemoteStore::addToStore(const Path & _srcPath, bool fixed,
|
||||||
writeString(hashAlgo, to);
|
writeString(hashAlgo, to);
|
||||||
dumpPath(srcPath, to, filter);
|
dumpPath(srcPath, to, filter);
|
||||||
processStderr();
|
processStderr();
|
||||||
Path path = readStorePath(from);
|
return readStorePath(from);
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,8 +246,7 @@ Path RemoteStore::addTextToStore(const string & suffix, const string & s,
|
||||||
writeStringSet(references, to);
|
writeStringSet(references, to);
|
||||||
|
|
||||||
processStderr();
|
processStderr();
|
||||||
Path path = readStorePath(from);
|
return readStorePath(from);
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,8 +268,7 @@ Path RemoteStore::importPath(bool requireSignature, Source & source)
|
||||||
anyway. */
|
anyway. */
|
||||||
|
|
||||||
processStderr(0, &source);
|
processStderr(0, &source);
|
||||||
Path path = readStorePath(from);
|
return readStorePath(from);
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ public:
|
||||||
|
|
||||||
void queryReferrers(const Path & path, PathSet & referrers);
|
void queryReferrers(const Path & path, PathSet & referrers);
|
||||||
|
|
||||||
|
Path queryDeriver(const Path & path);
|
||||||
|
|
||||||
Path addToStore(const Path & srcPath, bool fixed = false,
|
Path addToStore(const Path & srcPath, bool fixed = false,
|
||||||
bool recursive = false, string hashAlgo = "",
|
bool recursive = false, string hashAlgo = "",
|
||||||
PathFilter & filter = defaultPathFilter);
|
PathFilter & filter = defaultPathFilter);
|
||||||
|
|
|
@ -77,6 +77,10 @@ public:
|
||||||
virtual void queryReferrers(const Path & path,
|
virtual void queryReferrers(const Path & path,
|
||||||
PathSet & referrers) = 0;
|
PathSet & referrers) = 0;
|
||||||
|
|
||||||
|
/* Query the deriver of a store path. Return the empty string if
|
||||||
|
no deriver has been set. */
|
||||||
|
virtual Path queryDeriver(const Path & path) = 0;
|
||||||
|
|
||||||
/* Copy the contents of a path to the store and register the
|
/* Copy the contents of a path to the store and register the
|
||||||
validity the resulting path. The resulting path is returned.
|
validity the resulting path. The resulting path is returned.
|
||||||
If `fixed' is true, then the output of a fixed-output
|
If `fixed' is true, then the output of a fixed-output
|
||||||
|
|
|
@ -28,6 +28,7 @@ typedef enum {
|
||||||
wopCollectGarbage,
|
wopCollectGarbage,
|
||||||
wopExportPath,
|
wopExportPath,
|
||||||
wopImportPath,
|
wopImportPath,
|
||||||
|
wopQueryDeriver,
|
||||||
} WorkerOp;
|
} WorkerOp;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ static Path fixPath(Path path)
|
||||||
static Path useDeriver(Path path)
|
static Path useDeriver(Path path)
|
||||||
{
|
{
|
||||||
if (!isDerivation(path)) {
|
if (!isDerivation(path)) {
|
||||||
path = queryDeriver(noTxn, path);
|
path = store->queryDeriver(path);
|
||||||
if (path == "")
|
if (path == "")
|
||||||
throw Error(format("deriver of path `%1%' is not known") % path);
|
throw Error(format("deriver of path `%1%' is not known") % path);
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
||||||
for (Strings::iterator i = opArgs.begin();
|
for (Strings::iterator i = opArgs.begin();
|
||||||
i != opArgs.end(); ++i)
|
i != opArgs.end(); ++i)
|
||||||
{
|
{
|
||||||
Path deriver = queryDeriver(noTxn, fixPath(*i));
|
Path deriver = store->queryDeriver(fixPath(*i));
|
||||||
cout << format("%1%\n") %
|
cout << format("%1%\n") %
|
||||||
(deriver == "" ? "unknown-deriver" : deriver);
|
(deriver == "" ? "unknown-deriver" : deriver);
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,6 +277,15 @@ static void performOp(Source & from, Sink & to, unsigned int op)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case wopQueryDeriver: {
|
||||||
|
Path path = readStorePath(from);
|
||||||
|
startWork();
|
||||||
|
Path deriver = store->queryDeriver(path);
|
||||||
|
stopWork();
|
||||||
|
writeString(deriver, to);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case wopAddToStore: {
|
case wopAddToStore: {
|
||||||
/* !!! uberquick hack */
|
/* !!! uberquick hack */
|
||||||
string baseName = readString(from);
|
string baseName = readString(from);
|
||||||
|
|
Loading…
Reference in a new issue