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

Almost finished the identifier/user/multiple-derivations mod

This commit is contained in:
Wouter den Breejen 2007-06-12 21:01:55 +00:00
parent b909d57f5d
commit 76f5c8ba07
6 changed files with 50 additions and 13 deletions

View file

@ -2480,6 +2480,8 @@ void LocalStore::buildDerivations(const PathSet & drvPaths)
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;

View file

@ -57,6 +57,7 @@ struct DerivationStateOutput
{
}
//TODO add const ??
DerivationStateOutput(Path statepath, string componentHash, string hashAlgo, string hash, string stateIdentifier, string enabled, string shared, string synchronization, string createDirsBeforeInstall, string runtimeStateParamters, string username, bool check=true)
{
if(check){

View file

@ -406,27 +406,42 @@ void setDeriver(const Transaction & txn, const Path & storePath, const Path & de
if (!isRealisablePath(txn, storePath))
throw Error(format("path `%1%' is not valid") % storePath);
Derivation drv = derivationFromPath(deriver); //Error if its a state component
Derivation drv = derivationFromPath(deriver); //Redirect if its a state component
if (drv.outputs.size() != 0)
throw Error(format("path `%1%' is a state Path and its derivers need to be set by setDerivers") % storePath);
addStateDeriver(txn, storePath, deriver); //TODO remove store->
else
nixDB.setString(txn, dbDerivers, storePath, deriver);
}
void setDerivers(const Transaction & txn, const Path & storePath, const PathSet & derivers)
void addStateDeriver(const Transaction & txn, const Path & storePath, const Path & deriver)
{
printMsg(lvlError, format("Adding State Derivers into DB %1%") % deriver);
assertStorePath(storePath);
if (deriver == "") return;
assertStorePath(deriver);
if (!isRealisablePath(txn, storePath))
throw Error(format("path `%1%' is not valid") % storePath);
Derivation drv = derivationFromPath(deriver);
string identifier = drv.stateOutputs.find("state")->second.stateIdentifier;
string user = drv.stateOutputs.find("state")->second.username;
PathSet currentDerivers = queryDerivers(txn, storePath, identifier, user);
PathSet updatedDerivers = mergeNewDerivationIntoList(storePath, deriver, currentDerivers, true);
Strings data;
for (PathSet::iterator i = derivers.begin(); i != derivers.end(); ++i){
for (PathSet::iterator i = updatedDerivers.begin(); i != updatedDerivers.end(); ++i){
string deriver = *i;
//TODO Remove obsolete check
assertStorePath(deriver);
Derivation drv = derivationFromPath(deriver);
if (drv.outputs.size() == 0) //Error if its not a state component
throw Error(format("path `%1%' is a NOT state Path at setDerivers") % storePath);
throw Error(format("path `%1%' is a NOT state Path at addStateDeriver") % storePath);
//TODO Remove obsolete check
data.push_back(deriver);
}
@ -440,7 +455,14 @@ Path queryDeriver(const Transaction & txn, const Path & storePath)
throw Error(format("path `%1%' is not valid") % storePath);
Path deriver;
if (nixDB.queryString(txn, dbDerivers, storePath, deriver))
bool b = nixDB.queryString(txn, dbDerivers, storePath, deriver);
Derivation drv = derivationFromPath(deriver); //Redirect if its a state component
if (drv.outputs.size() != 0)
throw Error(format("This deriver `%1%' is a state deriver, u should use queryDerivers instead of queryDeriver") % deriver);
if (b)
return deriver;
else
return "";
@ -474,9 +496,6 @@ PathSet queryDerivers(const Transaction & txn, const Path & storePath, const str
filtereddata.insert(derivationpath);
}
if(filtereddata.size() == 0)
throw Error(format("There are no matching derivations with identifier %2% and user %3% for %1%") % storePath % identifier % user);
return filtereddata;
}
@ -1255,7 +1274,7 @@ PathSet LocalStore::getStateReferencesClosure(const Path & path)
//Merges a new .... into the list TODO
//This is all about one store path
//We assume newdrv is the newest
PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv, const PathSet drvs)
PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv, const PathSet drvs, bool deleteDrvs)
{
PathSet newdrvs;
@ -1272,6 +1291,12 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
if( !(identifier == getIdentifier && getUser == user) ) //only insert if it doenst already exist
newdrvs.insert(drv);
else{
if(deleteDrvs){
printMsg(lvlError, format("Deleting decrepated state derivation: %1%") % drv);
deletePath(drv); //Deletes the DRV from DISK!
}
}
}
newdrvs.insert(newdrv);
@ -1282,6 +1307,9 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
//TODO add mergeNewDerivationIntoList
void updateAllStateDerivations()
{
//call AddStateDerivation !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/*
Transaction txn(nixDB);

View file

@ -177,6 +177,12 @@ void deletePathWrapped(const Path & path,
unsigned long long & bytesFreed);
void deletePathWrapped(const Path & path);
/* TODO */
void addStateDeriver(const Transaction & txn, const Path & storePath, const Path & deriver);
/* TODO */
PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv, const PathSet drvs, bool deleteDrvs = false);
}

View file

@ -60,9 +60,9 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
executeAndPrintShellCommand("mkdir -p " + repos, "mkdir");
if(IsDirectory(repos))
executeAndPrintShellCommand(svnadminbin + " create " + repos, "svnadmin"); //TODO create as nixbld.nixbld chmod 700... can you still commit than ??
printMsg(lvlError, format("Repos %1% already exists, so we use that repository") % repos);
else
printMsg(lvlError, format("Repos %1% already exists, so we use that repository") % repos);
executeAndPrintShellCommand(svnadminbin + " create " + repos, "svnadmin"); //TODO create as nixbld.nixbld chmod 700... can you still commit than ??
if(d.type == "interval"){
intervalPaths.insert(statePath);