1
1
Fork 0
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:
Wouter den Breejen 2007-06-29 15:24:51 +00:00
parent 7eb2f61797
commit c370c9f535
11 changed files with 37 additions and 62 deletions

View file

@ -1197,7 +1197,7 @@ DerivationGoal::HookReply DerivationGoal::tryBuildHook()
*probably* already has it.) */ *probably* already has it.) */
PathSet allInputs; PathSet allInputs;
allInputs.insert(inputPaths.begin(), inputPaths.end()); 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; string s;
for (PathSet::iterator i = allInputs.begin(); for (PathSet::iterator i = allInputs.begin();
@ -1316,7 +1316,7 @@ bool DerivationGoal::prepareBuild()
Derivation inDrv = derivationFromPath(i->first); Derivation inDrv = derivationFromPath(i->first);
for (StringSet::iterator j = i->second.begin(); j != i->second.end(); ++j) for (StringSet::iterator j = i->second.begin(); j != i->second.end(); ++j)
if (inDrv.outputs.find(*j) != inDrv.outputs.end()) 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 else
throw BuildError( throw BuildError(
format("derivation `%1%' requires non-existent output `%2%' from input derivation `%3%'") format("derivation `%1%' requires non-existent output `%2%' from input derivation `%3%'")
@ -1325,7 +1325,7 @@ bool DerivationGoal::prepareBuild()
/* Second, the input sources. */ /* Second, the input sources. */
for (PathSet::iterator i = drv.inputSrcs.begin(); i != drv.inputSrcs.end(); ++i) 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)); debug(format("added input paths %1%") % showPaths(inputPaths));
@ -1450,7 +1450,7 @@ void DerivationGoal::startBuilder()
/* Write closure info to `fileName'. */ /* Write closure info to `fileName'. */
PathSet refs; 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 /* !!! in secure Nix, the writing should be done on the
build uid for security (maybe). */ build uid for security (maybe). */
writeStringToFile(tmpDir + "/" + fileName, writeStringToFile(tmpDir + "/" + fileName,

View file

@ -469,7 +469,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
roots under the `references' relation. */ roots under the `references' relation. */
PathSet livePaths; PathSet livePaths;
for (PathSet::const_iterator i = roots.begin(); i != roots.end(); ++i) 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) { if (gcKeepDerivations) {
for (PathSet::iterator i = livePaths.begin(); for (PathSet::iterator i = livePaths.begin();
@ -480,7 +480,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
turned off). */ turned off). */
Path deriver = queryDeriver(noTxn, *i); Path deriver = queryDeriver(noTxn, *i);
if (deriver != "" && store->isValidPath(deriver)) 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(); for (DerivationOutputs::iterator j = drv.outputs.begin();
j != drv.outputs.end(); ++j) j != drv.outputs.end(); ++j)
if (store->isValidPath(j->second.path)) 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; PathSet tempRootsClosed;
for (PathSet::iterator i = tempRoots.begin(); i != tempRoots.end(); ++i) for (PathSet::iterator i = tempRoots.begin(); i != tempRoots.end(); ++i)
if (store->isValidPath(*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 else
tempRootsClosed.insert(*i); tempRootsClosed.insert(*i);

View file

@ -1499,9 +1499,9 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
- Source/binary deployment (when called on a derivation with - Source/binary deployment (when called on a derivation with
`includeOutputs' set to true). `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) { if (includeOutputs) {
for (PathSet::iterator i = paths.begin(); 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(); for (DerivationOutputs::iterator j = drv.outputs.begin();
j != drv.outputs.end(); ++j) j != drv.outputs.end(); ++j)
if (store->isValidPath(j->second.path)) 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 * TODO
* *
@ -1576,14 +1554,14 @@ void getDependenciesAtBuildTime(const Transaction & txn, const Path & drvPath)
Derivation inDrv = derivationFromPath(i->first); Derivation inDrv = derivationFromPath(i->first);
for (StringSet::iterator j = i->second.begin(); j != i->second.end(); ++j) for (StringSet::iterator j = i->second.begin(); j != i->second.end(); ++j)
if (inDrv.outputs.find(*j) != inDrv.outputs.end()) 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 else
throw Error(format("derivation `%1%' requires non-existent output `%2%' from input derivation `%3%'") % drvPath % *j % i->first); throw Error(format("derivation `%1%' requires non-existent output `%2%' from input derivation `%3%'") % drvPath % *j % i->first);
} }
// Second, the input sources. // Second, the input sources.
for (PathSet::iterator i = drv.inputSrcs.begin(); i != drv.inputSrcs.end(); ++i) 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 //debug(format("added input paths %1%") % showPaths(inputPaths)); //TODO
allPaths.insert(inputPaths.begin(), inputPaths.end()); allPaths.insert(inputPaths.begin(), inputPaths.end());

View file

@ -96,9 +96,7 @@ public:
bool isStateDrv(const Derivation & drv); 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 scanForAllReferences(const Path & statePath);

View file

@ -17,11 +17,17 @@ Derivation derivationFromPath(const Path & drvPath)
return parseDerivation(t); 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; PathSet allPaths;
computeFSClosureRec(path, allPaths, flipDirection); 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 is false, we filter out all state paths
if(withState == false){ if(withState == false){
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i){ for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i){

View file

@ -17,8 +17,12 @@ Derivation derivationFromPath(const Path & drvPath);
`flipDirection' is true, the set of paths that can reach `flipDirection' is true, the set of paths that can reach
`storePath' is returned; that is, the closures under the `storePath' is returned; that is, the closures under the
`referrers' relation instead of the `references' relation is `referrers' relation instead of the `references' relation is
withState = TODO comment
withComponents = TODO
returned. */ 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 void computeFSClosureRec(const Path & path, PathSet & paths, const bool & flipDirection); //private

View file

@ -452,13 +452,7 @@ bool RemoteStore::isStateDrv(const Derivation & drv)
} }
//TODO //TODO
void RemoteStore::storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState) void RemoteStore::storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState)
{
}
//TODO
void RemoteStore::storePathStateRequisitesOnly(const Path & storePath, const bool includeOutputs, PathSet & statePaths)
{ {
} }

View file

@ -84,10 +84,8 @@ public:
bool isStateDrv(const Derivation & drv); 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 scanForAllReferences(const Path & statePath);
void scanForAllReferencesRecusively(const Path & storePath); void scanForAllReferencesRecusively(const Path & storePath);

View file

@ -215,11 +215,8 @@ public:
virtual bool isStateDrv(const Derivation & drv) = 0; virtual bool isStateDrv(const Derivation & drv) = 0;
/* TODO */ /* 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 */ /* TODO */
virtual void scanForAllReferences(const Path & statePath) = 0; virtual void scanForAllReferences(const Path & statePath) = 0;

View file

@ -175,7 +175,7 @@ PathSet getAllStateDerivationsRecursively(const Path & storePath)
{ {
//Get recursively all state paths //Get recursively all state paths
PathSet statePaths; PathSet statePaths;
store->storePathStateRequisitesOnly(storePath, false, statePaths); store->storePathRequisites(storePath, false, statePaths, false, true);
//Find the matching drv with the statePath //Find the matching drv with the statePath
PathSet derivations; PathSet derivations;

View file

@ -304,15 +304,15 @@ static void opQuery(Strings opFlags, Strings opArgs)
i != opArgs.end(); ++i) i != opArgs.end(); ++i)
{ {
Path path = maybeUseOutput(fixStoreOrStatePath(*i), useOutput, forceRealise); Path path = maybeUseOutput(fixStoreOrStatePath(*i), useOutput, forceRealise);
if (query == qRequisites) store->storePathRequisites(path, includeOutputs, paths, false); if (query == qRequisites) store->storePathRequisites(path, includeOutputs, paths, true, false);
else if (query == qRequisitesState) store->storePathStateRequisitesOnly(path, includeOutputs, paths); else if (query == qRequisitesState) store->storePathRequisites(path, includeOutputs, paths, false, true);
else if (query == qRequisitesFull) store->storePathRequisites(path, includeOutputs, paths, true); else if (query == qRequisitesFull) store->storePathRequisites(path, includeOutputs, paths, true, true);
else if (query == qReferences) store->queryReferences(path, paths); else if (query == qReferences) store->queryReferences(path, paths);
else if (query == qStateReferences) store->queryStateReferences(path, paths); else if (query == qStateReferences) store->queryStateReferences(path, paths);
else if (query == qReferrers) store->queryReferrers(path, paths); else if (query == qReferrers) store->queryReferrers(path, paths);
else if (query == qStateReferrers) store->queryStateReferrers(path, paths); else if (query == qStateReferrers) store->queryStateReferrers(path, paths);
else if (query == qReferrersClosure) computeFSClosure(path, paths, false, true); else if (query == qReferrersClosure) computeFSClosure(path, paths, true, false, true);
else if (query == qReferrersClosureWithState) computeFSClosure(path, paths, true, true); else if (query == qReferrersClosureWithState) computeFSClosure(path, paths, true, true, true);
} }
Paths sorted = topoSortPaths(paths); Paths sorted = topoSortPaths(paths);
for (Paths::reverse_iterator i = sorted.rbegin(); for (Paths::reverse_iterator i = sorted.rbegin();