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