forked from lix-project/lix
* `nix-env --upgrade --eq': only upgrade if the old version is equal
to the new version. This is actually useful.
This commit is contained in:
parent
f4a3a280db
commit
a945fb7905
2 changed files with 5 additions and 2 deletions
|
@ -31,7 +31,8 @@ Install / upgrade / uninstall flags:
|
||||||
Upgrade flags:
|
Upgrade flags:
|
||||||
|
|
||||||
--lt: upgrade if the current version is older (default)
|
--lt: upgrade if the current version is older (default)
|
||||||
--leq: upgrade if the current version is older or current
|
--leq: upgrade if the current version is older or equal
|
||||||
|
--eq: "upgrade" if the current version is equal
|
||||||
--always: upgrade regardless of current version
|
--always: upgrade regardless of current version
|
||||||
|
|
||||||
Query types:
|
Query types:
|
||||||
|
|
|
@ -476,7 +476,7 @@ static void opInstall(Globals & globals,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef enum { utLt, utLeq, utAlways } UpgradeType;
|
typedef enum { utLt, utLeq, utEq, utAlways } UpgradeType;
|
||||||
|
|
||||||
|
|
||||||
static void upgradeDerivations(Globals & globals,
|
static void upgradeDerivations(Globals & globals,
|
||||||
|
@ -520,6 +520,7 @@ static void upgradeDerivations(Globals & globals,
|
||||||
int d = compareVersions(drvName.version, newName.version);
|
int d = compareVersions(drvName.version, newName.version);
|
||||||
if (upgradeType == utLt && d < 0 ||
|
if (upgradeType == utLt && d < 0 ||
|
||||||
upgradeType == utLeq && d <= 0 ||
|
upgradeType == utLeq && d <= 0 ||
|
||||||
|
upgradeType == utEq && d == 0 ||
|
||||||
upgradeType == utAlways)
|
upgradeType == utAlways)
|
||||||
{
|
{
|
||||||
if ((bestElem == availElems.end() ||
|
if ((bestElem == availElems.end() ||
|
||||||
|
@ -562,6 +563,7 @@ static void opUpgrade(Globals & globals,
|
||||||
i != opFlags.end(); ++i)
|
i != opFlags.end(); ++i)
|
||||||
if (*i == "--lt") upgradeType = utLt;
|
if (*i == "--lt") upgradeType = utLt;
|
||||||
else if (*i == "--leq") upgradeType = utLeq;
|
else if (*i == "--leq") upgradeType = utLeq;
|
||||||
|
else if (*i == "--eq") upgradeType = utEq;
|
||||||
else if (*i == "--always") upgradeType = utAlways;
|
else if (*i == "--always") upgradeType = utAlways;
|
||||||
else throw UsageError(format("unknown flag `%1%'") % *i);
|
else throw UsageError(format("unknown flag `%1%'") % *i);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue