nix-env: Determine which paths have substitutes in parallel

This commit is contained in:
Eelco Dolstra 2012-07-11 10:14:06 -04:00
parent 5ee8944155
commit 6586414bc7
2 changed files with 24 additions and 2 deletions

View file

@ -33,6 +33,8 @@ private:
bool metaInfoRead; bool metaInfoRead;
MetaInfo meta; MetaInfo meta;
bool failed; // set if we get an AssertionError
public: public:
string name; string name;
string attrPath; /* path towards the derivation */ string attrPath; /* path towards the derivation */
@ -41,7 +43,7 @@ public:
/* !!! make this private */ /* !!! make this private */
Bindings * attrs; Bindings * attrs;
DrvInfo() : metaInfoRead(false), attrs(0) { }; DrvInfo() : metaInfoRead(false), failed(false), attrs(0) { };
string queryDrvPath(EvalState & state) const; string queryDrvPath(EvalState & state) const;
string queryOutPath(EvalState & state) const; string queryOutPath(EvalState & state) const;
@ -59,6 +61,9 @@ public:
} }
void setMetaInfo(const MetaInfo & meta); void setMetaInfo(const MetaInfo & meta);
void setFailed() { failed = true; };
bool hasFailed() { return failed; };
}; };

View file

@ -930,6 +930,21 @@ static void opQuery(Globals & globals,
} }
/* Query which paths have substitutes. */
SubstitutablePathInfos subs;
if (printStatus) {
PathSet paths;
foreach (vector<DrvInfo>::iterator, i, elems2)
try {
paths.insert(i->queryOutPath(globals.state));
} catch (AssertionError & e) {
printMsg(lvlTalkative, format("skipping derivation named `%1%' which gives an assertion failure") % i->name);
i->setFailed();
}
store->querySubstitutablePathInfos(paths, subs);
}
/* Print the desired columns, or XML output. */ /* Print the desired columns, or XML output. */
Table table; Table table;
std::ostringstream dummy; std::ostringstream dummy;
@ -938,6 +953,8 @@ static void opQuery(Globals & globals,
foreach (vector<DrvInfo>::iterator, i, elems2) { foreach (vector<DrvInfo>::iterator, i, elems2) {
try { try {
if (i->hasFailed()) continue;
startNest(nest, lvlDebug, format("outputting query result `%1%'") % i->attrPath); startNest(nest, lvlDebug, format("outputting query result `%1%'") % i->attrPath);
if (globals.prebuiltOnly && !isPrebuilt(globals.state, *i)) continue; if (globals.prebuiltOnly && !isPrebuilt(globals.state, *i)) continue;
@ -949,7 +966,7 @@ static void opQuery(Globals & globals,
XMLAttrs attrs; XMLAttrs attrs;
if (printStatus) { if (printStatus) {
bool hasSubs = store->hasSubstitutes(i->queryOutPath(globals.state)); bool hasSubs = subs.find(i->queryOutPath(globals.state)) != subs.end();
bool isInstalled = installed.find(i->queryOutPath(globals.state)) != installed.end(); bool isInstalled = installed.find(i->queryOutPath(globals.state)) != installed.end();
bool isValid = store->isValidPath(i->queryOutPath(globals.state)); bool isValid = store->isValidPath(i->queryOutPath(globals.state));
if (xmlOutput) { if (xmlOutput) {