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

Nix now understands the difference between runtime-state-components and non-runtime-state-compontens. Components and Derivations are now properly (re)build/derived (or not) when necessary.

This commit is contained in:
Wouter den Breejen 2007-06-08 16:00:55 +00:00
parent fd2b8271e4
commit 267ccc589d
8 changed files with 135 additions and 66 deletions

View file

@ -49,15 +49,19 @@ struct DerivationStateOutput
string createDirsBeforeInstall; //if true: creates state dirs before installation
string runtimeStateParamters; //if not empty: these are the runtime parameters where state can be found (you can use $statepath here)
DerivationStateOutput()
{
}
DerivationStateOutput(Path statepath, string hashAlgo, string hash, string stateIdentifier, string enabled, string shared, string synchronization, string createDirsBeforeInstall, string runtimeStateParamters)
DerivationStateOutput(Path statepath, string hashAlgo, string hash, string stateIdentifier, string enabled, string shared, string synchronization, string createDirsBeforeInstall, string runtimeStateParamters, bool check=true)
{
if(shared != "none" && shared != "full" && shared != "group")
throw Error(format("shared '%1%' is not a correct type") % shared);
if(synchronization != "none" && synchronization != "exclusive-lock" && synchronization != "recursive-exclusive-lock")
throw Error(format("synchronization '%1%' is not a correct type") % synchronization);
if(check){
if(shared != "none" && shared != "full" && shared != "group")
throw Error(format("shared '%1%' is not a correct type") % shared);
if(synchronization != "none" && synchronization != "exclusive-lock" && synchronization != "recursive-exclusive-lock")
throw Error(format("synchronization '%1%' is not a correct type") % synchronization);
}
//TODO
//commitReferences
@ -81,6 +85,21 @@ struct DerivationStateOutput
bool getCreateDirsBeforeInstall(){
return string2bool(createDirsBeforeInstall);
}
/*
* This sets all the paramters to "" to ensure they're not taken into account for the hash calculation in primops.cc
*/
void clearAllRuntimeParamters(){
this->statepath = "";
//this->hashAlgo; //Clear this one?
//this->hash; //Clear this one?
//this->stateIdentifier;
this->enabled = "";
this->shared = "";
this->synchronization = "";
this->createDirsBeforeInstall = "";
this->runtimeStateParamters = "";
}
};
struct DerivationStateOutputDir

View file

@ -1282,7 +1282,7 @@ void updateAllStateDerivations()
for (Strings::iterator i = unique_paths.begin(); i != unique_paths.end(); ++i)
{
string path = *i;
printMsg(lvlError, format("Unique: %1%") % path);
//printMsg(lvlError, format("Unique: %1%") % path);
store->updateStateDerivation(txn, path); //TODO replace store->
}

View file

@ -18,21 +18,14 @@ namespace nix {
void updatedStateDerivation(Path storePath)
{
//Remove the old .svn folders
//We dont remove the old .svn folders
//New repostorys are created by createStateDirs
//Create new repositorys, or use existing...
//createStateDirs already does that ...
printMsg(lvlError, format("Resetting state drv settings like repositorys"));
//Create a repository for this state location
//string repos = makeStateReposPath("stateOutput:staterepospath", stateDir, thisdir, drvName, stateIdentifier);
//executeAndPrintShellCommand("mkdir -p " + repos, "mkdir");
//executeAndPrintShellCommand(svnadminbin + " create " + repos, "svnadmin"); //TODO create as nixbld.nixbld chmod 700... can you still commit than ??
//createStateDirs
//
}
void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const DerivationStateOutputs & stateOutputs, const StringPairs & env)
@ -47,7 +40,7 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
PathSet intervalPaths;
//TODO check if we can create stata and staterepos dirs
//TODO check if we can create state and staterepos dirs
for (DerivationStateOutputDirs::const_reverse_iterator i = stateOutputDirs.rbegin(); i != stateOutputDirs.rend(); ++i){
DerivationStateOutputDir d = i->second;
@ -56,31 +49,33 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
string fullstatedir = stateDir + "/" + thisdir;
Path statePath = fullstatedir; //TODO call coerce function
//TODO REPLACE TRUE INTO VAR OF CREATEING DIRS BEFORE OR AFTER INSTALL
//Check if and how this dir needs to be versioned
if(d.type == "none"){
if(true){
executeAndPrintShellCommand("mkdir -p " + fullstatedir, "mkdir");
}
executeAndPrintShellCommand("mkdir -p " + fullstatedir, "mkdir");
continue;
}
//Create a repository for this state location
string repos = makeStateReposPath("stateOutput:staterepospath", stateDir, thisdir, drvName, stateIdentifier);
executeAndPrintShellCommand("mkdir -p " + repos, "mkdir");
executeAndPrintShellCommand(svnadminbin + " create " + repos, "svnadmin"); //TODO create as nixbld.nixbld chmod 700... can you still commit than ??
// //TODO Check if repos already exitst?
if(IsDirectory(repos))
executeAndPrintShellCommand(svnadminbin + " create " + repos, "svnadmin"); //TODO create as nixbld.nixbld chmod 700... can you still commit than ??
else
printMsg(lvlError, format("Repos %1% already exists, so we use that repository") % repos);
if(d.type == "interval"){
intervalPaths.insert(statePath);
}
//TODO REPLACE TRUE INTO VAR OF CREATEING DIRS BEFORE OR AFTER INSTALL
if(true){
printMsg(lvlError, format("Adding state subdir: %1% to %2% from repository %3%") % thisdir % fullstatedir % repos);
printMsg(lvlError, format("Adding state subdir: %1% to %2% from repository %3%") % thisdir % fullstatedir % repos);
if(IsDirectory(fullstatedir + "/.svn/")){
string checkoutcommand = svnbin + " checkout file://" + repos + " " + fullstatedir;
executeAndPrintShellCommand(checkoutcommand, "svn"); //TODO checkout as user
executeAndPrintShellCommand(checkoutcommand, "svn"); //TODO checkout as user
}
else
printMsg(lvlError, format("Statedir %1% already exists, so dont check out its repository again") % fullstatedir);
}
//Initialize the counters for the statePaths that have an interval to 0