* Fix the infamous NIX-17: nix-env -i prints misleading messages

("installing `foo'" followed by "uninstalling `foo'").
This commit is contained in:
Eelco Dolstra 2006-02-17 16:26:28 +00:00
parent 345a95afe9
commit 889ef564fd
1 changed files with 9 additions and 7 deletions

View File

@ -346,16 +346,14 @@ static void installDerivations(Globals & globals,
queryInstSources(globals.state, globals.instSource, args, newElems); queryInstSources(globals.state, globals.instSource, args, newElems);
StringSet newNames; StringSet newNames;
for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i) { for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i)
printMsg(lvlInfo,
format("installing `%1%'") % i->name);
newNames.insert(DrvName(i->name).name); newNames.insert(DrvName(i->name).name);
}
/* Add in the already installed derivations, unless they have the /* Add in the already installed derivations, unless they have the
same name as a to-be-installed element. */ same name as a to-be-installed element. */
DrvInfos installedElems = queryInstalled(globals.state, profile); DrvInfos installedElems = queryInstalled(globals.state, profile);
DrvInfos allElems(newElems);
for (DrvInfos::iterator i = installedElems.begin(); for (DrvInfos::iterator i = installedElems.begin();
i != installedElems.end(); ++i) i != installedElems.end(); ++i)
{ {
@ -363,14 +361,18 @@ static void installDerivations(Globals & globals,
if (!globals.preserveInstalled && if (!globals.preserveInstalled &&
newNames.find(drvName.name) != newNames.end()) newNames.find(drvName.name) != newNames.end())
printMsg(lvlInfo, printMsg(lvlInfo,
format("uninstalling `%1%'") % i->name); format("replacing old `%1%'") % i->name);
else else
newElems.push_back(*i); allElems.push_back(*i);
} }
for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i)
printMsg(lvlInfo,
format("installing `%1%'") % i->name);
if (globals.dryRun) return; if (globals.dryRun) return;
createUserEnv(globals.state, newElems, createUserEnv(globals.state, allElems,
profile, globals.keepDerivations); profile, globals.keepDerivations);
} }