forked from lix-project/lix
* nix-env -ub' (
--prebuilt-only') didn't really work because it
checked too soon whether substitutes are available. That is, it did so for every available package, rather than those matching installed packages. This was very slow and subject to assertion failures. So do the check much later. Idem for `nix-env -qab' and `nix-env -ib'.
This commit is contained in:
parent
412914d004
commit
4ba6afaf48
|
@ -45,9 +45,7 @@ struct InstallSourceInfo
|
||||||
Path nixExprPath; /* for srcNixExprDrvs, srcNixExprs */
|
Path nixExprPath; /* for srcNixExprDrvs, srcNixExprs */
|
||||||
Path profile; /* for srcProfile */
|
Path profile; /* for srcProfile */
|
||||||
string systemFilter; /* for srcNixExprDrvs */
|
string systemFilter; /* for srcNixExprDrvs */
|
||||||
bool prebuiltOnly;
|
|
||||||
Bindings autoArgs;
|
Bindings autoArgs;
|
||||||
InstallSourceInfo() : prebuiltOnly(false) { };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,6 +58,7 @@ struct Globals
|
||||||
bool preserveInstalled;
|
bool preserveInstalled;
|
||||||
bool keepDerivations;
|
bool keepDerivations;
|
||||||
string forceName;
|
string forceName;
|
||||||
|
bool prebuiltOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,8 +92,6 @@ static bool parseInstallSourceOptions(Globals & globals,
|
||||||
}
|
}
|
||||||
else if (arg == "--attr" || arg == "-A")
|
else if (arg == "--attr" || arg == "-A")
|
||||||
globals.instSource.type = srcAttrPath;
|
globals.instSource.type = srcAttrPath;
|
||||||
else if (arg == "--prebuilt-only" || arg == "-b")
|
|
||||||
globals.instSource.prebuiltOnly = true;
|
|
||||||
else return false;
|
else return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +219,7 @@ static bool isPrebuilt(EvalState & state, const DrvInfo & elem)
|
||||||
|
|
||||||
|
|
||||||
static DrvInfos filterBySelector(EvalState & state, const DrvInfos & allElems,
|
static DrvInfos filterBySelector(EvalState & state, const DrvInfos & allElems,
|
||||||
const Strings & args, bool newestOnly, bool prebuiltOnly)
|
const Strings & args, bool newestOnly)
|
||||||
{
|
{
|
||||||
DrvNames selectors = drvNamesFromArgs(args);
|
DrvNames selectors = drvNamesFromArgs(args);
|
||||||
|
|
||||||
|
@ -241,7 +238,6 @@ static DrvInfos filterBySelector(EvalState & state, const DrvInfos & allElems,
|
||||||
DrvName drvName(j->name);
|
DrvName drvName(j->name);
|
||||||
if (i->matches(drvName)) {
|
if (i->matches(drvName)) {
|
||||||
i->hits++;
|
i->hits++;
|
||||||
if (!prebuiltOnly || isPrebuilt(state, *j))
|
|
||||||
matches.push_back(std::pair<DrvInfo, unsigned int>(*j, n));
|
matches.push_back(std::pair<DrvInfo, unsigned int>(*j, n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -342,8 +338,7 @@ static void queryInstSources(EvalState & state,
|
||||||
loadDerivations(state, instSource.nixExprPath,
|
loadDerivations(state, instSource.nixExprPath,
|
||||||
instSource.systemFilter, instSource.autoArgs, "", allElems);
|
instSource.systemFilter, instSource.autoArgs, "", allElems);
|
||||||
|
|
||||||
elems = filterBySelector(state, allElems, args,
|
elems = filterBySelector(state, allElems, args, newestOnly);
|
||||||
newestOnly, instSource.prebuiltOnly);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -408,7 +403,7 @@ static void queryInstSources(EvalState & state,
|
||||||
case srcProfile: {
|
case srcProfile: {
|
||||||
elems = filterBySelector(state,
|
elems = filterBySelector(state,
|
||||||
queryInstalled(state, instSource.profile),
|
queryInstalled(state, instSource.profile),
|
||||||
args, newestOnly, instSource.prebuiltOnly);
|
args, newestOnly);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,8 +448,13 @@ static void installDerivations(Globals & globals,
|
||||||
debug(format("installing derivations"));
|
debug(format("installing derivations"));
|
||||||
|
|
||||||
/* Get the set of user environment elements to be installed. */
|
/* Get the set of user environment elements to be installed. */
|
||||||
DrvInfos newElems;
|
DrvInfos newElems, newElemsTmp;
|
||||||
queryInstSources(globals.state, globals.instSource, args, newElems, true);
|
queryInstSources(globals.state, globals.instSource, args, newElemsTmp, true);
|
||||||
|
|
||||||
|
/* If --prebuilt-only is given, filter out source-only packages. */
|
||||||
|
foreach (DrvInfos::iterator, i, newElemsTmp)
|
||||||
|
if (!globals.prebuiltOnly || isPrebuilt(globals.state, *i))
|
||||||
|
newElems.push_back(*i);
|
||||||
|
|
||||||
StringSet newNames;
|
StringSet newNames;
|
||||||
for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i) {
|
for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i) {
|
||||||
|
@ -574,7 +574,7 @@ static void upgradeDerivations(Globals & globals,
|
||||||
d2 = comparePriorities(globals.state, *bestElem, *j);
|
d2 = comparePriorities(globals.state, *bestElem, *j);
|
||||||
if (d2 == 0) d2 = compareVersions(bestName.version, newName.version);
|
if (d2 == 0) d2 = compareVersions(bestName.version, newName.version);
|
||||||
}
|
}
|
||||||
if (d2 < 0) {
|
if (d2 < 0 && (!globals.prebuiltOnly || isPrebuilt(globals.state, *j))) {
|
||||||
bestElem = j;
|
bestElem = j;
|
||||||
bestName = newName;
|
bestName = newName;
|
||||||
}
|
}
|
||||||
|
@ -862,7 +862,6 @@ static void opQuery(Globals & globals,
|
||||||
bool printOutPath = false;
|
bool printOutPath = false;
|
||||||
bool printDescription = false;
|
bool printDescription = false;
|
||||||
bool printMeta = false;
|
bool printMeta = false;
|
||||||
bool prebuiltOnly = false;
|
|
||||||
bool compareVersions = false;
|
bool compareVersions = false;
|
||||||
bool xmlOutput = false;
|
bool xmlOutput = false;
|
||||||
|
|
||||||
|
@ -882,7 +881,6 @@ static void opQuery(Globals & globals,
|
||||||
else if (arg == "--meta") printMeta = true;
|
else if (arg == "--meta") printMeta = true;
|
||||||
else if (arg == "--installed") source = sInstalled;
|
else if (arg == "--installed") source = sInstalled;
|
||||||
else if (arg == "--available" || arg == "-a") source = sAvailable;
|
else if (arg == "--available" || arg == "-a") source = sAvailable;
|
||||||
else if (arg == "--prebuilt-only" || arg == "-b") prebuiltOnly = true;
|
|
||||||
else if (arg == "--xml") xmlOutput = true;
|
else if (arg == "--xml") xmlOutput = true;
|
||||||
else if (arg == "--attr-path" || arg == "-P") printAttrPath = true;
|
else if (arg == "--attr-path" || arg == "-P") printAttrPath = true;
|
||||||
else if (arg == "--attr" || arg == "-A")
|
else if (arg == "--attr" || arg == "-A")
|
||||||
|
@ -909,7 +907,7 @@ static void opQuery(Globals & globals,
|
||||||
|
|
||||||
DrvInfos elems = filterBySelector(globals.state,
|
DrvInfos elems = filterBySelector(globals.state,
|
||||||
source == sInstalled ? installedElems : availElems,
|
source == sInstalled ? installedElems : availElems,
|
||||||
remaining, false, prebuiltOnly);
|
remaining, false);
|
||||||
|
|
||||||
DrvInfos & otherElems(source == sInstalled ? availElems : installedElems);
|
DrvInfos & otherElems(source == sInstalled ? availElems : installedElems);
|
||||||
|
|
||||||
|
@ -943,6 +941,8 @@ static void opQuery(Globals & globals,
|
||||||
try {
|
try {
|
||||||
startNest(nest, lvlDebug, format("outputting query result `%1%'") % i->attrPath);
|
startNest(nest, lvlDebug, format("outputting query result `%1%'") % i->attrPath);
|
||||||
|
|
||||||
|
if (globals.prebuiltOnly && !isPrebuilt(globals.state, *i)) continue;
|
||||||
|
|
||||||
/* For table output. */
|
/* For table output. */
|
||||||
Strings columns;
|
Strings columns;
|
||||||
|
|
||||||
|
@ -1239,6 +1239,7 @@ void run(Strings args)
|
||||||
|
|
||||||
globals.dryRun = false;
|
globals.dryRun = false;
|
||||||
globals.preserveInstalled = false;
|
globals.preserveInstalled = false;
|
||||||
|
globals.prebuiltOnly = false;
|
||||||
|
|
||||||
globals.keepDerivations =
|
globals.keepDerivations =
|
||||||
queryBoolSetting("env-keep-derivations", false);
|
queryBoolSetting("env-keep-derivations", false);
|
||||||
|
@ -1285,6 +1286,8 @@ void run(Strings args)
|
||||||
}
|
}
|
||||||
else if (arg == "--system-filter")
|
else if (arg == "--system-filter")
|
||||||
globals.instSource.systemFilter = needArg(i, args, arg);
|
globals.instSource.systemFilter = needArg(i, args, arg);
|
||||||
|
else if (arg == "--prebuilt-only" || arg == "-b")
|
||||||
|
globals.prebuiltOnly = true;
|
||||||
else {
|
else {
|
||||||
remaining.push_back(arg);
|
remaining.push_back(arg);
|
||||||
if (arg[0] == '-') {
|
if (arg[0] == '-') {
|
||||||
|
|
Loading…
Reference in a new issue