diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2009-10-13T09·30+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2009-10-13T09·30+0000 |
commit | 6f7d7bc1de110c49e7b41926e4669ce44bc86617 (patch) | |
tree | 9cbb132110f46961ce6ac3d9edec3134a866e570 /src/nix-env | |
parent | 53a4981fa28a9f13758554b643c06e871ede8dbd (diff) |
* Give a useful error message when an evaluation error occurs while
trying to upgrade a package.
Diffstat (limited to 'src/nix-env')
-rw-r--r-- | src/nix-env/nix-env.cc | 89 |
1 files changed, 48 insertions, 41 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index cb3fffc485ad..35caf687bf87 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -704,52 +704,59 @@ static void upgradeDerivations(Globals & globals, foreach (DrvInfos::iterator, i, installedElems) { DrvName drvName(i->name); - MetaInfo meta = i->queryMetaInfo(globals.state); - if (keep(meta)) { - newElems.push_back(*i); - continue; - } + try { - /* Find the derivation in the input Nix expression with - the same name that satisfies the version constraints - specified by upgradeType. If there are multiple - matches, take the one with the highest priority. If - there are still multiple matches, take the one with the - highest version. */ - DrvInfos::iterator bestElem = availElems.end(); - DrvName bestName; - foreach (DrvInfos::iterator, j, availElems) { - DrvName newName(j->name); - if (newName.name == drvName.name) { - int d = comparePriorities(globals.state, *i, *j); - if (d == 0) d = compareVersions(drvName.version, newName.version); - if ((upgradeType == utLt && d < 0) || - (upgradeType == utLeq && d <= 0) || - (upgradeType == utEq && d == 0) || - upgradeType == utAlways) - { - int d2 = -1; - 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; + MetaInfo meta = i->queryMetaInfo(globals.state); + if (keep(meta)) { + newElems.push_back(*i); + continue; + } + + /* Find the derivation in the input Nix expression + with the same name that satisfies the version + constraints specified by upgradeType. If there are + multiple matches, take the one with the highest + priority. If there are still multiple matches, + take the one with the highest version. */ + DrvInfos::iterator bestElem = availElems.end(); + DrvName bestName; + foreach (DrvInfos::iterator, j, availElems) { + DrvName newName(j->name); + if (newName.name == drvName.name) { + int d = comparePriorities(globals.state, *i, *j); + if (d == 0) d = compareVersions(drvName.version, newName.version); + if ((upgradeType == utLt && d < 0) || + (upgradeType == utLeq && d <= 0) || + (upgradeType == utEq && d == 0) || + upgradeType == utAlways) + { + int d2 = -1; + 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); + + } catch (Error & e) { + e.addPrefix(format("while trying to find an upgrade for `%1%':\n") % i->name); + throw; } - - 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); } printMissing(globals.state, newElems); |