From 24286e15c9822833c39d268e521522b9933db28e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 28 Jun 2004 13:37:05 +0000 Subject: [PATCH] * `nix-env -u' now allows a specific version to be specified when upgrading. This fixes a bug reported by Martin: $ nix-env -i foo-1.0 $ nix-env -u foo-1.0 upgrading foo-1.0 to foo-1.1 --- doc/manual/nix-env.xml | 3 +++ src/nix-env/main.cc | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/manual/nix-env.xml b/doc/manual/nix-env.xml index 70069fa1a..8a496da25 100644 --- a/doc/manual/nix-env.xml +++ b/doc/manual/nix-env.xml @@ -312,6 +312,9 @@ $ nix-env -f ~/foo.nix -i '*' (install everything in f $ nix-env --upgrade gcc upgrading `gcc-3.3.1' to `gcc-3.4' +$ nix-env -u gcc-3.3.2 --always (switch to a specific version) +upgrading `gcc-3.4' to `gcc-3.3.2' + $ nix-env --upgrade pan (no upgrades available, so nothing happens) diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc index c57f03cce..1f16e72ae 100644 --- a/src/nix-env/main.cc +++ b/src/nix-env/main.cc @@ -310,14 +310,16 @@ static void upgradeDerivations(EvalState & state, i != installedDrvs.end(); ++i) { DrvName drvName(i->second.name); + DrvName selector; /* Do we want to upgrade this derivation? */ bool upgrade = false; for (DrvNames::iterator j = selectors.begin(); j != selectors.end(); ++j) { - if (j->matches(drvName)) { + if (j->name == "*" || j->name == drvName.name) { j->hits++; + selector = *j; upgrade = true; break; } @@ -344,9 +346,10 @@ static void upgradeDerivations(EvalState & state, upgradeType == utLeq && d <= 0 || upgradeType == utAlways) { - if (bestDrv == availDrvs.end() || - compareVersions( - bestName.version, newName.version) < 0) + if (selector.matches(newName) && + (bestDrv == availDrvs.end() || + compareVersions( + bestName.version, newName.version) < 0)) { bestDrv = j; bestName = newName;