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