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

Fixed backwards compatible hack & added state creation call after build

This commit is contained in:
Wouter den Breejen 2007-05-22 13:19:27 +00:00
parent 73995157e3
commit 86b053dd80
5 changed files with 67 additions and 16 deletions

View file

@ -1377,14 +1377,11 @@ void DerivationGoal::startBuilder()
tmpDir = createTempDir(); tmpDir = createTempDir();
/* Create the state directory where the component can store it's state files place */ /* Create the state directory where the component can store it's state files place */
//TODO //printMsg(lvlError, format("STATE: `%1%'") % );
//We only create state dirs when state is enabled and when the dirs need to be created before the installation
//TODO include addDirsBefore ... if(drv.stateOutputs.size() != 0)
//if(enableState){ ... if(drv.stateOutputs.find("state")->second.getCreateDirsBeforeInstall())
//stateDir = createStateDirs(drv.stateOutputDirs, drv.stateOutputs); createStateDirs(drv.stateOutputDirs, drv.stateOutputs);
//}
//TODO create the startupscript
/* For convenience, set an environment pointing to the top build /* For convenience, set an environment pointing to the top build
directory. */ directory. */
@ -1616,6 +1613,11 @@ void DerivationGoal::computeClosure()
map<Path, PathSet> allReferences; map<Path, PathSet> allReferences;
map<Path, Hash> contentHashes; map<Path, Hash> contentHashes;
//We create state dirs only when state is enabled and when the dirs need to be created after the installation
if(drv.stateOutputs.size() != 0)
if(!drv.stateOutputs.find("state")->second.getCreateDirsBeforeInstall())
createStateDirs(drv.stateOutputDirs, drv.stateOutputs);
/* Check whether the output paths were created, and grep each /* Check whether the output paths were created, and grep each
output path to determine what other paths it references. Also make all output path to determine what other paths it references. Also make all
output paths read-only. */ output paths read-only. */

View file

@ -10,15 +10,14 @@ Derive | ATermList ATermList ATermList ATermList ATermList string string ATermLi
| string string string | ATerm | DerivationStateOutputDir | | string string string | ATerm | DerivationStateOutputDir |
#We use DeriveWithOutState to create derivations that dont use state, and thus dont have the stateDerivationStateOutput and DerivationStateOutputDir in their derivation #We use DeriveWithOutState to create derivations that dont use state, and thus dont have the stateDerivationStateOutput and DerivationStateOutputDir in their derivation
#Ive put this in because eelco requested it, and its easy to stay backwards compatible, but ultimately I thinks that it should be removed to prevent confusion & duplication #Ive put this in because eelco requested it, and its easy to stay backwards compatible, but ultimately I think that it should be removed to prevent confusion & duplication
#The function will be called matchDerivateWithOutState, but it will match the Derive term to remain backwards compatible
#!!!!!!!!Change the string "DeriveWithOutState" in derivations.ast-def.cc to "Derive" Derive | ATermList ATermList ATermList string string ATermList ATermList | ATerm | DeriveWithOutState
#TODO, make this automatic..
DeriveWithOutState | ATermList ATermList ATermList string string ATermList ATermList | ATerm |
| string string | ATerm | EnvBindingWithOutState | | string string | ATerm | EnvBindingWithOutState |
| string ATermList | ATerm | DerivationInputWithOutState | | string ATermList | ATerm | DerivationInputWithOutState |
| string string string string | ATerm | DerivationOutputWithOutState | | string string string string | ATerm | DerivationOutputWithOutState |
Closure | ATermList ATermList | ATerm | OldClosure | Closure | ATermList ATermList | ATerm | OldClosure |
| string ATermList | ATerm | OldClosureElem | | string ATermList | ATerm | OldClosureElem |

View file

@ -4,6 +4,7 @@
typedef struct _ATerm * ATerm; typedef struct _ATerm * ATerm;
#include "hash.hh" #include "hash.hh"
#include "util.hh"
#include <map> #include <map>
@ -55,6 +56,14 @@ struct DerivationStateOutput
this->synchronization = synchronization; this->synchronization = synchronization;
this->createDirsBeforeInstall = createDirsBeforeInstall; this->createDirsBeforeInstall = createDirsBeforeInstall;
} }
bool getEnabled(){
return string2bool(enabled);
}
bool getCreateDirsBeforeInstall(){
return string2bool(createDirsBeforeInstall);
}
}; };
struct DerivationStateOutputDir struct DerivationStateOutputDir

View file

@ -974,5 +974,38 @@ string bool2string(const bool b)
return "false"; return "false";
} }
bool string2bool(const string & s)
{
if(s == "true")
return true;
else if(s == "false")
return false;
else{
throw Error(format("cannot convert string: `%1%' to bool") % s);
quickExit(1);
return false;
}
}
string triml(const string & s) {
string news = s;
int pos(0);
for ( ; news[pos]==' ' || news[pos]=='\t'; ++pos );
news.erase(0, pos);
return news;
}
string trimr(const string & s) {
string news = s;
int pos(news.size());
for ( ; pos && news[pos-1]==' ' || news[pos]=='\t'; --pos );
news.erase(pos, news.size()-pos);
return news;
}
string trim(const string & s) {
return triml(trimr(s));
}
} }

View file

@ -279,10 +279,18 @@ bool statusOk(int status);
string int2String(int n); string int2String(int n);
bool string2Int(const string & s, int & n); bool string2Int(const string & s, int & n);
/* Parse a bool to a string */ /* Parse a bool to a string and back */
string bool2string(const bool b); string bool2string(const bool b);
bool string2bool(const string & s);
//return modified string s with spaces trimmed from left
string triml(const string & s);
//return modified string s with spaces trimmed from right
string trimr(const string & s);
//return modified string s with spaces trimmed from edges
string trim(const string & s);
} }
#endif /* !__UTIL_H */ #endif /* !__UTIL_H */