From 235c91dd7fba39450988167c7ec34715fa60f151 Mon Sep 17 00:00:00 2001 From: Wouter den Breejen Date: Tue, 19 Jun 2007 15:23:00 +0000 Subject: [PATCH] State paths can now be scanned and queryed (references), referres still need to be added --- src/libstore/build.cc | 25 +++++++++++++++---------- src/libstore/local-store.cc | 29 +++++++++++++++++++++-------- src/libstore/local-store.hh | 6 ++++-- src/libstore/remote-store.cc | 6 ------ src/libstore/remote-store.hh | 2 -- src/libstore/store-api.hh | 3 --- 6 files changed, 40 insertions(+), 31 deletions(-) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 0ff560fcc..0c3f4b25a 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -775,7 +775,6 @@ void DerivationGoal::haveDerivation() //Just before we build the drvs, we already put in the database which component path is a state component path printMsg(lvlError, format("updateAllStateDerivations %1%") % drvPath); - store->registerMaybeStatePath(drvPath); /* If they are all valid, then we're done. */ if (invalidOutputs.size() == 0) { @@ -1745,12 +1744,20 @@ void DerivationGoal::computeClosure() PathSet(), drvPath); } - - //TODO COMMENT + + /* + * TODO COMMENT + * + * + * + * + */ for (DerivationOutputs::iterator i = drv.outputs.begin(); i != drv.outputs.end(); ++i) { + Path path = i->second.path; + /* For this state-output path, find the references to other paths contained in it. * Get the state paths (instead of out paths) from all components, and then call * scanForStateReferences(). @@ -1759,22 +1766,20 @@ void DerivationGoal::computeClosure() for (PathSet::const_iterator i = allPaths.begin(); i != allPaths.end(); i++){ Path componentPath = *i; - printMsg(lvlError, format("COMP: %1%") % (*i)); - - if(store->isStateComponent(componentPath)){ + //printMsg(lvlError, format("COMP: %1%") % (*i)); + if(isStateComponentTxn(txn, componentPath)){ printMsg(lvlError, format("COMP-STATE: %1%") % (*i)); - - PathSet stateRefs = queryDerivers(noTxn, componentPath ,"*",getCallingUserName()); + PathSet stateRefs = queryDeriversStatePath(txn, componentPath ,"*",getCallingUserName()); allStatePaths = mergePathSets(stateRefs, allStatePaths); } } PathSet stateReferences = scanForStateReferences(path, allStatePaths); for (PathSet::const_iterator i = allStatePaths.begin(); i != allStatePaths.end(); i++){ - printMsg(lvlError, format("allStatePaths: %1%") % (*i)); + debug(format("all possible StatePaths: %1%") % (*i)); } for (PathSet::const_iterator i = stateReferences.begin(); i != stateReferences.end(); i++){ - printMsg(lvlError, format("stateReferences: %1%") % (*i)); + debug(format("state References scanned: %1%") % (*i)); } allStateReferences[path] = stateReferences; diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index b4f3b67c6..ff08c683e 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -485,18 +485,17 @@ void addStateDeriver(const Transaction & txn, const Path & storePath, const Path } //TODO Add and .. -bool isStateComponent(const Path & storePath) +bool isStateComponentTxn(const Transaction & txn, const Path & storePath) { - store->isValidPath(storePath); - string deriver; - + isValidPathTxn(txn, storePath); + string data; - return nixDB.queryString(noTxn, dbStateInfo, storePath, data); + return nixDB.queryString(txn, dbStateInfo, storePath, data); } bool LocalStore::isStateComponent(const Path & storePath) { - return nix::isStateComponent(storePath); + return nix::isStateComponentTxn(noTxn, storePath); } //TODO Add and .. @@ -564,6 +563,18 @@ PathSet queryDerivers(const Transaction & txn, const Path & storePath, const str return filtereddata; } +//TODO Wrapper around converting the drvPath to the statePath +PathSet queryDeriversStatePath(const Transaction & txn, const Path & storePath, const string & identifier, const string & user) +{ + PathSet drvs = queryDerivers(txn, storePath, identifier, user); + PathSet statePaths; + for (PathSet::const_iterator i = drvs.begin(); i != drvs.end(); i++){ + Derivation drv = derivationFromPath((*i)); + statePaths.insert(drv.stateOutputs.find("state")->second.statepath); + } + return statePaths; +} + const int substituteVersion = 2; @@ -1336,7 +1347,8 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv, if(identifier == getIdentifier && getUser == user) //only insert if it doenst already exist { - if(deleteDrvs){ + //We also check if it's NOT exactly the same drvpath + if(drv != newdrv && deleteDrvs){ printMsg(lvlTalkative, format("Deleting decrepated state derivation: %1% with identifier %2% and user %3%") % drv % identifier % user); deletePath(drv); //Deletes the DRV from DISK! } @@ -1352,6 +1364,7 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv, /* We register in this database which _component_ paths are state paths * This does not mean these paths are already valid!, you should look in derivivers for that */ +/* void registerMaybeStatePath(const Path & drvPath) { if(!isStateDrv(drvPath)) @@ -1370,7 +1383,7 @@ void LocalStore::registerMaybeStatePath(const Path & drvPath) { nix::registerMaybeStatePath(drvPath); } - +*/ /* Upgrade from schema 1 (Nix <= 0.7) to schema 2 (Nix >= 0.8). */ static void upgradeStore07() diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index 17c50f2ab..09194c32c 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -82,8 +82,6 @@ public: vector getStatePathsInterval(const PathSet & statePaths); - void registerMaybeStatePath(const Path & drvPath); - bool isStateComponent(const Path & path); bool isStateDrv(const Path & drvpath); @@ -159,6 +157,9 @@ Path queryDeriver(const Transaction & txn, const Path & path); deriver has been set. */ PathSet queryDerivers(const Transaction & txn, const Path & storePath, const string & identifier, const string & user); +/* TODO */ +PathSet queryDeriversStatePath(const Transaction & txn, const Path & storePath, const string & identifier, const string & user); + /* Delete a value from the nixStore directory. */ void deleteFromStore(const Path & path, unsigned long long & bytesFreed); @@ -188,6 +189,7 @@ void addStateDeriver(const Transaction & txn, const Path & storePath, const Path /* TODO */ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv, const PathSet drvs, bool deleteDrvs = false); +bool isStateComponentTxn(const Transaction & txn, const Path & path); } diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index cd3e955e7..3cdab7661 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -402,12 +402,6 @@ vector RemoteStore::getStatePathsInterval(const PathSet & statePaths) return intervals; } -//TODO -void RemoteStore::registerMaybeStatePath(const Path & drvPath) -{ - -} - bool RemoteStore::isStateComponent(const Path & path) { return false; diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh index a8dbe8b77..520df21af 100644 --- a/src/libstore/remote-store.hh +++ b/src/libstore/remote-store.hh @@ -70,8 +70,6 @@ public: vector getStatePathsInterval(const PathSet & statePaths); - void registerMaybeStatePath(const Path & drvPath); - bool isStateComponent(const Path & path); bool isStateDrv(const Path & drvpath); diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 82ba2212a..77959a008 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -192,9 +192,6 @@ public: /* TODO */ virtual vector getStatePathsInterval(const PathSet & statePaths) = 0; - /* TODO */ - virtual void registerMaybeStatePath(const Path & drvPath) = 0; - /* TODO */ virtual bool isStateComponent(const Path & path) = 0;