mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
adjusted to: void computeFSClosure(const Path & path, PathSet & paths, const bool & withComponents, const bool & withState, bool flipDirection)
This commit is contained in:
parent
7eb2f61797
commit
c370c9f535
11 changed files with 37 additions and 62 deletions
|
|
@ -1197,7 +1197,7 @@ DerivationGoal::HookReply DerivationGoal::tryBuildHook()
|
|||
*probably* already has it.) */
|
||||
PathSet allInputs;
|
||||
allInputs.insert(inputPaths.begin(), inputPaths.end());
|
||||
computeFSClosure(drvPath, allInputs, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
computeFSClosure(drvPath, allInputs, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
|
||||
string s;
|
||||
for (PathSet::iterator i = allInputs.begin();
|
||||
|
|
@ -1316,7 +1316,7 @@ bool DerivationGoal::prepareBuild()
|
|||
Derivation inDrv = derivationFromPath(i->first);
|
||||
for (StringSet::iterator j = i->second.begin(); j != i->second.end(); ++j)
|
||||
if (inDrv.outputs.find(*j) != inDrv.outputs.end())
|
||||
computeFSClosure(inDrv.outputs[*j].path, inputPaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
computeFSClosure(inDrv.outputs[*j].path, inputPaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
else
|
||||
throw BuildError(
|
||||
format("derivation `%1%' requires non-existent output `%2%' from input derivation `%3%'")
|
||||
|
|
@ -1325,7 +1325,7 @@ bool DerivationGoal::prepareBuild()
|
|||
|
||||
/* Second, the input sources. */
|
||||
for (PathSet::iterator i = drv.inputSrcs.begin(); i != drv.inputSrcs.end(); ++i)
|
||||
computeFSClosure(*i, inputPaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
computeFSClosure(*i, inputPaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
|
||||
debug(format("added input paths %1%") % showPaths(inputPaths));
|
||||
|
||||
|
|
@ -1450,7 +1450,7 @@ void DerivationGoal::startBuilder()
|
|||
|
||||
/* Write closure info to `fileName'. */
|
||||
PathSet refs;
|
||||
computeFSClosure(storePath, refs, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
computeFSClosure(storePath, refs, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
/* !!! in secure Nix, the writing should be done on the
|
||||
build uid for security (maybe). */
|
||||
writeStringToFile(tmpDir + "/" + fileName,
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
|||
roots under the `references' relation. */
|
||||
PathSet livePaths;
|
||||
for (PathSet::const_iterator i = roots.begin(); i != roots.end(); ++i)
|
||||
computeFSClosure(canonPath(*i), livePaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO DELETE STATE??
|
||||
computeFSClosure(canonPath(*i), livePaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO DELETE STATE??
|
||||
|
||||
if (gcKeepDerivations) {
|
||||
for (PathSet::iterator i = livePaths.begin();
|
||||
|
|
@ -480,7 +480,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
|||
turned off). */
|
||||
Path deriver = queryDeriver(noTxn, *i);
|
||||
if (deriver != "" && store->isValidPath(deriver))
|
||||
computeFSClosure(deriver, livePaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
||||
computeFSClosure(deriver, livePaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -493,7 +493,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
|||
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
||||
j != drv.outputs.end(); ++j)
|
||||
if (store->isValidPath(j->second.path))
|
||||
computeFSClosure(j->second.path, livePaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
||||
computeFSClosure(j->second.path, livePaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -518,7 +518,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
|||
PathSet tempRootsClosed;
|
||||
for (PathSet::iterator i = tempRoots.begin(); i != tempRoots.end(); ++i)
|
||||
if (store->isValidPath(*i))
|
||||
computeFSClosure(*i, tempRootsClosed, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO .... STATE
|
||||
computeFSClosure(*i, tempRootsClosed, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO .... STATE
|
||||
else
|
||||
tempRootsClosed.insert(*i);
|
||||
|
||||
|
|
|
|||
|
|
@ -1499,9 +1499,9 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
|
|||
- Source/binary deployment (when called on a derivation with
|
||||
`includeOutputs' set to true).
|
||||
*/
|
||||
void storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState)
|
||||
void storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState)
|
||||
{
|
||||
computeFSClosure(storePath, paths, withState);
|
||||
computeFSClosure(storePath, paths, withComponents, withState);
|
||||
|
||||
if (includeOutputs) {
|
||||
for (PathSet::iterator i = paths.begin();
|
||||
|
|
@ -1511,38 +1511,16 @@ void storePathRequisites(const Path & storePath, const bool includeOutputs, Path
|
|||
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
||||
j != drv.outputs.end(); ++j)
|
||||
if (store->isValidPath(j->second.path))
|
||||
computeFSClosure(j->second.path, paths, withState);
|
||||
computeFSClosure(j->second.path, paths, withComponents, withState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocalStore::storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState)
|
||||
void LocalStore::storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState)
|
||||
{
|
||||
return nix::storePathRequisites(storePath, includeOutputs, paths, withState);
|
||||
return nix::storePathRequisites(storePath, includeOutputs, paths, withComponents, withState);
|
||||
}
|
||||
|
||||
/*
|
||||
* Same as storePathRequisites with withState=true, but now only returns the state paths
|
||||
*/
|
||||
void storePathStateRequisitesOnlyTxn(const Transaction & txn, const Path & storePath, const bool includeOutputs, PathSet & statePaths)
|
||||
{
|
||||
PathSet paths;
|
||||
storePathRequisites(storePath, includeOutputs, paths, true);
|
||||
|
||||
//filter out all non-state paths
|
||||
for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i){
|
||||
if (isValidStatePathTxn(txn, *i))
|
||||
statePaths.insert(*i);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalStore::storePathStateRequisitesOnly(const Path & storePath, const bool includeOutputs, PathSet & statePaths)
|
||||
{
|
||||
nix::storePathStateRequisitesOnlyTxn(noTxn, storePath, includeOutputs, statePaths);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* TODO
|
||||
*
|
||||
|
|
@ -1576,14 +1554,14 @@ void getDependenciesAtBuildTime(const Transaction & txn, const Path & drvPath)
|
|||
Derivation inDrv = derivationFromPath(i->first);
|
||||
for (StringSet::iterator j = i->second.begin(); j != i->second.end(); ++j)
|
||||
if (inDrv.outputs.find(*j) != inDrv.outputs.end())
|
||||
computeFSClosure(inDrv.outputs[*j].path, inputPaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
computeFSClosure(inDrv.outputs[*j].path, inputPaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
else
|
||||
throw Error(format("derivation `%1%' requires non-existent output `%2%' from input derivation `%3%'") % drvPath % *j % i->first);
|
||||
}
|
||||
|
||||
// Second, the input sources.
|
||||
for (PathSet::iterator i = drv.inputSrcs.begin(); i != drv.inputSrcs.end(); ++i)
|
||||
computeFSClosure(*i, inputPaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
computeFSClosure(*i, inputPaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
|
||||
//debug(format("added input paths %1%") % showPaths(inputPaths)); //TODO
|
||||
allPaths.insert(inputPaths.begin(), inputPaths.end());
|
||||
|
|
|
|||
|
|
@ -96,9 +96,7 @@ public:
|
|||
|
||||
bool isStateDrv(const Derivation & drv);
|
||||
|
||||
void storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState);
|
||||
|
||||
void storePathStateRequisitesOnly(const Path & storePath, const bool includeOutputs, PathSet & statePaths);
|
||||
void storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState);
|
||||
|
||||
void scanForAllReferences(const Path & statePath);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,11 +17,17 @@ Derivation derivationFromPath(const Path & drvPath)
|
|||
return parseDerivation(t);
|
||||
}
|
||||
|
||||
void computeFSClosure(const Path & path, PathSet & paths, const bool & withState, bool flipDirection)
|
||||
void computeFSClosure(const Path & path, PathSet & paths, const bool & withComponents, const bool & withState, bool flipDirection)
|
||||
{
|
||||
PathSet allPaths;
|
||||
computeFSClosureRec(path, allPaths, flipDirection);
|
||||
|
||||
if(!withComponents && !withState)
|
||||
throw Error(format("Useless call to computeFSClosure, at leat withComponents or withState must be true"));
|
||||
|
||||
//if withComponents is false .....
|
||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
//if withState is false, we filter out all state paths
|
||||
if(withState == false){
|
||||
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i){
|
||||
|
|
|
|||
|
|
@ -17,8 +17,12 @@ Derivation derivationFromPath(const Path & drvPath);
|
|||
`flipDirection' is true, the set of paths that can reach
|
||||
`storePath' is returned; that is, the closures under the
|
||||
`referrers' relation instead of the `references' relation is
|
||||
|
||||
withState = TODO comment
|
||||
withComponents = TODO
|
||||
|
||||
returned. */
|
||||
void computeFSClosure(const Path & storePath, PathSet & paths, const bool & withState, bool flipDirection = false);
|
||||
void computeFSClosure(const Path & storePath, PathSet & paths, const bool & withComponents, const bool & withState, bool flipDirection = false);
|
||||
|
||||
void computeFSClosureRec(const Path & path, PathSet & paths, const bool & flipDirection); //private
|
||||
|
||||
|
|
|
|||
|
|
@ -452,13 +452,7 @@ bool RemoteStore::isStateDrv(const Derivation & drv)
|
|||
}
|
||||
|
||||
//TODO
|
||||
void RemoteStore::storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//TODO
|
||||
void RemoteStore::storePathStateRequisitesOnly(const Path & storePath, const bool includeOutputs, PathSet & statePaths)
|
||||
void RemoteStore::storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,10 +84,8 @@ public:
|
|||
|
||||
bool isStateDrv(const Derivation & drv);
|
||||
|
||||
void storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState);
|
||||
void storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState);
|
||||
|
||||
void storePathStateRequisitesOnly(const Path & storePath, const bool includeOutputs, PathSet & statePaths);
|
||||
|
||||
void scanForAllReferences(const Path & statePath);
|
||||
|
||||
void scanForAllReferencesRecusively(const Path & storePath);
|
||||
|
|
|
|||
|
|
@ -215,11 +215,8 @@ public:
|
|||
virtual bool isStateDrv(const Derivation & drv) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual void storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState) = 0;
|
||||
virtual void storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual void storePathStateRequisitesOnly(const Path & storePath, const bool includeOutputs, PathSet & statePaths) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual void scanForAllReferences(const Path & statePath) = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ PathSet getAllStateDerivationsRecursively(const Path & storePath)
|
|||
{
|
||||
//Get recursively all state paths
|
||||
PathSet statePaths;
|
||||
store->storePathStateRequisitesOnly(storePath, false, statePaths);
|
||||
store->storePathRequisites(storePath, false, statePaths, false, true);
|
||||
|
||||
//Find the matching drv with the statePath
|
||||
PathSet derivations;
|
||||
|
|
|
|||
|
|
@ -304,15 +304,15 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
|||
i != opArgs.end(); ++i)
|
||||
{
|
||||
Path path = maybeUseOutput(fixStoreOrStatePath(*i), useOutput, forceRealise);
|
||||
if (query == qRequisites) store->storePathRequisites(path, includeOutputs, paths, false);
|
||||
else if (query == qRequisitesState) store->storePathStateRequisitesOnly(path, includeOutputs, paths);
|
||||
else if (query == qRequisitesFull) store->storePathRequisites(path, includeOutputs, paths, true);
|
||||
if (query == qRequisites) store->storePathRequisites(path, includeOutputs, paths, true, false);
|
||||
else if (query == qRequisitesState) store->storePathRequisites(path, includeOutputs, paths, false, true);
|
||||
else if (query == qRequisitesFull) store->storePathRequisites(path, includeOutputs, paths, true, true);
|
||||
else if (query == qReferences) store->queryReferences(path, paths);
|
||||
else if (query == qStateReferences) store->queryStateReferences(path, paths);
|
||||
else if (query == qReferrers) store->queryReferrers(path, paths);
|
||||
else if (query == qStateReferrers) store->queryStateReferrers(path, paths);
|
||||
else if (query == qReferrersClosure) computeFSClosure(path, paths, false, true);
|
||||
else if (query == qReferrersClosureWithState) computeFSClosure(path, paths, true, true);
|
||||
else if (query == qReferrersClosure) computeFSClosure(path, paths, true, false, true);
|
||||
else if (query == qReferrersClosureWithState) computeFSClosure(path, paths, true, true, true);
|
||||
}
|
||||
Paths sorted = topoSortPaths(paths);
|
||||
for (Paths::reverse_iterator i = sorted.rbegin();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue