forked from lix-project/lix
Rename drv output querying functions, like master
- `queryDerivationOutputMapAssumeTotal` -> `queryPartialDerivationOutputMap` - `queryDerivationOutputMapAssumeTotal` -> `queryDerivationOutputMap
This commit is contained in:
parent
f899a7c6d7
commit
45a2f1baab
|
@ -64,7 +64,7 @@ void EvalState::realiseContext(const PathSet & context)
|
||||||
paths. */
|
paths. */
|
||||||
if (allowedPaths) {
|
if (allowedPaths) {
|
||||||
for (auto & [drvPath, outputs] : drvs) {
|
for (auto & [drvPath, outputs] : drvs) {
|
||||||
auto outputPaths = store->queryDerivationOutputMapAssumeTotal(drvPath);
|
auto outputPaths = store->queryDerivationOutputMap(drvPath);
|
||||||
for (auto & outputName : outputs) {
|
for (auto & outputName : outputs) {
|
||||||
if (outputPaths.count(outputName) == 0)
|
if (outputPaths.count(outputName) == 0)
|
||||||
throw Error("derivation '%s' does not have an output named '%s'",
|
throw Error("derivation '%s' does not have an output named '%s'",
|
||||||
|
|
|
@ -1041,8 +1041,8 @@ private:
|
||||||
/* Wrappers around the corresponding Store methods that first consult the
|
/* Wrappers around the corresponding Store methods that first consult the
|
||||||
derivation. This is currently needed because when there is no drv file
|
derivation. This is currently needed because when there is no drv file
|
||||||
there also is no DB entry. */
|
there also is no DB entry. */
|
||||||
std::map<std::string, std::optional<StorePath>> queryDerivationOutputMap();
|
std::map<std::string, std::optional<StorePath>> queryPartialDerivationOutputMap();
|
||||||
OutputPathMap queryDerivationOutputMapAssumeTotal();
|
OutputPathMap queryDerivationOutputMap();
|
||||||
|
|
||||||
/* Return the set of (in)valid paths. */
|
/* Return the set of (in)valid paths. */
|
||||||
void checkPathValidity();
|
void checkPathValidity();
|
||||||
|
@ -1367,7 +1367,7 @@ void DerivationGoal::repairClosure()
|
||||||
that produced those outputs. */
|
that produced those outputs. */
|
||||||
|
|
||||||
/* Get the output closure. */
|
/* Get the output closure. */
|
||||||
auto outputs = queryDerivationOutputMapAssumeTotal();
|
auto outputs = queryDerivationOutputMap();
|
||||||
StorePathSet outputClosure;
|
StorePathSet outputClosure;
|
||||||
for (auto & i : outputs) {
|
for (auto & i : outputs) {
|
||||||
if (!wantOutput(i.first, wantedOutputs)) continue;
|
if (!wantOutput(i.first, wantedOutputs)) continue;
|
||||||
|
@ -1386,7 +1386,7 @@ void DerivationGoal::repairClosure()
|
||||||
std::map<StorePath, StorePath> outputsToDrv;
|
std::map<StorePath, StorePath> outputsToDrv;
|
||||||
for (auto & i : inputClosure)
|
for (auto & i : inputClosure)
|
||||||
if (i.isDerivation()) {
|
if (i.isDerivation()) {
|
||||||
auto depOutputs = worker.store.queryDerivationOutputMap(i);
|
auto depOutputs = worker.store.queryPartialDerivationOutputMap(i);
|
||||||
for (auto & j : depOutputs)
|
for (auto & j : depOutputs)
|
||||||
if (j.second)
|
if (j.second)
|
||||||
outputsToDrv.insert_or_assign(*j.second, i);
|
outputsToDrv.insert_or_assign(*j.second, i);
|
||||||
|
@ -1457,7 +1457,7 @@ void DerivationGoal::inputsRealised()
|
||||||
`i' as input paths. Only add the closures of output paths
|
`i' as input paths. Only add the closures of output paths
|
||||||
that are specified as inputs. */
|
that are specified as inputs. */
|
||||||
assert(worker.store.isValidPath(drvPath));
|
assert(worker.store.isValidPath(drvPath));
|
||||||
auto outputs = worker.store.queryDerivationOutputMap(depDrvPath);
|
auto outputs = worker.store.queryPartialDerivationOutputMap(depDrvPath);
|
||||||
for (auto & j : wantedDepOutputs) {
|
for (auto & j : wantedDepOutputs) {
|
||||||
if (outputs.count(j) > 0) {
|
if (outputs.count(j) > 0) {
|
||||||
auto optRealizedInput = outputs.at(j);
|
auto optRealizedInput = outputs.at(j);
|
||||||
|
@ -2912,11 +2912,11 @@ struct RestrictedStore : public LocalFSStore
|
||||||
void queryReferrers(const StorePath & path, StorePathSet & referrers) override
|
void queryReferrers(const StorePath & path, StorePathSet & referrers) override
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
std::map<std::string, std::optional<StorePath>> queryDerivationOutputMap(const StorePath & path) override
|
std::map<std::string, std::optional<StorePath>> queryPartialDerivationOutputMap(const StorePath & path) override
|
||||||
{
|
{
|
||||||
if (!goal.isAllowed(path))
|
if (!goal.isAllowed(path))
|
||||||
throw InvalidPath("cannot query output map for unknown path '%s' in recursive Nix", printStorePath(path));
|
throw InvalidPath("cannot query output map for unknown path '%s' in recursive Nix", printStorePath(path));
|
||||||
return next->queryDerivationOutputMap(path);
|
return next->queryPartialDerivationOutputMap(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override
|
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override
|
||||||
|
@ -2979,7 +2979,7 @@ struct RestrictedStore : public LocalFSStore
|
||||||
|
|
||||||
for (auto & path : paths) {
|
for (auto & path : paths) {
|
||||||
if (!path.path.isDerivation()) continue;
|
if (!path.path.isDerivation()) continue;
|
||||||
auto outputs = next->queryDerivationOutputMapAssumeTotal(path.path);
|
auto outputs = next->queryDerivationOutputMap(path.path);
|
||||||
for (auto & output : outputs)
|
for (auto & output : outputs)
|
||||||
if (wantOutput(output.first, path.outputs))
|
if (wantOutput(output.first, path.outputs))
|
||||||
newPaths.insert(output.second);
|
newPaths.insert(output.second);
|
||||||
|
@ -4548,7 +4548,7 @@ void DerivationGoal::flushLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::map<std::string, std::optional<StorePath>> DerivationGoal::queryDerivationOutputMap()
|
std::map<std::string, std::optional<StorePath>> DerivationGoal::queryPartialDerivationOutputMap()
|
||||||
{
|
{
|
||||||
if (drv->type() != DerivationType::CAFloating) {
|
if (drv->type() != DerivationType::CAFloating) {
|
||||||
std::map<std::string, std::optional<StorePath>> res;
|
std::map<std::string, std::optional<StorePath>> res;
|
||||||
|
@ -4556,11 +4556,11 @@ std::map<std::string, std::optional<StorePath>> DerivationGoal::queryDerivationO
|
||||||
res.insert_or_assign(name, output.pathOpt(worker.store, drv->name, name));
|
res.insert_or_assign(name, output.pathOpt(worker.store, drv->name, name));
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
return worker.store.queryDerivationOutputMap(drvPath);
|
return worker.store.queryPartialDerivationOutputMap(drvPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputPathMap DerivationGoal::queryDerivationOutputMapAssumeTotal()
|
OutputPathMap DerivationGoal::queryDerivationOutputMap()
|
||||||
{
|
{
|
||||||
if (drv->type() != DerivationType::CAFloating) {
|
if (drv->type() != DerivationType::CAFloating) {
|
||||||
OutputPathMap res;
|
OutputPathMap res;
|
||||||
|
@ -4568,7 +4568,7 @@ OutputPathMap DerivationGoal::queryDerivationOutputMapAssumeTotal()
|
||||||
res.insert_or_assign(name, *output.second);
|
res.insert_or_assign(name, *output.second);
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
return worker.store.queryDerivationOutputMapAssumeTotal(drvPath);
|
return worker.store.queryDerivationOutputMap(drvPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4576,7 +4576,7 @@ OutputPathMap DerivationGoal::queryDerivationOutputMapAssumeTotal()
|
||||||
void DerivationGoal::checkPathValidity()
|
void DerivationGoal::checkPathValidity()
|
||||||
{
|
{
|
||||||
bool checkHash = buildMode == bmRepair;
|
bool checkHash = buildMode == bmRepair;
|
||||||
for (auto & i : queryDerivationOutputMap()) {
|
for (auto & i : queryPartialDerivationOutputMap()) {
|
||||||
InitialOutputStatus status {
|
InitialOutputStatus status {
|
||||||
.wanted = wantOutput(i.first, wantedOutputs),
|
.wanted = wantOutput(i.first, wantedOutputs),
|
||||||
};
|
};
|
||||||
|
|
|
@ -325,7 +325,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
case wopQueryDerivationOutputMap: {
|
case wopQueryDerivationOutputMap: {
|
||||||
auto path = store->parseStorePath(readString(from));
|
auto path = store->parseStorePath(readString(from));
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
auto outputs = store->queryDerivationOutputMap(path);
|
auto outputs = store->queryPartialDerivationOutputMap(path);
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
worker_proto::write(*store, to, outputs);
|
worker_proto::write(*store, to, outputs);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -803,7 +803,7 @@ StorePathSet LocalStore::queryValidDerivers(const StorePath & path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::map<std::string, std::optional<StorePath>> LocalStore::queryDerivationOutputMap(const StorePath & path)
|
std::map<std::string, std::optional<StorePath>> LocalStore::queryPartialDerivationOutputMap(const StorePath & path)
|
||||||
{
|
{
|
||||||
std::map<std::string, std::optional<StorePath>> outputs;
|
std::map<std::string, std::optional<StorePath>> outputs;
|
||||||
BasicDerivation drv = readDerivation(path);
|
BasicDerivation drv = readDerivation(path);
|
||||||
|
|
|
@ -133,7 +133,7 @@ public:
|
||||||
|
|
||||||
StorePathSet queryValidDerivers(const StorePath & path) override;
|
StorePathSet queryValidDerivers(const StorePath & path) override;
|
||||||
|
|
||||||
std::map<std::string, std::optional<StorePath>> queryDerivationOutputMap(const StorePath & path) override;
|
std::map<std::string, std::optional<StorePath>> queryPartialDerivationOutputMap(const StorePath & path) override;
|
||||||
|
|
||||||
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override;
|
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override;
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ void Store::queryMissing(const std::vector<StorePathWithOutputs> & targets,
|
||||||
/* true for regular derivations, and CA derivations for which we
|
/* true for regular derivations, and CA derivations for which we
|
||||||
have a trust mapping for all wanted outputs. */
|
have a trust mapping for all wanted outputs. */
|
||||||
auto knownOutputPaths = true;
|
auto knownOutputPaths = true;
|
||||||
for (auto & [outputName, pathOpt] : queryDerivationOutputMap(path.path)) {
|
for (auto & [outputName, pathOpt] : queryPartialDerivationOutputMap(path.path)) {
|
||||||
if (!pathOpt) {
|
if (!pathOpt) {
|
||||||
knownOutputPaths = false;
|
knownOutputPaths = false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -474,7 +474,7 @@ StorePathSet RemoteStore::queryDerivationOutputs(const StorePath & path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::map<std::string, std::optional<StorePath>> RemoteStore::queryDerivationOutputMap(const StorePath & path)
|
std::map<std::string, std::optional<StorePath>> RemoteStore::queryPartialDerivationOutputMap(const StorePath & path)
|
||||||
{
|
{
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
conn->to << wopQueryDerivationOutputMap << printStorePath(path);
|
conn->to << wopQueryDerivationOutputMap << printStorePath(path);
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
|
|
||||||
StorePathSet queryDerivationOutputs(const StorePath & path) override;
|
StorePathSet queryDerivationOutputs(const StorePath & path) override;
|
||||||
|
|
||||||
std::map<std::string, std::optional<StorePath>> queryDerivationOutputMap(const StorePath & path) override;
|
std::map<std::string, std::optional<StorePath>> queryPartialDerivationOutputMap(const StorePath & path) override;
|
||||||
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override;
|
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override;
|
||||||
|
|
||||||
StorePathSet querySubstitutablePaths(const StorePathSet & paths) override;
|
StorePathSet querySubstitutablePaths(const StorePathSet & paths) override;
|
||||||
|
|
|
@ -366,8 +366,8 @@ bool Store::PathInfoCacheValue::isKnownNow()
|
||||||
return std::chrono::steady_clock::now() < time_point + ttl;
|
return std::chrono::steady_clock::now() < time_point + ttl;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputPathMap Store::queryDerivationOutputMapAssumeTotal(const StorePath & path) {
|
OutputPathMap Store::queryDerivationOutputMap(const StorePath & path) {
|
||||||
auto resp = queryDerivationOutputMap(path);
|
auto resp = queryPartialDerivationOutputMap(path);
|
||||||
OutputPathMap result;
|
OutputPathMap result;
|
||||||
for (auto & [outName, optOutPath] : resp) {
|
for (auto & [outName, optOutPath] : resp) {
|
||||||
if (!optOutPath)
|
if (!optOutPath)
|
||||||
|
@ -379,7 +379,7 @@ OutputPathMap Store::queryDerivationOutputMapAssumeTotal(const StorePath & path)
|
||||||
|
|
||||||
StorePathSet Store::queryDerivationOutputs(const StorePath & path)
|
StorePathSet Store::queryDerivationOutputs(const StorePath & path)
|
||||||
{
|
{
|
||||||
auto outputMap = this->queryDerivationOutputMapAssumeTotal(path);
|
auto outputMap = this->queryDerivationOutputMap(path);
|
||||||
StorePathSet outputPaths;
|
StorePathSet outputPaths;
|
||||||
for (auto & i: outputMap) {
|
for (auto & i: outputMap) {
|
||||||
outputPaths.emplace(std::move(i.second));
|
outputPaths.emplace(std::move(i.second));
|
||||||
|
|
|
@ -348,12 +348,12 @@ public:
|
||||||
/* Query the mapping outputName => outputPath for the given derivation. All
|
/* Query the mapping outputName => outputPath for the given derivation. All
|
||||||
outputs are mentioned so ones mising the mapping are mapped to
|
outputs are mentioned so ones mising the mapping are mapped to
|
||||||
`std::nullopt`. */
|
`std::nullopt`. */
|
||||||
virtual std::map<std::string, std::optional<StorePath>> queryDerivationOutputMap(const StorePath & path)
|
virtual std::map<std::string, std::optional<StorePath>> queryPartialDerivationOutputMap(const StorePath & path)
|
||||||
{ unsupported("queryDerivationOutputMap"); }
|
{ unsupported("queryPartialDerivationOutputMap"); }
|
||||||
|
|
||||||
/* Query the mapping outputName=>outputPath for the given derivation.
|
/* Query the mapping outputName=>outputPath for the given derivation.
|
||||||
Assume every output has a mapping and throw an exception otherwise. */
|
Assume every output has a mapping and throw an exception otherwise. */
|
||||||
OutputPathMap queryDerivationOutputMapAssumeTotal(const StorePath & path);
|
OutputPathMap queryDerivationOutputMap(const StorePath & path);
|
||||||
|
|
||||||
/* Query the full store path given the hash part of a valid store
|
/* Query the full store path given the hash part of a valid store
|
||||||
path, or empty if the path doesn't exist. */
|
path, or empty if the path doesn't exist. */
|
||||||
|
|
|
@ -518,7 +518,7 @@ static void _main(int argc, char * * argv)
|
||||||
if (counter)
|
if (counter)
|
||||||
drvPrefix += fmt("-%d", counter + 1);
|
drvPrefix += fmt("-%d", counter + 1);
|
||||||
|
|
||||||
auto builtOutputs = store->queryDerivationOutputMapAssumeTotal(drvPath);
|
auto builtOutputs = store->queryDerivationOutputMap(drvPath);
|
||||||
|
|
||||||
for (auto & outputName : wantedOutputs) {
|
for (auto & outputName : wantedOutputs) {
|
||||||
auto outputPath = builtOutputs.at(outputName);
|
auto outputPath = builtOutputs.at(outputName);
|
||||||
|
|
|
@ -381,7 +381,7 @@ static void queryInstSources(EvalState & state,
|
||||||
|
|
||||||
if (path.isDerivation()) {
|
if (path.isDerivation()) {
|
||||||
elem.setDrvPath(state.store->printStorePath(path));
|
elem.setDrvPath(state.store->printStorePath(path));
|
||||||
auto outputs = state.store->queryDerivationOutputMapAssumeTotal(path);
|
auto outputs = state.store->queryDerivationOutputMap(path);
|
||||||
elem.setOutPath(state.store->printStorePath(outputs.at("out")));
|
elem.setOutPath(state.store->printStorePath(outputs.at("out")));
|
||||||
if (name.size() >= drvExtension.size() &&
|
if (name.size() >= drvExtension.size() &&
|
||||||
string(name, name.size() - drvExtension.size()) == drvExtension)
|
string(name, name.size() - drvExtension.size()) == drvExtension)
|
||||||
|
|
|
@ -65,7 +65,7 @@ static PathSet realisePath(StorePathWithOutputs path, bool build = true)
|
||||||
|
|
||||||
if (path.path.isDerivation()) {
|
if (path.path.isDerivation()) {
|
||||||
if (build) store->buildPaths({path});
|
if (build) store->buildPaths({path});
|
||||||
auto outputPaths = store->queryDerivationOutputMapAssumeTotal(path.path);
|
auto outputPaths = store->queryDerivationOutputMap(path.path);
|
||||||
Derivation drv = store->derivationFromPath(path.path);
|
Derivation drv = store->derivationFromPath(path.path);
|
||||||
rootNr++;
|
rootNr++;
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixProfile
|
||||||
store2->addPermRoot(bo.path, absPath(symlink), true);
|
store2->addPermRoot(bo.path, absPath(symlink), true);
|
||||||
},
|
},
|
||||||
[&](BuildableFromDrv bfd) {
|
[&](BuildableFromDrv bfd) {
|
||||||
auto builtOutputs = store->queryDerivationOutputMapAssumeTotal(bfd.drvPath);
|
auto builtOutputs = store->queryDerivationOutputMap(bfd.drvPath);
|
||||||
for (auto & output : builtOutputs) {
|
for (auto & output : builtOutputs) {
|
||||||
std::string symlink = outLink;
|
std::string symlink = outLink;
|
||||||
if (i) symlink += fmt("-%d", i);
|
if (i) symlink += fmt("-%d", i);
|
||||||
|
|
|
@ -488,7 +488,7 @@ bool NixRepl::processLine(string line)
|
||||||
but doing it in a child makes it easier to recover from
|
but doing it in a child makes it easier to recover from
|
||||||
problems / SIGINT. */
|
problems / SIGINT. */
|
||||||
if (runProgram(settings.nixBinDir + "/nix", Strings{"build", "--no-link", drvPath}) == 0) {
|
if (runProgram(settings.nixBinDir + "/nix", Strings{"build", "--no-link", drvPath}) == 0) {
|
||||||
auto outputs = state->store->queryDerivationOutputMapAssumeTotal(state->store->parseStorePath(drvPath));
|
auto outputs = state->store->queryDerivationOutputMap(state->store->parseStorePath(drvPath));
|
||||||
std::cout << std::endl << "this derivation produced the following outputs:" << std::endl;
|
std::cout << std::endl << "this derivation produced the following outputs:" << std::endl;
|
||||||
for (auto & i : outputs)
|
for (auto & i : outputs)
|
||||||
std::cout << fmt(" %s -> %s\n", i.first, state->store->printStorePath(i.second));
|
std::cout << fmt(" %s -> %s\n", i.first, state->store->printStorePath(i.second));
|
||||||
|
|
Loading…
Reference in a new issue