mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
Added backwards compatib. but still something... remains that changes the hashes .... :(
This commit is contained in:
parent
802d7f40bd
commit
09b8b7efbc
4 changed files with 99 additions and 59 deletions
|
|
@ -554,17 +554,20 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
|
||||||
drv.env["out"] = outPath;
|
drv.env["out"] = outPath;
|
||||||
drv.outputs["out"] = DerivationOutput(outPath, outputHashAlgo, outputHash);
|
drv.outputs["out"] = DerivationOutput(outPath, outputHashAlgo, outputHash);
|
||||||
|
|
||||||
/* Add the state path based on the outPath */
|
//only add state when we have to to keep compitibilty with the 'old' format.
|
||||||
string callingUser = "wouterdb"; //TODO: Change into variable
|
if(enableState){
|
||||||
string componentHash = printHash(hashDerivationModulo(state, drv)); //hash of the component path
|
/* Add the state path based on the outPath */
|
||||||
Hash statehash = hashString(htSHA256, stateIndentifier + callingUser + componentHash); //hash of the state path
|
string callingUser = "wouterdb"; //TODO: Change into variable
|
||||||
Path stateOutPath = makeStatePath("stateOutput:statepath", statehash, drvName); //
|
string componentHash = printHash(hashDerivationModulo(state, drv)); //hash of the component path
|
||||||
|
Hash statehash = hashString(htSHA256, stateIndentifier + callingUser + componentHash); //hash of the state path
|
||||||
|
Path stateOutPath = makeStatePath("stateOutput:statepath", statehash, drvName); //
|
||||||
|
|
||||||
drv.env["statepath"] = stateOutPath;
|
drv.env["statepath"] = stateOutPath;
|
||||||
string enableStateS = bool2string(enableState && disableState);
|
string enableStateS = bool2string(enableState && disableState);
|
||||||
string createDirsBeforeInstallS = bool2string(createDirsBeforeInstall);
|
string createDirsBeforeInstallS = bool2string(createDirsBeforeInstall);
|
||||||
|
|
||||||
drv.stateOutputs["state"] = DerivationStateOutput(stateOutPath, outputHashAlgo, outputHash, enableStateS, shareState, syncState, createDirsBeforeInstallS);
|
drv.stateOutputs["state"] = DerivationStateOutput(stateOutPath, outputHashAlgo, outputHash, enableStateS, shareState, syncState, createDirsBeforeInstallS);
|
||||||
|
}
|
||||||
|
|
||||||
/* Write the resulting term into the Nix store directory. */
|
/* Write the resulting term into the Nix store directory. */
|
||||||
Path drvPath = writeDerivation(drv, drvName);
|
Path drvPath = writeDerivation(drv, drvName);
|
||||||
|
|
|
||||||
|
|
@ -1378,7 +1378,11 @@ void DerivationGoal::startBuilder()
|
||||||
|
|
||||||
/* 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
|
//TODO
|
||||||
stateDir = createStateDirs(drv.stateOutputDirs, drv.stateOutputs);
|
|
||||||
|
//TODO include addDirsBefore ...
|
||||||
|
//if(enableState){ ...
|
||||||
|
//stateDir = createStateDirs(drv.stateOutputDirs, drv.stateOutputs);
|
||||||
|
//}
|
||||||
|
|
||||||
//TODO create the startupscript
|
//TODO create the startupscript
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,19 @@ init initDerivationsHelpers
|
||||||
#wouter added 2 ATermList
|
#wouter added 2 ATermList
|
||||||
|
|
||||||
Derive | ATermList ATermList ATermList ATermList ATermList string string ATermList ATermList | ATerm |
|
Derive | ATermList ATermList ATermList ATermList ATermList string string ATermList ATermList | ATerm |
|
||||||
|
|
||||||
| string string | ATerm | EnvBinding |
|
| string string | ATerm | EnvBinding |
|
||||||
| string ATermList | ATerm | DerivationInput |
|
| string ATermList | ATerm | DerivationInput |
|
||||||
| string string string string | ATerm | DerivationOutput |
|
| string string string string | ATerm | DerivationOutput |
|
||||||
| string string string string string string string string | ATerm | DerivationStateOutput |
|
| string string string string string string string string | ATerm | DerivationStateOutput |
|
||||||
| 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
|
||||||
|
#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
|
||||||
|
|
||||||
|
DeriveWithOutState | ATermList ATermList ATermList string string ATermList ATermList | ATerm |
|
||||||
|
| string string | ATerm | EnvBindingWithOutState |
|
||||||
|
| string ATermList | ATerm | DerivationInputWithOutState |
|
||||||
|
| string string string string | ATerm | DerivationOutputWithOutState |
|
||||||
|
|
||||||
Closure | ATermList ATermList | ATerm | OldClosure |
|
Closure | ATermList ATermList | ATerm | OldClosure |
|
||||||
| string ATermList | ATerm | OldClosureElem |
|
| string ATermList | ATerm | OldClosureElem |
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "aterm.hh"
|
#include "aterm.hh"
|
||||||
#include "globals.hh"
|
#include "globals.hh"
|
||||||
|
#include "util.hh"
|
||||||
|
|
||||||
#include "derivations-ast.hh"
|
#include "derivations-ast.hh"
|
||||||
#include "derivations-ast.cc"
|
#include "derivations-ast.cc"
|
||||||
|
|
@ -65,10 +66,15 @@ void throwBadDrv(ATerm t)
|
||||||
Derivation parseDerivation(ATerm t)
|
Derivation parseDerivation(ATerm t)
|
||||||
{
|
{
|
||||||
Derivation drv;
|
Derivation drv;
|
||||||
ATermList outs, stateOuts, stateOutDirs, inDrvs, inSrcs, args, bnds;
|
ATermList outs, inDrvs, inSrcs, args, bnds;
|
||||||
|
ATermList stateOuts = ATempty, stateOutDirs = ATempty;
|
||||||
|
|
||||||
ATerm builder, platform;
|
ATerm builder, platform;
|
||||||
|
|
||||||
if (!matchDerive(t, outs, stateOuts, stateOutDirs, inDrvs, inSrcs, platform, builder, args, bnds))
|
bool withState;
|
||||||
|
if (matchDerive(t, outs, stateOuts, stateOutDirs, inDrvs, inSrcs, platform, builder, args, bnds) ) { withState = true; }
|
||||||
|
else if (matchDeriveWithOutState(t, outs, inDrvs, inSrcs, platform, builder, args, bnds) ) { withState = false; }
|
||||||
|
else
|
||||||
throwBadDrv(t);
|
throwBadDrv(t);
|
||||||
|
|
||||||
for (ATermIterator i(outs); i; ++i) {
|
for (ATermIterator i(outs); i; ++i) {
|
||||||
|
|
@ -83,35 +89,39 @@ Derivation parseDerivation(ATerm t)
|
||||||
drv.outputs[aterm2String(id)] = out;
|
drv.outputs[aterm2String(id)] = out;
|
||||||
}
|
}
|
||||||
|
|
||||||
//parse state part
|
if(withState){
|
||||||
for (ATermIterator i(stateOuts); i; ++i) {
|
//parse state part
|
||||||
ATerm id, statepath, hashAlgo, hash, enabled, shared, synchronization, createDirsBeforeInstall;
|
for (ATermIterator i(stateOuts); i; ++i) {
|
||||||
if (!matchDerivationStateOutput(*i, id, statepath, hashAlgo, hash, enabled, shared, synchronization, createDirsBeforeInstall))
|
ATerm id, statepath, hashAlgo, hash, enabled, shared, synchronization, createDirsBeforeInstall;
|
||||||
throwBadDrv(t);
|
if (!matchDerivationStateOutput(*i, id, statepath, hashAlgo, hash, enabled, shared, synchronization, createDirsBeforeInstall))
|
||||||
DerivationStateOutput stateOut;
|
throwBadDrv(t);
|
||||||
stateOut.statepath = aterm2String(statepath);
|
DerivationStateOutput stateOut;
|
||||||
//checkPath(stateOut.path); //should we check the statpath .... ???
|
stateOut.statepath = aterm2String(statepath);
|
||||||
stateOut.hashAlgo = aterm2String(hashAlgo);
|
//checkPath(stateOut.path); //should we check the statpath .... ???
|
||||||
stateOut.hash = aterm2String(hash);
|
stateOut.hashAlgo = aterm2String(hashAlgo);
|
||||||
stateOut.enabled = aterm2String(enabled);
|
stateOut.hash = aterm2String(hash);
|
||||||
stateOut.shared = aterm2String(shared);
|
stateOut.enabled = aterm2String(enabled);
|
||||||
stateOut.synchronization = aterm2String(synchronization);
|
stateOut.shared = aterm2String(shared);
|
||||||
stateOut.createDirsBeforeInstall = aterm2String(createDirsBeforeInstall);
|
stateOut.synchronization = aterm2String(synchronization);
|
||||||
drv.stateOutputs[aterm2String(id)] = stateOut;
|
stateOut.createDirsBeforeInstall = aterm2String(createDirsBeforeInstall);
|
||||||
}
|
drv.stateOutputs[aterm2String(id)] = stateOut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//parse state dirs part
|
if(withState){
|
||||||
for (ATermIterator i(stateOutDirs); i; ++i) {
|
//parse state dirs part
|
||||||
ATerm id, path, type, interval;
|
for (ATermIterator i(stateOutDirs); i; ++i) {
|
||||||
if (!matchDerivationStateOutputDir(*i, id, /*path,*/ type, interval))
|
ATerm id, path, type, interval;
|
||||||
throwBadDrv(t);
|
if (!matchDerivationStateOutputDir(*i, id, type, interval))
|
||||||
path = id;
|
throwBadDrv(t);
|
||||||
DerivationStateOutputDir stateOutDirs;
|
path = id; //We prevent duplication since the key is also the path
|
||||||
stateOutDirs.path = aterm2String(path);
|
DerivationStateOutputDir stateOutDirs;
|
||||||
stateOutDirs.type = aterm2String(type);
|
stateOutDirs.path = aterm2String(path);
|
||||||
stateOutDirs.interval = aterm2String(interval);
|
stateOutDirs.type = aterm2String(type);
|
||||||
drv.stateOutputDirs[aterm2String(id)] = stateOutDirs;
|
stateOutDirs.interval = aterm2String(interval);
|
||||||
}
|
drv.stateOutputDirs[aterm2String(id)] = stateOutDirs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (ATermIterator i(inDrvs); i; ++i) {
|
for (ATermIterator i(inDrvs); i; ++i) {
|
||||||
ATerm drvPath;
|
ATerm drvPath;
|
||||||
|
|
@ -150,8 +160,7 @@ Derivation parseDerivation(ATerm t)
|
||||||
ATerm unparseDerivation(const Derivation & drv)
|
ATerm unparseDerivation(const Derivation & drv)
|
||||||
{
|
{
|
||||||
ATermList outputs = ATempty;
|
ATermList outputs = ATempty;
|
||||||
for (DerivationOutputs::const_reverse_iterator i = drv.outputs.rbegin();
|
for (DerivationOutputs::const_reverse_iterator i = drv.outputs.rbegin(); i != drv.outputs.rend(); ++i)
|
||||||
i != drv.outputs.rend(); ++i)
|
|
||||||
outputs = ATinsert(outputs,
|
outputs = ATinsert(outputs,
|
||||||
makeDerivationOutput(
|
makeDerivationOutput(
|
||||||
toATerm(i->first),
|
toATerm(i->first),
|
||||||
|
|
@ -159,8 +168,14 @@ ATerm unparseDerivation(const Derivation & drv)
|
||||||
toATerm(i->second.hashAlgo),
|
toATerm(i->second.hashAlgo),
|
||||||
toATerm(i->second.hash)));
|
toATerm(i->second.hash)));
|
||||||
|
|
||||||
|
//decide if we need to add state to the derivation
|
||||||
|
bool createState = false;
|
||||||
|
|
||||||
ATermList stateOutputs = ATempty;
|
ATermList stateOutputs = ATempty;
|
||||||
for (DerivationStateOutputs::const_reverse_iterator i = drv.stateOutputs.rbegin(); i != drv.stateOutputs.rend(); ++i)
|
for (DerivationStateOutputs::const_reverse_iterator i = drv.stateOutputs.rbegin(); i != drv.stateOutputs.rend(); ++i){
|
||||||
|
if(i->second.enabled == "true"){
|
||||||
|
createState = true;
|
||||||
|
}
|
||||||
stateOutputs = ATinsert(stateOutputs,
|
stateOutputs = ATinsert(stateOutputs,
|
||||||
makeDerivationStateOutput(
|
makeDerivationStateOutput(
|
||||||
toATerm(i->first),
|
toATerm(i->first),
|
||||||
|
|
@ -172,19 +187,18 @@ ATerm unparseDerivation(const Derivation & drv)
|
||||||
toATerm(i->second.synchronization),
|
toATerm(i->second.synchronization),
|
||||||
toATerm(i->second.createDirsBeforeInstall)
|
toATerm(i->second.createDirsBeforeInstall)
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
|
||||||
ATermList stateOutputDirs = ATempty;
|
ATermList stateOutputDirs = ATempty;
|
||||||
for (DerivationStateOutputDirs::const_reverse_iterator i = drv.stateOutputDirs.rbegin(); i != drv.stateOutputDirs.rend(); ++i)
|
for (DerivationStateOutputDirs::const_reverse_iterator i = drv.stateOutputDirs.rbegin(); i != drv.stateOutputDirs.rend(); ++i)
|
||||||
stateOutputDirs = ATinsert(stateOutputDirs,
|
stateOutputDirs = ATinsert(stateOutputDirs,
|
||||||
makeDerivationStateOutputDir(
|
makeDerivationStateOutputDir(
|
||||||
toATerm(i->first),
|
toATerm(i->first),
|
||||||
//toATerm(i->second.path),
|
//toATerm(i->second.path), //removed to prevent duplication since the key is also the path
|
||||||
toATerm(i->second.type),
|
toATerm(i->second.type),
|
||||||
toATerm(i->second.interval)
|
toATerm(i->second.interval)
|
||||||
));
|
));
|
||||||
|
|
||||||
//toATermList(i->second.dirs)
|
|
||||||
|
|
||||||
|
|
||||||
ATermList inDrvs = ATempty;
|
ATermList inDrvs = ATempty;
|
||||||
for (DerivationInputs::const_reverse_iterator i = drv.inputDrvs.rbegin();
|
for (DerivationInputs::const_reverse_iterator i = drv.inputDrvs.rbegin();
|
||||||
|
|
@ -207,16 +221,28 @@ ATerm unparseDerivation(const Derivation & drv)
|
||||||
toATerm(i->first),
|
toATerm(i->first),
|
||||||
toATerm(i->second)));
|
toATerm(i->second)));
|
||||||
|
|
||||||
return makeDerive(
|
if(createState){
|
||||||
outputs,
|
return makeDerive(
|
||||||
stateOutputs,
|
outputs,
|
||||||
stateOutputDirs,
|
stateOutputs,
|
||||||
inDrvs,
|
stateOutputDirs,
|
||||||
toATermList(drv.inputSrcs),
|
inDrvs,
|
||||||
toATerm(drv.platform),
|
toATermList(drv.inputSrcs),
|
||||||
toATerm(drv.builder),
|
toATerm(drv.platform),
|
||||||
args,
|
toATerm(drv.builder),
|
||||||
env);
|
args,
|
||||||
|
env);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return makeDeriveWithOutState(
|
||||||
|
outputs,
|
||||||
|
inDrvs,
|
||||||
|
toATermList(drv.inputSrcs),
|
||||||
|
toATerm(drv.platform),
|
||||||
|
toATerm(drv.builder),
|
||||||
|
args,
|
||||||
|
env);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue