diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 0baa1759f..227aa6d67 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -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, diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index fd0dcaef9..f43c138fc 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -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); diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 666e0cc74..635e56dd0 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -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()); diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index d307339a0..279ddeace 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -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); diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index 905db7ac1..f92149aeb 100644 --- a/src/libstore/misc.cc +++ b/src/libstore/misc.cc @@ -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){ diff --git a/src/libstore/misc.hh b/src/libstore/misc.hh index 1af328e36..1cc713fc6 100644 --- a/src/libstore/misc.hh +++ b/src/libstore/misc.hh @@ -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 diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index ee9ac52c9..7a2ec505b 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -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) { } diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh index 7afaefcbf..6de3376f9 100644 --- a/src/libstore/remote-store.hh +++ b/src/libstore/remote-store.hh @@ -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); diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 0c2385b24..97312d22d 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -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; diff --git a/src/nix-state/nix-state.cc b/src/nix-state/nix-state.cc index d01c60629..86bc694dc 100644 --- a/src/nix-state/nix-state.cc +++ b/src/nix-state/nix-state.cc @@ -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; diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index 04b6237c5..3d603dbf0 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -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();