mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
This commit is contained in:
parent
a4fda31ad5
commit
0e41b191bf
12 changed files with 42 additions and 45 deletions
|
|
@ -350,7 +350,7 @@ static Hash hashDerivationModulo(EvalState & state, Derivation drv)
|
|||
if(drvso.runtimeStateParamters != ""){ //Has runtime parameters --> Clear all state parameters
|
||||
drv.stateOutputs.clear();
|
||||
drv.stateOutputDirs.clear();
|
||||
drv.env["statepath"] = "";
|
||||
drv.env["statePath"] = "";
|
||||
}
|
||||
else{ //Has NO runtime parameters --> Clear state parameters selectively
|
||||
drvso.clearAllRuntimeParamters();
|
||||
|
|
@ -617,14 +617,15 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
|
|||
//printMsg(lvlError, format("DerivationOutput %1% %2% %3%") % outPath % outputHashAlgo % outputHash);
|
||||
//only add state when we have to to keep compitibilty with the 'old' format.
|
||||
//We add state when it's enbaled by the keywords, and not excplicitly disabled by the user
|
||||
Path stateOutPath;
|
||||
if(enableState && !disableState){
|
||||
/* Add the state path based on the outPath
|
||||
*
|
||||
* NOTE: we do not include the username into the hash calculation of the statepath yet, multiple different users can use the same dervation
|
||||
* but need different state paths. Thats why we keep a 'dummy' value e.g. global hash for everyone, and later at build time recalculate the real state path
|
||||
*/
|
||||
Path stateOutPath = makeStatePath(printHash(componentHash), drvName, stateIdentifier); //State path
|
||||
drv.env["statepath"] = stateOutPath;
|
||||
stateOutPath = makeStatePath(printHash(componentHash), drvName, stateIdentifier); //State path
|
||||
drv.env["statePath"] = stateOutPath;
|
||||
|
||||
string enableStateS = bool2string("true");
|
||||
string createDirsBeforeInstallS = bool2string(createDirsBeforeInstall);
|
||||
|
|
@ -659,10 +660,10 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
|
|||
|
||||
/* !!! assumes a single output */
|
||||
ATermMap outAttrs(2);
|
||||
outAttrs.set(toATerm("outPath"),
|
||||
makeAttrRHS(makeStr(outPath, singleton<PathSet>(drvPath)), makeNoPos()));
|
||||
outAttrs.set(toATerm("drvPath"),
|
||||
makeAttrRHS(makeStr(drvPath, singleton<PathSet>(drvPath)), makeNoPos()));
|
||||
outAttrs.set(toATerm("outPath"), makeAttrRHS(makeStr(outPath, singleton<PathSet>(drvPath)), makeNoPos()));
|
||||
outAttrs.set(toATerm("drvPath"), makeAttrRHS(makeStr(drvPath, singleton<PathSet>(drvPath)), makeNoPos()));
|
||||
if(enableState && !disableState)
|
||||
outAttrs.set(toATerm("statePath"), makeAttrRHS(makeStr(stateOutPath, singleton<PathSet>(drvPath)), makeNoPos()));
|
||||
|
||||
return makeAttrs(outAttrs);
|
||||
}
|
||||
|
|
@ -683,6 +684,8 @@ static Expr prim_derivationLazy(EvalState & state, const ATermVector & args)
|
|||
makeAttrRHS(makeSelect(drvStrict, toATerm("outPath")), makeNoPos()));
|
||||
attrs.set(toATerm("drvPath"),
|
||||
makeAttrRHS(makeSelect(drvStrict, toATerm("drvPath")), makeNoPos()));
|
||||
attrs.set(toATerm("statePath"), //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! add a state check !
|
||||
makeAttrRHS(makeSelect(drvStrict, toATerm("statePath")), makeNoPos()));
|
||||
|
||||
return makeAttrs(attrs);
|
||||
}
|
||||
|
|
@ -769,8 +772,8 @@ static Expr prim_toFile(EvalState & state, const ATermVector & args)
|
|||
}
|
||||
|
||||
Path storePath = readOnlyMode
|
||||
? computeStorePathForText(name, contents, refs, stateRefs)
|
||||
: store->addTextToStore(name, contents, refs, stateRefs);
|
||||
? computeStorePathForText(name, contents, refs)
|
||||
: store->addTextToStore(name, contents, refs);
|
||||
|
||||
/* Note: we don't need to add `context' to the context of the
|
||||
result, since `storePath' itself has references to the paths
|
||||
|
|
|
|||
|
|
@ -1730,6 +1730,7 @@ void DerivationGoal::computeClosure()
|
|||
The reason that we do the transaction here and not on the fly
|
||||
while we are scanning (above) is so that we don't hold database
|
||||
locks for too long. */
|
||||
|
||||
Transaction txn;
|
||||
createStoreTransaction(txn);
|
||||
for (DerivationOutputs::iterator i = drv.outputs.begin();
|
||||
|
|
@ -1779,6 +1780,8 @@ void DerivationGoal::computeClosure()
|
|||
//If state is enabled: Seaches for state and component references in the state path
|
||||
if(isStateDrvTxn(txn, drv)){
|
||||
Path statePath = drv.stateOutputs.find("state")->second.statepath;
|
||||
printMsg(lvlTalkative, format("scanning for component and state references inside `%1%'") % statePath);
|
||||
|
||||
PathSet state_references = scanForReferences(statePath, allPaths);
|
||||
PathSet state_stateReferences = scanForStateReferences(statePath, allStatePaths);
|
||||
all_state_references = mergePathSets(all_state_references, mergePathSets(state_references, state_stateReferences));
|
||||
|
|
@ -1794,8 +1797,7 @@ void DerivationGoal::computeClosure()
|
|||
allStateReferences[path] = all_state_references;
|
||||
}
|
||||
|
||||
for (DerivationOutputs::iterator i = drv.outputs.begin();
|
||||
i != drv.outputs.end(); ++i)
|
||||
for (DerivationOutputs::iterator i = drv.outputs.begin(); i != drv.outputs.end(); ++i)
|
||||
{
|
||||
registerValidPath(txn, i->second.path,
|
||||
contentHashes[i->second.path],
|
||||
|
|
|
|||
|
|
@ -27,14 +27,11 @@ Path writeDerivation(const Derivation & drv, const string & name)
|
|||
(that can be missing (of course) and should not necessarily be
|
||||
held during a garbage collection). */
|
||||
|
||||
//We only need to hash over inputSrcs and inputDrvs (I think ...)
|
||||
PathSet stateReferences;
|
||||
|
||||
string suffix = name + drvExtension;
|
||||
string contents = atPrint(unparseDerivation(drv));
|
||||
return readOnlyMode
|
||||
? computeStorePathForText(suffix, contents, references, stateReferences)
|
||||
: store->addTextToStore(suffix, contents, references, stateReferences);
|
||||
? computeStorePathForText(suffix, contents, references)
|
||||
: store->addTextToStore(suffix, contents, references);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -483,8 +483,7 @@ void setDeriver(const Transaction & txn, const Path & storePath, const Path & de
|
|||
if (!isRealisablePath(txn, storePath))
|
||||
throw Error(format("path `%1%' is not valid") % storePath);
|
||||
|
||||
Derivation drv = derivationFromPath(deriver);
|
||||
if (drv.outputs.size() != 0){ //Redirect if its a state component
|
||||
if (isStateDrvPathTxn(txn, deriver)){ //Redirect if its a state component
|
||||
addStateDeriver(txn, storePath, deriver);
|
||||
}
|
||||
else{
|
||||
|
|
@ -787,8 +786,7 @@ void registerValidPath(const Transaction & txn,
|
|||
}
|
||||
|
||||
|
||||
void registerValidPaths(const Transaction & txn,
|
||||
const ValidPathInfos & infos)
|
||||
void registerValidPaths(const Transaction & txn, const ValidPathInfos & infos)
|
||||
{
|
||||
PathSet newPaths;
|
||||
for (ValidPathInfos::const_iterator i = infos.begin();
|
||||
|
|
@ -882,10 +880,13 @@ Path LocalStore::addToStore(const Path & _srcPath, bool fixed,
|
|||
}
|
||||
|
||||
|
||||
//Gets all derivations ...
|
||||
Path LocalStore::addTextToStore(const string & suffix, const string & s,
|
||||
const PathSet & references, const PathSet & stateReferences)
|
||||
const PathSet & references)
|
||||
{
|
||||
Path dstPath = computeStorePathForText(suffix, s, references, stateReferences);
|
||||
Path dstPath = computeStorePathForText(suffix, s, references);
|
||||
|
||||
printMsg(lvlError, format("addTextToStore: %1%") % dstPath);
|
||||
|
||||
addTempRoot(dstPath);
|
||||
|
||||
|
|
@ -902,7 +903,7 @@ Path LocalStore::addTextToStore(const string & suffix, const string & s,
|
|||
canonicalisePathMetaData(dstPath);
|
||||
|
||||
Transaction txn(nixDB);
|
||||
registerValidPath(txn, dstPath, hashPath(htSHA256, dstPath), references, stateReferences, "");
|
||||
registerValidPath(txn, dstPath, hashPath(htSHA256, dstPath), references, PathSet(), ""); //There are no stateReferences in drvs..... so we dont need to register them (I think)
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
|
|
@ -1299,8 +1300,7 @@ void verifyStore(bool checkContents)
|
|||
//TODO TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
if (find(references.begin(), references.end(), to) == references.end()) {
|
||||
printMsg(lvlError, format("adding missing referrer mapping from `%1%' to `%2%'")
|
||||
% from % to);
|
||||
printMsg(lvlError, format("adding missing referrer mapping from `%1%' to `%2%'") % from % to);
|
||||
references.insert(to);
|
||||
setReferences(txn, from, references, stateReferences);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public:
|
|||
PathFilter & filter = defaultPathFilter);
|
||||
|
||||
Path addTextToStore(const string & suffix, const string & s,
|
||||
const PathSet & references, const PathSet & stateReferences);
|
||||
const PathSet & references);
|
||||
|
||||
void exportPath(const Path & path, bool sign,
|
||||
Sink & sink);
|
||||
|
|
|
|||
|
|
@ -250,13 +250,12 @@ Path RemoteStore::addToStore(const Path & _srcPath, bool fixed,
|
|||
|
||||
|
||||
Path RemoteStore::addTextToStore(const string & suffix, const string & s,
|
||||
const PathSet & references, const PathSet & stateReferences)
|
||||
const PathSet & references)
|
||||
{
|
||||
writeInt(wopAddTextToStore, to);
|
||||
writeString(suffix, to);
|
||||
writeString(s, to);
|
||||
writeStringSet(references, to);
|
||||
writeStringSet(stateReferences, to);
|
||||
|
||||
processStderr();
|
||||
Path path = readStorePath(from);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public:
|
|||
PathFilter & filter = defaultPathFilter);
|
||||
|
||||
Path addTextToStore(const string & suffix, const string & s,
|
||||
const PathSet & references, const PathSet & stateReferences);
|
||||
const PathSet & references);
|
||||
|
||||
void exportPath(const Path & path, bool sign,
|
||||
Sink & sink);
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath,
|
|||
|
||||
|
||||
Path computeStorePathForText(const string & suffix, const string & s,
|
||||
const PathSet & references, const PathSet & stateReferences)
|
||||
const PathSet & references)
|
||||
{
|
||||
Hash hash = hashString(htSHA256, s);
|
||||
/* Stuff the references (if any) into the type. This is a bit
|
||||
|
|
@ -190,10 +190,6 @@ Path computeStorePathForText(const string & suffix, const string & s,
|
|||
type += ":";
|
||||
type += *i;
|
||||
}
|
||||
for (PathSet::const_iterator i = stateReferences.begin(); i != stateReferences.end(); ++i) {
|
||||
type += ":";
|
||||
type += *i;
|
||||
}
|
||||
|
||||
return makeStorePath(type, hash, suffix);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public:
|
|||
/* Like addToStore, but the contents written to the output path is
|
||||
a regular file containing the given string. */
|
||||
virtual Path addTextToStore(const string & suffix, const string & s,
|
||||
const PathSet & references, const PathSet & stateReferences) = 0;
|
||||
const PathSet & references) = 0;
|
||||
|
||||
/* Export a store path, that is, create a NAR dump of the store
|
||||
path and append its references and its deriver. Optionally, a
|
||||
|
|
@ -264,7 +264,7 @@ std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath,
|
|||
affected), but it has some backwards compatibility issues (the
|
||||
hashing scheme changes), so I'm not doing that for now. */
|
||||
Path computeStorePathForText(const string & suffix, const string & s,
|
||||
const PathSet & references, const PathSet & stateReferences);
|
||||
const PathSet & references);
|
||||
|
||||
|
||||
/* Remove the temporary roots file for this process. Any temporary
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems,
|
|||
|
||||
/* Construct the whole top level derivation. */
|
||||
PathSet references;
|
||||
PathSet stateReferences; //TODO TODO TODO TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
ATermList manifest = ATempty;
|
||||
ATermList inputs = ATempty;
|
||||
for (DrvInfos::const_iterator i = elems.begin();
|
||||
|
|
@ -197,14 +196,13 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems,
|
|||
`nix-env -i /nix/store/abcd...-foo'. */
|
||||
store->addTempRoot(i->queryOutPath(state));
|
||||
store->ensurePath(i->queryOutPath(state));
|
||||
|
||||
references.insert(i->queryOutPath(state));
|
||||
if (drvPath != "") references.insert(drvPath);
|
||||
}
|
||||
|
||||
/* Also write a copy of the list of inputs to the store; we need
|
||||
it for future modifications of the environment. */
|
||||
Path manifestFile = store->addTextToStore("env-manifest", atPrint(canonicaliseExpr(makeList(ATreverse(manifest)))), references, stateReferences);
|
||||
Path manifestFile = store->addTextToStore("env-manifest", atPrint(canonicaliseExpr(makeList(ATreverse(manifest)))), references);
|
||||
|
||||
Expr topLevel = makeCall(envBuilder, makeAttrs(ATmakeList3(
|
||||
makeBind(toATerm("system"),
|
||||
|
|
@ -379,6 +377,9 @@ static void queryInstSources(EvalState & state,
|
|||
if (isDerivation(*i)) {
|
||||
elem.setDrvPath(*i);
|
||||
elem.setOutPath(findOutput(derivationFromPath(*i), "out"));
|
||||
|
||||
//TODO !!!!!!!!!!!!!!!!!!!! setStatePath??
|
||||
|
||||
if (name.size() >= drvExtension.size() &&
|
||||
string(name, name.size() - drvExtension.size()) == drvExtension)
|
||||
name = string(name, 0, name.size() - drvExtension.size());
|
||||
|
|
|
|||
|
|
@ -315,9 +315,8 @@ static void performOp(Source & from, Sink & to, unsigned int op)
|
|||
string suffix = readString(from);
|
||||
string s = readString(from);
|
||||
PathSet refs = readStorePaths(from);
|
||||
PathSet stateRefs; //TODO TODO TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
startWork();
|
||||
Path path = store->addTextToStore(suffix, s, refs, stateRefs);
|
||||
Path path = store->addTextToStore(suffix, s, refs);
|
||||
stopWork();
|
||||
writeString(path, to);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue