* Give a useful error message when an evaluation error occurs while
trying to upgrade a package.
This commit is contained in:
parent
53a4981fa2
commit
6f7d7bc1de
1 changed files with 48 additions and 41 deletions
|
@ -704,52 +704,59 @@ static void upgradeDerivations(Globals & globals,
|
||||||
foreach (DrvInfos::iterator, i, installedElems) {
|
foreach (DrvInfos::iterator, i, installedElems) {
|
||||||
DrvName drvName(i->name);
|
DrvName drvName(i->name);
|
||||||
|
|
||||||
MetaInfo meta = i->queryMetaInfo(globals.state);
|
try {
|
||||||
if (keep(meta)) {
|
|
||||||
newElems.push_back(*i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the derivation in the input Nix expression with
|
MetaInfo meta = i->queryMetaInfo(globals.state);
|
||||||
the same name that satisfies the version constraints
|
if (keep(meta)) {
|
||||||
specified by upgradeType. If there are multiple
|
newElems.push_back(*i);
|
||||||
matches, take the one with the highest priority. If
|
continue;
|
||||||
there are still multiple matches, take the one with the
|
}
|
||||||
highest version. */
|
|
||||||
DrvInfos::iterator bestElem = availElems.end();
|
/* Find the derivation in the input Nix expression
|
||||||
DrvName bestName;
|
with the same name that satisfies the version
|
||||||
foreach (DrvInfos::iterator, j, availElems) {
|
constraints specified by upgradeType. If there are
|
||||||
DrvName newName(j->name);
|
multiple matches, take the one with the highest
|
||||||
if (newName.name == drvName.name) {
|
priority. If there are still multiple matches,
|
||||||
int d = comparePriorities(globals.state, *i, *j);
|
take the one with the highest version. */
|
||||||
if (d == 0) d = compareVersions(drvName.version, newName.version);
|
DrvInfos::iterator bestElem = availElems.end();
|
||||||
if ((upgradeType == utLt && d < 0) ||
|
DrvName bestName;
|
||||||
(upgradeType == utLeq && d <= 0) ||
|
foreach (DrvInfos::iterator, j, availElems) {
|
||||||
(upgradeType == utEq && d == 0) ||
|
DrvName newName(j->name);
|
||||||
upgradeType == utAlways)
|
if (newName.name == drvName.name) {
|
||||||
{
|
int d = comparePriorities(globals.state, *i, *j);
|
||||||
int d2 = -1;
|
if (d == 0) d = compareVersions(drvName.version, newName.version);
|
||||||
if (bestElem != availElems.end()) {
|
if ((upgradeType == utLt && d < 0) ||
|
||||||
d2 = comparePriorities(globals.state, *bestElem, *j);
|
(upgradeType == utLeq && d <= 0) ||
|
||||||
if (d2 == 0) d2 = compareVersions(bestName.version, newName.version);
|
(upgradeType == utEq && d == 0) ||
|
||||||
}
|
upgradeType == utAlways)
|
||||||
if (d2 < 0) {
|
{
|
||||||
bestElem = j;
|
int d2 = -1;
|
||||||
bestName = newName;
|
if (bestElem != availElems.end()) {
|
||||||
|
d2 = comparePriorities(globals.state, *bestElem, *j);
|
||||||
|
if (d2 == 0) d2 = compareVersions(bestName.version, newName.version);
|
||||||
|
}
|
||||||
|
if (d2 < 0) {
|
||||||
|
bestElem = j;
|
||||||
|
bestName = newName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (bestElem != availElems.end() &&
|
||||||
|
i->queryOutPath(globals.state) !=
|
||||||
|
bestElem->queryOutPath(globals.state))
|
||||||
|
{
|
||||||
|
printMsg(lvlInfo,
|
||||||
|
format("upgrading `%1%' to `%2%'")
|
||||||
|
% i->name % bestElem->name);
|
||||||
|
newElems.push_back(*bestElem);
|
||||||
|
} else newElems.push_back(*i);
|
||||||
|
|
||||||
if (bestElem != availElems.end() &&
|
} catch (Error & e) {
|
||||||
i->queryOutPath(globals.state) !=
|
e.addPrefix(format("while trying to find an upgrade for `%1%':\n") % i->name);
|
||||||
bestElem->queryOutPath(globals.state))
|
throw;
|
||||||
{
|
}
|
||||||
printMsg(lvlInfo,
|
|
||||||
format("upgrading `%1%' to `%2%'")
|
|
||||||
% i->name % bestElem->name);
|
|
||||||
newElems.push_back(*bestElem);
|
|
||||||
} else newElems.push_back(*i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printMissing(globals.state, newElems);
|
printMissing(globals.state, newElems);
|
||||||
|
|
Loading…
Reference in a new issue