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

Small fix

This commit is contained in:
Wouter den Breejen 2007-05-21 21:56:34 +00:00
parent 5cac336820
commit 802d7f40bd
6 changed files with 26 additions and 12 deletions

View file

@ -389,6 +389,7 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
string shareState = "none";
string syncState = "all";
string stateIndentifier = "";
bool createDirsBeforeInstall = false;
for (ATermMap::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
string key = aterm2String(i->key);
@ -462,7 +463,8 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
else if(key == "synchronization") { string s = coerceToString(state, value, context, true); syncState = s; }
else if(key == "enableState") { bool b = evalBool(state, value); disableState = true; }
else if(key == "indentifier"){ string s = coerceToString(state, value, context, true); stateIndentifier = s; }
else if(key == "createDirsBeforeInstall"){ bool b = evalBool(state, value); createDirsBeforeInstall = b; }
/* All other attributes are passed to the builder through
the environment. */
else {
@ -559,10 +561,10 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
Path stateOutPath = makeStatePath("stateOutput:statepath", statehash, drvName); //
drv.env["statepath"] = stateOutPath;
string enableStateS = "false";
if(enableState && disableState == false)
enableStateS = "true";
drv.stateOutputs["state"] = DerivationStateOutput(stateOutPath, outputHashAlgo, outputHash, enableStateS, shareState, syncState);
string enableStateS = bool2string(enableState && disableState);
string createDirsBeforeInstallS = bool2string(createDirsBeforeInstall);
drv.stateOutputs["state"] = DerivationStateOutput(stateOutPath, outputHashAlgo, outputHash, enableStateS, shareState, syncState, createDirsBeforeInstallS);
/* Write the resulting term into the Nix store directory. */
Path drvPath = writeDerivation(drv, drvName);

View file

@ -7,7 +7,7 @@ Derive | ATermList ATermList ATermList ATermList ATermList string string ATermLi
| string string | ATerm | EnvBinding |
| string ATermList | ATerm | DerivationInput |
| string string string string | ATerm | DerivationOutput |
| string string string string string string string | ATerm | DerivationStateOutput |
| string string string string string string string string | ATerm | DerivationStateOutput |
| string string string | ATerm | DerivationStateOutputDir |
Closure | ATermList ATermList | ATerm | OldClosure |

View file

@ -85,8 +85,8 @@ Derivation parseDerivation(ATerm t)
//parse state part
for (ATermIterator i(stateOuts); i; ++i) {
ATerm id, statepath, hashAlgo, hash, enabled, shared, synchronization;
if (!matchDerivationStateOutput(*i, id, statepath, hashAlgo, hash, enabled, shared, synchronization))
ATerm id, statepath, hashAlgo, hash, enabled, shared, synchronization, createDirsBeforeInstall;
if (!matchDerivationStateOutput(*i, id, statepath, hashAlgo, hash, enabled, shared, synchronization, createDirsBeforeInstall))
throwBadDrv(t);
DerivationStateOutput stateOut;
stateOut.statepath = aterm2String(statepath);
@ -96,6 +96,7 @@ Derivation parseDerivation(ATerm t)
stateOut.enabled = aterm2String(enabled);
stateOut.shared = aterm2String(shared);
stateOut.synchronization = aterm2String(synchronization);
stateOut.createDirsBeforeInstall = aterm2String(createDirsBeforeInstall);
drv.stateOutputs[aterm2String(id)] = stateOut;
}
@ -168,7 +169,8 @@ ATerm unparseDerivation(const Derivation & drv)
toATerm(i->second.hash),
toATerm(i->second.enabled),
toATerm(i->second.shared),
toATerm(i->second.synchronization)
toATerm(i->second.synchronization),
toATerm(i->second.createDirsBeforeInstall)
));
ATermList stateOutputDirs = ATempty;

View file

@ -41,11 +41,11 @@ struct DerivationStateOutput
string enabled;
string shared;
string synchronization;
string createStateDirsBeforeInstall;
string createDirsBeforeInstall;
DerivationStateOutput()
{
}
DerivationStateOutput(Path statepath, string hashAlgo, string hash, string enabled, string shared, string synchronization, string createStateDirsBeforeInstall)
DerivationStateOutput(Path statepath, string hashAlgo, string hash, string enabled, string shared, string synchronization, string createDirsBeforeInstall)
{
this->statepath = statepath;
this->hashAlgo = hashAlgo;
@ -53,7 +53,7 @@ struct DerivationStateOutput
this->enabled = enabled;
this->shared = shared;
this->synchronization = synchronization;
this->createStateDirsBeforeInstall = createStateDirsBeforeInstall;
this->createDirsBeforeInstall = createDirsBeforeInstall;
}
};

View file

@ -966,5 +966,13 @@ bool string2Int(const string & s, int & n)
return str && str.get() == EOF;
}
string bool2string(const bool b)
{
if(b == true)
return "true";
else
return "false";
}
}

View file

@ -279,6 +279,8 @@ bool statusOk(int status);
string int2String(int n);
bool string2Int(const string & s, int & n);
/* Parse a bool to a string */
string bool2string(const bool b);
}