forked from lix-project/lix
Add Store::readDerivation() convenience function
This commit is contained in:
parent
045b07200c
commit
9f736dd89d
|
@ -241,7 +241,7 @@ connected:
|
|||
|
||||
uploadLock = -1;
|
||||
|
||||
BasicDerivation drv(readDerivation(*store, store->realStoreDir + "/" + std::string(drvPath->to_string())));
|
||||
auto drv = store->readDerivation(*drvPath);
|
||||
drv.inputSrcs = store->parseStorePathSet(inputs);
|
||||
|
||||
auto result = sshStore->buildDerivation(*drvPath, drv);
|
||||
|
|
|
@ -688,7 +688,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
|
|||
for (auto & j : refs) {
|
||||
drv.inputSrcs.insert(j.clone());
|
||||
if (j.isDerivation())
|
||||
drv.inputDrvs[j.clone()] = readDerivation(*state.store, state.store->toRealPath(j)).outputNames();
|
||||
drv.inputDrvs[j.clone()] = state.store->readDerivation(j).outputNames();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -329,7 +329,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
|||
case wopQueryDerivationOutputNames: {
|
||||
auto path = store->parseStorePath(readString(from));
|
||||
logger->startWork();
|
||||
auto names = readDerivation(*store, store->toRealPath(path)).outputNames();
|
||||
auto names = store->readDerivation(path).outputNames();
|
||||
logger->stopWork();
|
||||
to << names;
|
||||
break;
|
||||
|
|
|
@ -204,6 +204,12 @@ Derivation readDerivation(const Store & store, const Path & drvPath)
|
|||
Derivation Store::derivationFromPath(const StorePath & drvPath)
|
||||
{
|
||||
ensurePath(drvPath);
|
||||
return readDerivation(drvPath);
|
||||
}
|
||||
|
||||
|
||||
Derivation Store::readDerivation(const StorePath & drvPath)
|
||||
{
|
||||
auto accessor = getFSAccessor();
|
||||
try {
|
||||
return parseDerivation(*this, accessor->readFile(printStorePath(drvPath)));
|
||||
|
@ -378,7 +384,7 @@ Hash hashDerivationModulo(Store & store, const Derivation & drv, bool maskOutput
|
|||
if (h == drvHashes.end()) {
|
||||
assert(store.isValidPath(i.first));
|
||||
h = drvHashes.insert_or_assign(i.first.clone(), hashDerivationModulo(store,
|
||||
readDerivation(store, store.toRealPath(i.first)), false)).first;
|
||||
store.readDerivation(i.first), false)).first;
|
||||
}
|
||||
inputs2.insert_or_assign(h->second.to_string(Base16, false), i.second);
|
||||
}
|
||||
|
|
|
@ -595,7 +595,7 @@ uint64_t LocalStore::addValidPath(State & state,
|
|||
efficiently query whether a path is an output of some
|
||||
derivation. */
|
||||
if (info.path.isDerivation()) {
|
||||
auto drv = readDerivation(*this, realStoreDir + "/" + std::string(info.path.to_string()));
|
||||
auto drv = readDerivation(info.path);
|
||||
|
||||
/* Verify that the output paths in the derivation are correct
|
||||
(i.e., follow the scheme for computing output paths from
|
||||
|
@ -911,8 +911,7 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
|
|||
for (auto & i : infos)
|
||||
if (i.path.isDerivation()) {
|
||||
// FIXME: inefficient; we already loaded the derivation in addValidPath().
|
||||
checkDerivationOutputs(i.path,
|
||||
readDerivation(*this, realStoreDir + "/" + std::string(i.path.to_string())));
|
||||
checkDerivationOutputs(i.path, readDerivation(i.path));
|
||||
}
|
||||
|
||||
/* Do a topological sort of the paths. This will throw an
|
||||
|
|
|
@ -583,6 +583,9 @@ public:
|
|||
ensurePath(). */
|
||||
Derivation derivationFromPath(const StorePath & drvPath);
|
||||
|
||||
/* Read a derivation (which must already be valid). */
|
||||
Derivation readDerivation(const StorePath & drvPath);
|
||||
|
||||
/* Place in `out' the set of all store paths in the file system
|
||||
closure of `storePath'; that is, all paths than can be directly
|
||||
or indirectly reached from it. `out' is not cleared. If
|
||||
|
|
|
@ -61,11 +61,9 @@ struct CmdShowDerivation : InstallablesCommand
|
|||
for (auto & drvPath : drvPaths) {
|
||||
if (!drvPath.isDerivation()) continue;
|
||||
|
||||
auto drvPathS = store->printStorePath(drvPath);
|
||||
auto drvObj(jsonRoot.object(store->printStorePath(drvPath)));
|
||||
|
||||
auto drvObj(jsonRoot.object(drvPathS));
|
||||
|
||||
auto drv = readDerivation(*store, drvPathS);
|
||||
auto drv = store->readDerivation(drvPath);
|
||||
|
||||
{
|
||||
auto outputsObj(drvObj.object("outputs"));
|
||||
|
|
Loading…
Reference in a new issue