mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 20:20:58 +01:00
This commit is contained in:
parent
a4fda31ad5
commit
0e41b191bf
12 changed files with 42 additions and 45 deletions
|
|
@ -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();
|
||||
|
|
@ -1778,7 +1779,9 @@ 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;
|
||||
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,14 +786,13 @@ 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();
|
||||
i != infos.end(); ++i)
|
||||
newPaths.insert(i->path);
|
||||
|
||||
|
||||
for (ValidPathInfos::const_iterator i = infos.begin();
|
||||
i != infos.end(); ++i)
|
||||
{
|
||||
|
|
@ -804,7 +802,7 @@ void registerValidPaths(const Transaction & txn,
|
|||
setHash(txn, i->path, i->hash);
|
||||
|
||||
setReferences(txn, i->path, i->references, i->stateReferences);
|
||||
|
||||
|
||||
/* Check that all referenced paths are also valid (or about to
|
||||
become valid). */
|
||||
for (PathSet::iterator j = i->references.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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue