forked from lix-project/lix
getDerivation(): Don't always quietly ignore assertion failure
Ignoring assertion failures makes some sense for nix-env -qa, but not for nix-instantiate/nix-build or hydra-eval-jobs.
This commit is contained in:
parent
ad328bea15
commit
70f75be199
|
@ -84,7 +84,8 @@ typedef set<Bindings *> Done;
|
||||||
makes sense for the caller to recursively search for derivations in
|
makes sense for the caller to recursively search for derivations in
|
||||||
`v'. */
|
`v'. */
|
||||||
static bool getDerivation(EvalState & state, Value & v,
|
static bool getDerivation(EvalState & state, Value & v,
|
||||||
const string & attrPath, DrvInfos & drvs, Done & done)
|
const string & attrPath, DrvInfos & drvs, Done & done,
|
||||||
|
bool ignoreAssertionFailures)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
state.forceValue(v);
|
state.forceValue(v);
|
||||||
|
@ -116,16 +117,18 @@ static bool getDerivation(EvalState & state, Value & v,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} catch (AssertionError & e) {
|
} catch (AssertionError & e) {
|
||||||
return false;
|
if (ignoreAssertionFailures) return false;
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool getDerivation(EvalState & state, Value & v, DrvInfo & drv)
|
bool getDerivation(EvalState & state, Value & v, DrvInfo & drv,
|
||||||
|
bool ignoreAssertionFailures)
|
||||||
{
|
{
|
||||||
Done done;
|
Done done;
|
||||||
DrvInfos drvs;
|
DrvInfos drvs;
|
||||||
getDerivation(state, v, "", drvs, done);
|
getDerivation(state, v, "", drvs, done, ignoreAssertionFailures);
|
||||||
if (drvs.size() != 1) return false;
|
if (drvs.size() != 1) return false;
|
||||||
drv = drvs.front();
|
drv = drvs.front();
|
||||||
return true;
|
return true;
|
||||||
|
@ -140,7 +143,8 @@ static string addToPath(const string & s1, const string & s2)
|
||||||
|
|
||||||
static void getDerivations(EvalState & state, Value & vIn,
|
static void getDerivations(EvalState & state, Value & vIn,
|
||||||
const string & pathPrefix, Bindings & autoArgs,
|
const string & pathPrefix, Bindings & autoArgs,
|
||||||
DrvInfos & drvs, Done & done)
|
DrvInfos & drvs, Done & done,
|
||||||
|
bool ignoreAssertionFailures)
|
||||||
{
|
{
|
||||||
Value v;
|
Value v;
|
||||||
state.autoCallFunction(autoArgs, vIn, v);
|
state.autoCallFunction(autoArgs, vIn, v);
|
||||||
|
@ -148,7 +152,7 @@ static void getDerivations(EvalState & state, Value & vIn,
|
||||||
/* Process the expression. */
|
/* Process the expression. */
|
||||||
DrvInfo drv;
|
DrvInfo drv;
|
||||||
|
|
||||||
if (!getDerivation(state, v, pathPrefix, drvs, done)) ;
|
if (!getDerivation(state, v, pathPrefix, drvs, done, ignoreAssertionFailures)) ;
|
||||||
|
|
||||||
else if (v.type == tAttrs) {
|
else if (v.type == tAttrs) {
|
||||||
|
|
||||||
|
@ -171,8 +175,8 @@ static void getDerivations(EvalState & state, Value & vIn,
|
||||||
string pathPrefix2 = addToPath(pathPrefix, i->first);
|
string pathPrefix2 = addToPath(pathPrefix, i->first);
|
||||||
Value & v2(*v.attrs->find(i->second)->value);
|
Value & v2(*v.attrs->find(i->second)->value);
|
||||||
if (combineChannels)
|
if (combineChannels)
|
||||||
getDerivations(state, v2, pathPrefix2, autoArgs, drvs, done);
|
getDerivations(state, v2, pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures);
|
||||||
else if (getDerivation(state, v2, pathPrefix2, drvs, done)) {
|
else if (getDerivation(state, v2, pathPrefix2, drvs, done, ignoreAssertionFailures)) {
|
||||||
/* If the value of this attribute is itself an
|
/* If the value of this attribute is itself an
|
||||||
attribute set, should we recurse into it? => Only
|
attribute set, should we recurse into it? => Only
|
||||||
if it has a `recurseForDerivations = true'
|
if it has a `recurseForDerivations = true'
|
||||||
|
@ -180,7 +184,7 @@ static void getDerivations(EvalState & state, Value & vIn,
|
||||||
if (v2.type == tAttrs) {
|
if (v2.type == tAttrs) {
|
||||||
Bindings::iterator j = v2.attrs->find(state.symbols.create("recurseForDerivations"));
|
Bindings::iterator j = v2.attrs->find(state.symbols.create("recurseForDerivations"));
|
||||||
if (j != v2.attrs->end() && state.forceBool(*j->value))
|
if (j != v2.attrs->end() && state.forceBool(*j->value))
|
||||||
getDerivations(state, v2, pathPrefix2, autoArgs, drvs, done);
|
getDerivations(state, v2, pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,8 +195,8 @@ static void getDerivations(EvalState & state, Value & vIn,
|
||||||
startNest(nest, lvlDebug,
|
startNest(nest, lvlDebug,
|
||||||
format("evaluating list element"));
|
format("evaluating list element"));
|
||||||
string pathPrefix2 = addToPath(pathPrefix, (format("%1%") % n).str());
|
string pathPrefix2 = addToPath(pathPrefix, (format("%1%") % n).str());
|
||||||
if (getDerivation(state, *v.list.elems[n], pathPrefix2, drvs, done))
|
if (getDerivation(state, *v.list.elems[n], pathPrefix2, drvs, done, ignoreAssertionFailures))
|
||||||
getDerivations(state, *v.list.elems[n], pathPrefix2, autoArgs, drvs, done);
|
getDerivations(state, *v.list.elems[n], pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,10 +205,10 @@ static void getDerivations(EvalState & state, Value & vIn,
|
||||||
|
|
||||||
|
|
||||||
void getDerivations(EvalState & state, Value & v, const string & pathPrefix,
|
void getDerivations(EvalState & state, Value & v, const string & pathPrefix,
|
||||||
Bindings & autoArgs, DrvInfos & drvs)
|
Bindings & autoArgs, DrvInfos & drvs, bool ignoreAssertionFailures)
|
||||||
{
|
{
|
||||||
Done done;
|
Done done;
|
||||||
getDerivations(state, v, pathPrefix, autoArgs, drvs, done);
|
getDerivations(state, v, pathPrefix, autoArgs, drvs, done, ignoreAssertionFailures);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,12 @@ typedef list<DrvInfo> DrvInfos;
|
||||||
|
|
||||||
/* If value `v' denotes a derivation, store information about the
|
/* If value `v' denotes a derivation, store information about the
|
||||||
derivation in `drv' and return true. Otherwise, return false. */
|
derivation in `drv' and return true. Otherwise, return false. */
|
||||||
bool getDerivation(EvalState & state, Value & v, DrvInfo & drv);
|
bool getDerivation(EvalState & state, Value & v, DrvInfo & drv,
|
||||||
|
bool ignoreAssertionFailures);
|
||||||
|
|
||||||
void getDerivations(EvalState & state, Value & v, const string & pathPrefix,
|
void getDerivations(EvalState & state, Value & v, const string & pathPrefix,
|
||||||
Bindings & autoArgs, DrvInfos & drvs);
|
Bindings & autoArgs, DrvInfos & drvs,
|
||||||
|
bool ignoreAssertionFailures);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ static void loadDerivations(EvalState & state, Path nixExprPath,
|
||||||
Value v;
|
Value v;
|
||||||
findAlongAttrPath(state, pathPrefix, autoArgs, loadSourceExpr(state, nixExprPath), v);
|
findAlongAttrPath(state, pathPrefix, autoArgs, loadSourceExpr(state, nixExprPath), v);
|
||||||
|
|
||||||
getDerivations(state, v, pathPrefix, autoArgs, elems);
|
getDerivations(state, v, pathPrefix, autoArgs, elems, true);
|
||||||
|
|
||||||
/* Filter out all derivations not applicable to the current
|
/* Filter out all derivations not applicable to the current
|
||||||
system. */
|
system. */
|
||||||
|
@ -362,7 +362,7 @@ static void queryInstSources(EvalState & state,
|
||||||
Expr * e2 = state.parseExprFromString(*i, absPath("."));
|
Expr * e2 = state.parseExprFromString(*i, absPath("."));
|
||||||
Expr * call = new ExprApp(e2, e1);
|
Expr * call = new ExprApp(e2, e1);
|
||||||
Value v; state.eval(call, v);
|
Value v; state.eval(call, v);
|
||||||
getDerivations(state, v, "", instSource.autoArgs, elems);
|
getDerivations(state, v, "", instSource.autoArgs, elems, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -417,7 +417,7 @@ static void queryInstSources(EvalState & state,
|
||||||
Value v;
|
Value v;
|
||||||
findAlongAttrPath(state, *i, instSource.autoArgs,
|
findAlongAttrPath(state, *i, instSource.autoArgs,
|
||||||
loadSourceExpr(state, instSource.nixExprPath), v);
|
loadSourceExpr(state, instSource.nixExprPath), v);
|
||||||
getDerivations(state, v, "", instSource.autoArgs, elems);
|
getDerivations(state, v, "", instSource.autoArgs, elems, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ DrvInfos queryInstalled(EvalState & state, const Path & userEnv)
|
||||||
Value v;
|
Value v;
|
||||||
state.evalFile(manifestFile, v);
|
state.evalFile(manifestFile, v);
|
||||||
Bindings bindings;
|
Bindings bindings;
|
||||||
getDerivations(state, v, "", bindings, elems);
|
getDerivations(state, v, "", bindings, elems, false);
|
||||||
} else if (pathExists(oldManifestFile))
|
} else if (pathExists(oldManifestFile))
|
||||||
readLegacyManifest(oldManifestFile, elems);
|
readLegacyManifest(oldManifestFile, elems);
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
||||||
/* Evaluate it. */
|
/* Evaluate it. */
|
||||||
debug("evaluating user environment builder");
|
debug("evaluating user environment builder");
|
||||||
DrvInfo topLevelDrv;
|
DrvInfo topLevelDrv;
|
||||||
if (!getDerivation(state, topLevel, topLevelDrv))
|
if (!getDerivation(state, topLevel, topLevelDrv, false))
|
||||||
abort();
|
abort();
|
||||||
|
|
||||||
/* Realise the resulting store expression. */
|
/* Realise the resulting store expression. */
|
||||||
|
|
|
@ -56,7 +56,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DrvInfos drvs;
|
DrvInfos drvs;
|
||||||
getDerivations(state, v, "", autoArgs, drvs);
|
getDerivations(state, v, "", autoArgs, drvs, false);
|
||||||
foreach (DrvInfos::iterator, i, drvs) {
|
foreach (DrvInfos::iterator, i, drvs) {
|
||||||
Path drvPath = i->queryDrvPath(state);
|
Path drvPath = i->queryDrvPath(state);
|
||||||
if (gcRoot == "")
|
if (gcRoot == "")
|
||||||
|
|
Loading…
Reference in a new issue