about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-12-23T22·13+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-12-23T22·13+0000
commit392b7e0f8ecd50f98017021253386714f0771752 (patch)
tree82a28780cdb45f4d57b0f4526ed4e7e44fec94b6 /src
parent833f2fc92da8d31c62eb35dae8b3861829a1383a (diff)
* Fixed a bug in the upgrade operation.
Diffstat (limited to 'src')
-rw-r--r--src/nix-env/main.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc
index 6150b2fb6c00..7bced5be07a2 100644
--- a/src/nix-env/main.cc
+++ b/src/nix-env/main.cc
@@ -439,6 +439,7 @@ static void upgradeDerivations(EvalState & state,
     loadDerivations(state, nePath, availDrvs);
 
     /* Go through all installed derivations. */
+    DrvInfos newDrvs;
     for (DrvInfos::iterator i = installedDrvs.begin();
          i != installedDrvs.end(); ++i)
     {
@@ -455,31 +456,32 @@ static void upgradeDerivations(EvalState & state,
                 break;
             }
         }
-        if (!upgrade) continue;
 
         /* If yes, find the derivation in the input Nix expression
            with the same name and the highest version number. */
         DrvInfos::iterator bestDrv = i;
         DrvName bestName = drvName;
-        for (DrvInfos::iterator j = availDrvs.begin();
-             j != availDrvs.end(); ++j)
-        {
-            DrvName newName(j->second.name);
-            if (newName.name == bestName.name &&
-                compareVersions(newName.version, bestName.version) > 0)
-                bestDrv = j;
+        if (upgrade) {
+            for (DrvInfos::iterator j = availDrvs.begin();
+                 j != availDrvs.end(); ++j)
+            {
+                DrvName newName(j->second.name);
+                if (newName.name == bestName.name &&
+                    compareVersions(newName.version, bestName.version) > 0)
+                    bestDrv = j;
+            }
         }
 
         if (bestDrv != i) {
             printMsg(lvlInfo,
                 format("upgrading `%1%' to `%2%'")
                 % i->second.name % bestDrv->second.name);
-            installedDrvs.erase(i);
-            installedDrvs.insert(*bestDrv);
         }
+        
+        newDrvs.insert(*bestDrv);
     }
     
-    createUserEnv(state, installedDrvs, linkPath);
+    createUserEnv(state, newDrvs, linkPath);
 }