1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-26 20:20:58 +01:00

Before adjusting getStateReferencesClosure_

This commit is contained in:
Wouter den Breejen 2007-06-13 15:18:57 +00:00
parent bc0af4449a
commit 184443d18d
7 changed files with 144 additions and 43 deletions

View file

@ -773,6 +773,11 @@ void DerivationGoal::haveDerivation()
/* Check what outputs paths are not already valid. */
PathSet invalidOutputs = checkPathValidity(false);
//Just before we build, we resolve the multiple derivations linked to one store path issue, by choosing the latest derivation
printMsg(lvlError, format("updateAllStateDerivations %1%") % drvPath);
//addStateDeriver(....); //only on succesfull! build
/* If they are all valid, then we're done. */
if (invalidOutputs.size() == 0) {
amDone(ecSuccess);
@ -1678,13 +1683,17 @@ void DerivationGoal::computeClosure()
% path % algo % printHash(h) % printHash(h2));
}
/* Get rid of all weird permissions. */
canonicalisePathMetaData(path);
/* Get rid of all weird permissions. */
canonicalisePathMetaData(path);
/* For this output path, find the references to other paths contained
in it. */
/* For this output path, find the references to other paths contained in it. */
PathSet references = scanForReferences(path, allPaths);
/* For this state-output path, find the references to other paths contained in it. */
Path statePath = drv.stateOutputs.find("state")->second.statepath;
PathSet state_references = scanForReferences(statePath, allPaths);
references = mergePathSets(references, state_references);
/* For debugging, print out the referenced and unreferenced
paths. */
for (PathSet::iterator i = inputPaths.begin();
@ -2479,13 +2488,7 @@ void LocalStore::buildDerivations(const PathSet & drvPaths)
startNest(nest, lvlDebug,
format("building %1%") % showPaths(drvPaths));
//Just before we build, we resolve the multiple derivations linked to one store path issue, by choosing the latest derivation
printMsg(lvlError, format("updateAllStateDerivations %1%") % showPaths(drvPaths));
store->updateAllStateDerivations();
Worker worker;
Goals goals;
for (PathSet::const_iterator i = drvPaths.begin(); i != drvPaths.end(); ++i){
goals.insert(worker.makeDerivationGoal(*i));

View file

@ -408,7 +408,7 @@ void setDeriver(const Transaction & txn, const Path & storePath, const Path & de
Derivation drv = derivationFromPath(deriver); //Redirect if its a state component
if (drv.outputs.size() != 0)
addStateDeriver(txn, storePath, deriver); //TODO remove store->
addStateDeriver(txn, storePath, deriver);
else
nixDB.setString(txn, dbDerivers, storePath, deriver);
}
@ -474,14 +474,14 @@ PathSet queryDerivers(const Transaction & txn, const Path & storePath, const str
if (!isRealisablePath(txn, storePath))
throw Error(format("path `%1%' is not valid") % storePath);
if(identifier == "" || user == "")
throw Error(format("The identifer or user argument is empty, use queryDeriver(...) for non-state components"));
if(user == "")
throw Error(format("The user argument is empty, use queryDeriver(...) for non-state components"));
Strings alldata;
nixDB.queryStrings(txn, dbDerivers, storePath, alldata); //get all current derivers
PathSet filtereddata;
for (Strings::iterator i = alldata.begin(); i != alldata.end(); ++i) {
for (Strings::iterator i = alldata.begin(); i != alldata.end(); ++i) { //filter on username and identifier
string derivationpath = (*i);
Derivation drv = derivationFromPath(derivationpath);
@ -496,6 +496,7 @@ PathSet queryDerivers(const Transaction & txn, const Path & storePath, const str
filtereddata.insert(derivationpath);
}
return filtereddata;
}
@ -1244,25 +1245,48 @@ vector<int> LocalStore::getStatePathsInterval(const PathSet & statePaths)
//TODO direct or all recursive parameter
//TODO check if these are state components
PathSet getStateReferencesClosure(const Path & path)
//TODO CHECK FOR DERIVATION INSTEAD OF
PathSet getStateReferencesClosure(const Path & drvpath)
{
PathSet empty;
return getStateReferencesClosure_(drvpath, empty);
}
PathSet getStateReferencesClosure_(const Path & drvpath, PathSet & paths)
{
Transaction txn(nixDB); //TODO should u do a transaction here? ... this might delay the process ...
Strings data;
PathSet paths;
TODODODODOD..........
Paths referencesKeys;
nixDB.queryStrings(txn, dbReferences, path, data);
for (Strings::iterator i = data.begin(); i != data.end(); ++i)
{
//printMsg(lvlError, format("References: `%1%'") % *i);
paths.insert(*i);
string storePath = *i;
bool alreadyExists = false;
for (PathSet::iterator j = paths.begin(); j != paths.end(); ++j) //Get also the references of this dep.
{
string checkPath = *j;
if(storePath == checkPath){
alreadyExists = true;
break;
}
}
if( !alreadyExists ){
printMsg(lvlError, format("References: `%1%'") % storePath);
paths.insert(storePath);
PathSet rec = getStateReferencesClosure_(storePath, paths); //go recursive
//paths = mergePathSets(paths, rec); //merge
}
}
txn.commit();
return paths;
}
PathSet LocalStore::getStateReferencesClosure(const Path & path)
@ -1293,7 +1317,7 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
newdrvs.insert(drv);
else{
if(deleteDrvs){
printMsg(lvlError, format("Deleting decrepated state derivation: %1%") % drv);
printMsg(lvlError, format("Deleting decrepated state derivation: %1% with identifier %2% and user %3%") % drv % identifier % user);
deletePath(drv); //Deletes the DRV from DISK!
}
}
@ -1308,6 +1332,7 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
void updateAllStateDerivations()
{
//call AddStateDerivation !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/*

View file

@ -183,6 +183,9 @@ 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);
/* TODO */
PathSet getStateReferencesClosure_(const Path & drvpath, PathSet & paths);
}