From 889ef564fd0aca2814659f28fc7b9dc0191a6656 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 17 Feb 2006 16:26:28 +0000 Subject: [PATCH] * Fix the infamous NIX-17: nix-env -i prints misleading messages ("installing `foo'" followed by "uninstalling `foo'"). --- src/nix-env/main.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc index dd531382f..4acbb6db0 100644 --- a/src/nix-env/main.cc +++ b/src/nix-env/main.cc @@ -346,16 +346,14 @@ static void installDerivations(Globals & globals, queryInstSources(globals.state, globals.instSource, args, newElems); StringSet newNames; - for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i) { - printMsg(lvlInfo, - format("installing `%1%'") % i->name); + for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i) newNames.insert(DrvName(i->name).name); - } /* Add in the already installed derivations, unless they have the same name as a to-be-installed element. */ DrvInfos installedElems = queryInstalled(globals.state, profile); + DrvInfos allElems(newElems); for (DrvInfos::iterator i = installedElems.begin(); i != installedElems.end(); ++i) { @@ -363,14 +361,18 @@ static void installDerivations(Globals & globals, if (!globals.preserveInstalled && newNames.find(drvName.name) != newNames.end()) printMsg(lvlInfo, - format("uninstalling `%1%'") % i->name); + format("replacing old `%1%'") % i->name); 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; - createUserEnv(globals.state, newElems, + createUserEnv(globals.state, allElems, profile, globals.keepDerivations); }