aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd/command.cc
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2021-05-17 08:45:08 +0200
committerregnat <rg@regnat.ovh>2021-05-17 08:45:08 +0200
commit21050846457f356346204dd52fb7a6d49f710688 (patch)
treeb431f5168d57bef20608b6e36e11e11cc9843b34 /src/libcmd/command.cc
parentec613603ba324bf12f8f554d74fb1a02c6e9b472 (diff)
Enfore the use of properly built paths in libcmd
Replace `DerivedPathWithHints` by a new `BuiltPath` type that serves as a proof that the corresponding path has been built.
Diffstat (limited to 'src/libcmd/command.cc')
-rw-r--r--src/libcmd/command.cc39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc
index 25e4873e8..569c4b9e4 100644
--- a/src/libcmd/command.cc
+++ b/src/libcmd/command.cc
@@ -54,7 +54,7 @@ void StoreCommand::run()
run(getStore());
}
-RealisedPathsCommand::RealisedPathsCommand(bool recursive)
+BuiltPathsCommand::BuiltPathsCommand(bool recursive)
: recursive(recursive)
{
if (recursive)
@@ -81,39 +81,45 @@ RealisedPathsCommand::RealisedPathsCommand(bool recursive)
});
}
-void RealisedPathsCommand::run(ref<Store> store)
+void BuiltPathsCommand::run(ref<Store> store)
{
- std::vector<RealisedPath> paths;
+ BuiltPaths paths;
if (all) {
if (installables.size())
throw UsageError("'--all' does not expect arguments");
// XXX: Only uses opaque paths, ignores all the realisations
for (auto & p : store->queryAllValidPaths())
- paths.push_back(p);
+ paths.push_back(BuiltPath::Opaque{p});
} else {
- auto pathSet = toRealisedPaths(store, realiseMode, operateOn, installables);
+ paths = toBuiltPaths(store, realiseMode, operateOn, installables);
if (recursive) {
- auto roots = std::move(pathSet);
- pathSet = {};
- RealisedPath::closure(*store, roots, pathSet);
+ // XXX: This only computes the store path closure, ignoring
+ // intermediate realisations
+ StorePathSet pathsRoots, pathsClosure;
+ for (auto & root: paths) {
+ auto rootFromThis = root.outPaths();
+ pathsRoots.insert(rootFromThis.begin(), rootFromThis.end());
+ }
+ store->computeFSClosure(pathsRoots, pathsClosure);
+ for (auto & path : pathsClosure)
+ paths.push_back(BuiltPath::Opaque{path});
}
- for (auto & path : pathSet)
- paths.push_back(path);
}
run(store, std::move(paths));
}
StorePathsCommand::StorePathsCommand(bool recursive)
- : RealisedPathsCommand(recursive)
+ : BuiltPathsCommand(recursive)
{
}
-void StorePathsCommand::run(ref<Store> store, std::vector<RealisedPath> paths)
+void StorePathsCommand::run(ref<Store> store, BuiltPaths paths)
{
StorePaths storePaths;
- for (auto & p : paths)
- storePaths.push_back(p.path());
+ for (auto& builtPath : paths)
+ for (auto& p : builtPath.outPaths())
+ storePaths.push_back(p);
run(store, std::move(storePaths));
}
@@ -175,10 +181,7 @@ void MixProfile::updateProfile(const BuiltPaths & buildables)
},
[&](BuiltPath::Built bfd) {
for (auto & output : bfd.outputs) {
- /* Output path should be known because we just tried to
- build it. */
- assert(output.second);
- result.push_back(*output.second);
+ result.push_back(output.second);
}
},
}, buildable.raw());