From 802d7f40bd4f2283c5fd9e382dc795374934053c Mon Sep 17 00:00:00 2001 From: Wouter den Breejen Date: Mon, 21 May 2007 21:56:34 +0000 Subject: [PATCH] Small fix --- src/libexpr/primops.cc | 12 +++++++----- src/libstore/derivations-ast.def | 2 +- src/libstore/derivations.cc | 8 +++++--- src/libstore/derivations.hh | 6 +++--- src/libutil/util.cc | 8 ++++++++ src/libutil/util.hh | 2 ++ 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 63dc5ccd0..2bc21b286 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -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); diff --git a/src/libstore/derivations-ast.def b/src/libstore/derivations-ast.def index 603795693..0333d88ec 100644 --- a/src/libstore/derivations-ast.def +++ b/src/libstore/derivations-ast.def @@ -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 | diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index 2170b4ad5..308494f27 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -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; diff --git a/src/libstore/derivations.hh b/src/libstore/derivations.hh index 959c92dca..f8071bfc7 100644 --- a/src/libstore/derivations.hh +++ b/src/libstore/derivations.hh @@ -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; } }; diff --git a/src/libutil/util.cc b/src/libutil/util.cc index ec722f757..7c8354846 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -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"; +} + } diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 4d284ccfd..0af444c6b 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -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); }