forked from lix-project/lix
Include the output name in the GC root link
Output names are now appended to resulting GC symlinks, e.g. by nix-build. For backwards compatibility, if the output is named "out", nothing is appended. E.g. doing "nix-build -A foo" on a derivation that produces outputs "out", "bin" and "dev" will produce symlinks "./result", "./result-bin" and "./result-dev", respectively.
This commit is contained in:
parent
4aa1e5c554
commit
a9e6752bbd
|
@ -33,16 +33,6 @@ static void sigintHandler(int signo)
|
|||
}
|
||||
|
||||
|
||||
Path makeRootName(const Path & gcRoot, int & counter)
|
||||
{
|
||||
counter++;
|
||||
if (counter == 1)
|
||||
return gcRoot;
|
||||
else
|
||||
return (format("%1%-%2%") % gcRoot % counter).str();
|
||||
}
|
||||
|
||||
|
||||
void printGCWarning()
|
||||
{
|
||||
static bool haveWarned = false;
|
||||
|
|
|
@ -26,7 +26,6 @@ MakeError(UsageError, nix::Error);
|
|||
class StoreAPI;
|
||||
|
||||
/* Ugh. No better place to put this. */
|
||||
Path makeRootName(const Path & gcRoot, int & counter);
|
||||
void printGCWarning();
|
||||
|
||||
void printMissing(StoreAPI & store, const PathSet & paths);
|
||||
|
|
|
@ -64,9 +64,11 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
|||
Path drvPath = i->queryDrvPath(state);
|
||||
if (gcRoot == "")
|
||||
printGCWarning();
|
||||
else
|
||||
drvPath = addPermRoot(*store, drvPath,
|
||||
makeRootName(gcRoot, rootNr), indirectRoot);
|
||||
else {
|
||||
Path rootName = gcRoot;
|
||||
if (++rootNr > 1) rootName += "-" + int2String(rootNr);
|
||||
drvPath = addPermRoot(*store, drvPath, rootName, indirectRoot);
|
||||
}
|
||||
std::cout << format("%1%\n") % drvPath;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,15 +64,19 @@ static PathSet realisePath(const Path & path)
|
|||
if (isDerivation(path)) {
|
||||
store->buildPaths(singleton<PathSet>(path));
|
||||
Derivation drv = derivationFromPath(*store, path);
|
||||
rootNr++;
|
||||
|
||||
PathSet outputs;
|
||||
foreach (DerivationOutputs::iterator, i, drv.outputs) {
|
||||
Path outPath = i->second.path;
|
||||
if (gcRoot == "")
|
||||
printGCWarning();
|
||||
else
|
||||
outPath = addPermRoot(*store, outPath,
|
||||
makeRootName(gcRoot, rootNr), indirectRoot);
|
||||
else {
|
||||
Path rootName = gcRoot;
|
||||
if (rootNr > 1) rootName += "-" + int2String(rootNr);
|
||||
if (i->first != "out") rootName += "-" + i->first;
|
||||
outPath = addPermRoot(*store, outPath, rootName, indirectRoot);
|
||||
}
|
||||
outputs.insert(outPath);
|
||||
}
|
||||
return outputs;
|
||||
|
|
Loading…
Reference in a new issue