* Fixed a bug in the upgrade operation.

This commit is contained in:
Eelco Dolstra 2003-12-23 22:13:36 +00:00
parent 833f2fc92d
commit 392b7e0f8e

View file

@ -439,6 +439,7 @@ static void upgradeDerivations(EvalState & state,
loadDerivations(state, nePath, availDrvs); loadDerivations(state, nePath, availDrvs);
/* Go through all installed derivations. */ /* Go through all installed derivations. */
DrvInfos newDrvs;
for (DrvInfos::iterator i = installedDrvs.begin(); for (DrvInfos::iterator i = installedDrvs.begin();
i != installedDrvs.end(); ++i) i != installedDrvs.end(); ++i)
{ {
@ -455,12 +456,12 @@ static void upgradeDerivations(EvalState & state,
break; break;
} }
} }
if (!upgrade) continue;
/* If yes, find the derivation in the input Nix expression /* If yes, find the derivation in the input Nix expression
with the same name and the highest version number. */ with the same name and the highest version number. */
DrvInfos::iterator bestDrv = i; DrvInfos::iterator bestDrv = i;
DrvName bestName = drvName; DrvName bestName = drvName;
if (upgrade) {
for (DrvInfos::iterator j = availDrvs.begin(); for (DrvInfos::iterator j = availDrvs.begin();
j != availDrvs.end(); ++j) j != availDrvs.end(); ++j)
{ {
@ -469,17 +470,18 @@ static void upgradeDerivations(EvalState & state,
compareVersions(newName.version, bestName.version) > 0) compareVersions(newName.version, bestName.version) > 0)
bestDrv = j; bestDrv = j;
} }
}
if (bestDrv != i) { if (bestDrv != i) {
printMsg(lvlInfo, printMsg(lvlInfo,
format("upgrading `%1%' to `%2%'") format("upgrading `%1%' to `%2%'")
% i->second.name % bestDrv->second.name); % i->second.name % bestDrv->second.name);
installedDrvs.erase(i);
installedDrvs.insert(*bestDrv);
}
} }
createUserEnv(state, installedDrvs, linkPath); newDrvs.insert(*bestDrv);
}
createUserEnv(state, newDrvs, linkPath);
} }