mirror of
https://github.com/NixOS/nix
synced 2025-07-09 07:53:55 +02:00
printMissing(): Take a MissingPaths argument
This commit is contained in:
parent
af05ce0f6d
commit
5d308ccca5
4 changed files with 24 additions and 22 deletions
|
@ -35,15 +35,17 @@ void printVersion(const std::string & programName);
|
|||
void printGCWarning();
|
||||
|
||||
class Store;
|
||||
struct MissingPaths;
|
||||
|
||||
void printMissing(
|
||||
ref<Store> store,
|
||||
const std::vector<DerivedPath> & paths,
|
||||
Verbosity lvl = lvlInfo);
|
||||
|
||||
void printMissing(ref<Store> store, const StorePathSet & willBuild,
|
||||
const StorePathSet & willSubstitute, const StorePathSet & unknown,
|
||||
uint64_t downloadSize, uint64_t narSize, Verbosity lvl = lvlInfo);
|
||||
void printMissing(
|
||||
ref<Store> store,
|
||||
const MissingPaths & missing,
|
||||
Verbosity lvl = lvlInfo);
|
||||
|
||||
std::string getArg(const std::string & opt,
|
||||
Strings::iterator & i, const Strings::iterator & end);
|
||||
|
|
|
@ -46,41 +46,41 @@ void printGCWarning()
|
|||
|
||||
void printMissing(ref<Store> store, const std::vector<DerivedPath> & paths, Verbosity lvl)
|
||||
{
|
||||
auto missing = store->queryMissing(paths);
|
||||
printMissing(store, missing.willBuild, missing.willSubstitute, missing.unknown, missing.downloadSize, missing.narSize, lvl);
|
||||
printMissing(store, store->queryMissing(paths), lvl);
|
||||
}
|
||||
|
||||
|
||||
void printMissing(ref<Store> store, const StorePathSet & willBuild,
|
||||
const StorePathSet & willSubstitute, const StorePathSet & unknown,
|
||||
uint64_t downloadSize, uint64_t narSize, Verbosity lvl)
|
||||
void printMissing(
|
||||
ref<Store> store,
|
||||
const MissingPaths & missing,
|
||||
Verbosity lvl)
|
||||
{
|
||||
if (!willBuild.empty()) {
|
||||
if (willBuild.size() == 1)
|
||||
if (!missing.willBuild.empty()) {
|
||||
if (missing.willBuild.size() == 1)
|
||||
printMsg(lvl, "this derivation will be built:");
|
||||
else
|
||||
printMsg(lvl, "these %d derivations will be built:", willBuild.size());
|
||||
auto sorted = store->topoSortPaths(willBuild);
|
||||
printMsg(lvl, "these %d derivations will be built:", missing.willBuild.size());
|
||||
auto sorted = store->topoSortPaths(missing.willBuild);
|
||||
reverse(sorted.begin(), sorted.end());
|
||||
for (auto & i : sorted)
|
||||
printMsg(lvl, " %s", store->printStorePath(i));
|
||||
}
|
||||
|
||||
if (!willSubstitute.empty()) {
|
||||
const float downloadSizeMiB = downloadSize / (1024.f * 1024.f);
|
||||
const float narSizeMiB = narSize / (1024.f * 1024.f);
|
||||
if (willSubstitute.size() == 1) {
|
||||
if (!missing.willSubstitute.empty()) {
|
||||
const float downloadSizeMiB = missing.downloadSize / (1024.f * 1024.f);
|
||||
const float narSizeMiB = missing.narSize / (1024.f * 1024.f);
|
||||
if (missing.willSubstitute.size() == 1) {
|
||||
printMsg(lvl, "this path will be fetched (%.2f MiB download, %.2f MiB unpacked):",
|
||||
downloadSizeMiB,
|
||||
narSizeMiB);
|
||||
} else {
|
||||
printMsg(lvl, "these %d paths will be fetched (%.2f MiB download, %.2f MiB unpacked):",
|
||||
willSubstitute.size(),
|
||||
missing.willSubstitute.size(),
|
||||
downloadSizeMiB,
|
||||
narSizeMiB);
|
||||
}
|
||||
std::vector<const StorePath *> willSubstituteSorted = {};
|
||||
std::for_each(willSubstitute.begin(), willSubstitute.end(),
|
||||
std::for_each(missing.willSubstitute.begin(), missing.willSubstitute.end(),
|
||||
[&](const StorePath &p) { willSubstituteSorted.push_back(&p); });
|
||||
std::sort(willSubstituteSorted.begin(), willSubstituteSorted.end(),
|
||||
[](const StorePath *lhs, const StorePath *rhs) {
|
||||
|
@ -93,10 +93,10 @@ void printMissing(ref<Store> store, const StorePathSet & willBuild,
|
|||
printMsg(lvl, " %s", store->printStorePath(*p));
|
||||
}
|
||||
|
||||
if (!unknown.empty()) {
|
||||
if (!missing.unknown.empty()) {
|
||||
printMsg(lvl, "don't know how to build these paths%s:",
|
||||
(settings.readOnlyMode ? " (may be caused by read-only store access)" : ""));
|
||||
for (auto & i : unknown)
|
||||
for (auto & i : missing.unknown)
|
||||
printMsg(lvl, " %s", store->printStorePath(i));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -425,7 +425,7 @@ static void main_nix_build(int argc, char * * argv)
|
|||
auto missing = store->queryMissing(paths);
|
||||
|
||||
if (settings.printMissing)
|
||||
printMissing(ref<Store>(store), missing.willBuild, missing.willSubstitute, missing.unknown, missing.downloadSize, missing.narSize);
|
||||
printMissing(ref<Store>(store), missing);
|
||||
|
||||
if (!dryRun)
|
||||
store->buildPaths(paths, buildMode, evalStore);
|
||||
|
|
|
@ -158,7 +158,7 @@ static void opRealise(Strings opFlags, Strings opArgs)
|
|||
}
|
||||
|
||||
if (settings.printMissing)
|
||||
printMissing(ref<Store>(store), missing.willBuild, missing.willSubstitute, missing.unknown, missing.downloadSize, missing.narSize);
|
||||
printMissing(ref<Store>(store), missing);
|
||||
|
||||
if (dryRun) return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue