forked from lix-project/lix
Merge branch 'nix-env-warn-unmatched' of https://github.com/lheckemann/nix
This commit is contained in:
commit
6a8cba83bb
|
@ -718,28 +718,39 @@ static void uninstallDerivations(Globals & globals, Strings & selectors,
|
||||||
while (true) {
|
while (true) {
|
||||||
string lockToken = optimisticLockProfile(profile);
|
string lockToken = optimisticLockProfile(profile);
|
||||||
|
|
||||||
DrvInfos installedElems = queryInstalled(*globals.state, profile);
|
DrvInfos workingElems = queryInstalled(*globals.state, profile);
|
||||||
DrvInfos newElems;
|
|
||||||
|
|
||||||
for (auto & i : installedElems) {
|
for (auto & selector : selectors) {
|
||||||
DrvName drvName(i.queryName());
|
DrvInfos::iterator split = workingElems.begin();
|
||||||
bool found = false;
|
if (isPath(selector)) {
|
||||||
for (auto & j : selectors)
|
StorePath selectorStorePath = globals.state->store->followLinksToStorePath(selector);
|
||||||
/* !!! the repeated calls to followLinksToStorePath()
|
split = std::partition(
|
||||||
are expensive, should pre-compute them. */
|
workingElems.begin(), workingElems.end(),
|
||||||
if ((isPath(j) && globals.state->store->parseStorePath(i.queryOutPath()) == globals.state->store->followLinksToStorePath(j))
|
[&selectorStorePath, globals](auto &elem) {
|
||||||
|| DrvName(j).matches(drvName))
|
return selectorStorePath != globals.state->store->parseStorePath(elem.queryOutPath());
|
||||||
{
|
|
||||||
printInfo("uninstalling '%s'", i.queryName());
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (!found) newElems.push_back(i);
|
);
|
||||||
|
} else {
|
||||||
|
DrvName selectorName(selector);
|
||||||
|
split = std::partition(
|
||||||
|
workingElems.begin(), workingElems.end(),
|
||||||
|
[&selectorName](auto &elem){
|
||||||
|
DrvName elemName(elem.queryName());
|
||||||
|
return !selectorName.matches(elemName);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (split == workingElems.end())
|
||||||
|
warn("Selector '%s' matched no installed paths", selector);
|
||||||
|
for (auto removedElem = split; removedElem != workingElems.end(); removedElem++) {
|
||||||
|
printInfo("uninstalling '%s'", removedElem->queryName());
|
||||||
|
}
|
||||||
|
workingElems.erase(split, workingElems.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globals.dryRun) return;
|
if (globals.dryRun) return;
|
||||||
|
|
||||||
if (createUserEnv(*globals.state, newElems,
|
if (createUserEnv(*globals.state, workingElems,
|
||||||
profile, settings.envKeepDerivations, lockToken)) break;
|
profile, settings.envKeepDerivations, lockToken)) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue