mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 20:20:58 +01:00
Before adding dbValidStatePaths
This commit is contained in:
parent
0e41b191bf
commit
51fad07fbd
13 changed files with 167 additions and 144 deletions
|
|
@ -1194,7 +1194,7 @@ DerivationGoal::HookReply DerivationGoal::tryBuildHook()
|
|||
*probably* already has it.) */
|
||||
PathSet allInputs;
|
||||
allInputs.insert(inputPaths.begin(), inputPaths.end());
|
||||
computeFSClosure(drvPath, allInputs);
|
||||
computeFSClosure(drvPath, allInputs, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
|
||||
string s;
|
||||
for (PathSet::iterator i = allInputs.begin();
|
||||
|
|
@ -1316,7 +1316,7 @@ bool DerivationGoal::prepareBuild()
|
|||
for (StringSet::iterator j = i->second.begin();
|
||||
j != i->second.end(); ++j)
|
||||
if (inDrv.outputs.find(*j) != inDrv.outputs.end())
|
||||
computeFSClosure(inDrv.outputs[*j].path, inputPaths);
|
||||
computeFSClosure(inDrv.outputs[*j].path, inputPaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
else
|
||||
throw BuildError(
|
||||
format("derivation `%1%' requires non-existent output `%2%' from input derivation `%3%'")
|
||||
|
|
@ -1326,7 +1326,7 @@ bool DerivationGoal::prepareBuild()
|
|||
/* Second, the input sources. */
|
||||
for (PathSet::iterator i = drv.inputSrcs.begin();
|
||||
i != drv.inputSrcs.end(); ++i)
|
||||
computeFSClosure(*i, inputPaths);
|
||||
computeFSClosure(*i, inputPaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
|
||||
debug(format("added input paths %1%") % showPaths(inputPaths));
|
||||
|
||||
|
|
@ -1451,7 +1451,7 @@ void DerivationGoal::startBuilder()
|
|||
|
||||
/* Write closure info to `fileName'. */
|
||||
PathSet refs;
|
||||
computeFSClosure(storePath, refs);
|
||||
computeFSClosure(storePath, refs, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
/* !!! in secure Nix, the writing should be done on the
|
||||
build uid for security (maybe). */
|
||||
writeStringToFile(tmpDir + "/" + fileName,
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
|||
roots under the `references' relation. */
|
||||
PathSet livePaths;
|
||||
for (PathSet::const_iterator i = roots.begin(); i != roots.end(); ++i)
|
||||
computeFSClosure(canonPath(*i), livePaths);
|
||||
computeFSClosure(canonPath(*i), livePaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO DELETE STATE??
|
||||
|
||||
if (gcKeepDerivations) {
|
||||
for (PathSet::iterator i = livePaths.begin();
|
||||
|
|
@ -480,7 +480,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
|||
turned off). */
|
||||
Path deriver = queryDeriver(noTxn, *i);
|
||||
if (deriver != "" && store->isValidPath(deriver))
|
||||
computeFSClosure(deriver, livePaths);
|
||||
computeFSClosure(deriver, livePaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -493,7 +493,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
|||
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
||||
j != drv.outputs.end(); ++j)
|
||||
if (store->isValidPath(j->second.path))
|
||||
computeFSClosure(j->second.path, livePaths);
|
||||
computeFSClosure(j->second.path, livePaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -518,7 +518,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
|||
PathSet tempRootsClosed;
|
||||
for (PathSet::iterator i = tempRoots.begin(); i != tempRoots.end(); ++i)
|
||||
if (store->isValidPath(*i))
|
||||
computeFSClosure(*i, tempRootsClosed);
|
||||
computeFSClosure(*i, tempRootsClosed, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO .... STATE
|
||||
else
|
||||
tempRootsClosed.insert(*i);
|
||||
|
||||
|
|
|
|||
|
|
@ -320,8 +320,7 @@ static Substitutes readSubstitutes(const Transaction & txn,
|
|||
|
||||
static bool isRealisablePath(const Transaction & txn, const Path & path)
|
||||
{
|
||||
return isValidPathTxn(txn, path)
|
||||
|| readSubstitutes(txn, path).size() > 0;
|
||||
return isValidPathTxn(txn, path) || readSubstitutes(txn, path).size() > 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -545,7 +544,7 @@ bool LocalStore::isStateDrvPath(const Path & isStateDrv)
|
|||
}
|
||||
|
||||
//TODO Add and ..
|
||||
bool isStateDrvTxn(const Transaction & txn, Derivation drv)
|
||||
bool isStateDrvTxn(const Transaction & txn, const Derivation & drv)
|
||||
{
|
||||
if (drv.stateOutputs.size() != 0)
|
||||
return true;
|
||||
|
|
@ -553,7 +552,7 @@ bool isStateDrvTxn(const Transaction & txn, Derivation drv)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool LocalStore::isStateDrv(Derivation drv)
|
||||
bool LocalStore::isStateDrv(const Derivation & drv)
|
||||
{
|
||||
return nix::isStateDrvTxn(noTxn, drv);
|
||||
}
|
||||
|
|
@ -886,7 +885,7 @@ Path LocalStore::addTextToStore(const string & suffix, const string & s,
|
|||
{
|
||||
Path dstPath = computeStorePathForText(suffix, s, references);
|
||||
|
||||
printMsg(lvlError, format("addTextToStore: %1%") % dstPath);
|
||||
//printMsg(lvlError, format("addTextToStore: %1%") % dstPath);
|
||||
|
||||
addTempRoot(dstPath);
|
||||
|
||||
|
|
@ -1043,7 +1042,7 @@ Path LocalStore::importPath(bool requireSignature, Source & source)
|
|||
|
||||
PathSet references = readStorePaths(hashAndReadSource);
|
||||
|
||||
//TODO TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
//TODO TODO also ..??!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
PathSet stateReferences;
|
||||
|
||||
Path deriver = readString(hashAndReadSource);
|
||||
|
|
@ -1137,7 +1136,7 @@ void deleteFromStore(const Path & _path, unsigned long long & bytesFreed)
|
|||
invalidatePath(txn, path);
|
||||
|
||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
//Also delete stateReferrers?????
|
||||
//Also delete/invalidate stateReferrers?????
|
||||
}
|
||||
txn.commit();
|
||||
|
||||
|
|
@ -1228,9 +1227,8 @@ void verifyStore(bool checkContents)
|
|||
}
|
||||
}
|
||||
|
||||
//TODO also check state references and refererres
|
||||
|
||||
/* Check the `references' table. */
|
||||
//TODO TODO Do the exact same thing for dbStateReferrers
|
||||
printMsg(lvlInfo, "checking the references table");
|
||||
Paths referencesKeys;
|
||||
nixDB.enumTable(txn, dbReferences, referencesKeys);
|
||||
|
|
@ -1264,6 +1262,7 @@ void verifyStore(bool checkContents)
|
|||
}
|
||||
|
||||
/* Check the `referrers' table. */
|
||||
//TODO TODO Do the exact same thing for dbStateReferrers, but merge! it into this one....
|
||||
printMsg(lvlInfo, "checking the referrers table");
|
||||
Strings referrers;
|
||||
nixDB.enumTable(txn, dbReferrers, referrers);
|
||||
|
|
@ -1294,10 +1293,9 @@ void verifyStore(bool checkContents)
|
|||
else {
|
||||
PathSet references;
|
||||
queryReferences(txn, from, references);
|
||||
|
||||
PathSet stateReferences;
|
||||
|
||||
PathSet stateReferences; //already a stateReferrers here!
|
||||
queryStateReferences(txn, from, stateReferences);
|
||||
//TODO TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
if (find(references.begin(), references.end(), to) == references.end()) {
|
||||
printMsg(lvlError, format("adding missing referrer mapping from `%1%' to `%2%'") % from % to);
|
||||
|
|
@ -1309,7 +1307,7 @@ void verifyStore(bool checkContents)
|
|||
}
|
||||
|
||||
//TODO Check stateinfo and statecounters table
|
||||
|
||||
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
|
|
@ -1412,29 +1410,43 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
|
|||
return newdrvs;
|
||||
}
|
||||
|
||||
/* We register in this database which _component_ paths are state paths
|
||||
* This does not mean these paths are already valid!, you should look in derivivers for that
|
||||
*/
|
||||
/*
|
||||
void registerMaybeStatePath(const Path & drvPath)
|
||||
{
|
||||
if(!isStateDrv(drvPath))
|
||||
return;
|
||||
/* Place in `paths' the set of paths that are required to `realise'
|
||||
the given store path, i.e., all paths necessary for valid
|
||||
deployment of the path. For a derivation, this is the union of
|
||||
requisites of the inputs, plus the derivation; for other store
|
||||
paths, it is the set of paths in the FS closure of the path. If
|
||||
`includeOutputs' is true, include the requisites of the output
|
||||
paths of derivations as well.
|
||||
|
||||
printMsg(lvlError, format("derivation aaa: %1% ") % drvPath);
|
||||
Note that this function can be used to implement three different
|
||||
deployment policies:
|
||||
|
||||
|
||||
Derivation drv = derivationFromPath(drvPath);
|
||||
Path storePath = drv.outputs["out"].path;
|
||||
|
||||
nixDB.setString(noTxn, dbStateInfo, storePath, ""); //update the dbinfo db. (maybe TODO)
|
||||
}
|
||||
|
||||
void LocalStore::registerMaybeStatePath(const Path & drvPath)
|
||||
{
|
||||
nix::registerMaybeStatePath(drvPath);
|
||||
}
|
||||
- Source deployment (when called on a derivation).
|
||||
- Binary deployment (when called on an output path).
|
||||
- Source/binary deployment (when called on a derivation with
|
||||
`includeOutputs' set to true).
|
||||
*/
|
||||
void storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState)
|
||||
{
|
||||
computeFSClosure(storePath, paths, withState);
|
||||
|
||||
if (includeOutputs) {
|
||||
for (PathSet::iterator i = paths.begin();
|
||||
i != paths.end(); ++i)
|
||||
if (isDerivation(*i)) {
|
||||
Derivation drv = derivationFromPath(*i);
|
||||
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
||||
j != drv.outputs.end(); ++j)
|
||||
if (store->isValidPath(j->second.path))
|
||||
computeFSClosure(j->second.path, paths, withState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocalStore::storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState)
|
||||
{
|
||||
return nix::storePathRequisites(storePath, includeOutputs, paths, withState);
|
||||
}
|
||||
|
||||
/* Upgrade from schema 1 (Nix <= 0.7) to schema 2 (Nix >= 0.8). */
|
||||
static void upgradeStore07()
|
||||
|
|
|
|||
|
|
@ -88,7 +88,9 @@ public:
|
|||
|
||||
bool isStateDrvPath(const Path & drvpath);
|
||||
|
||||
bool isStateDrv(Derivation drv);
|
||||
bool isStateDrv(const Derivation & drv);
|
||||
|
||||
void storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState);
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -197,7 +199,7 @@ bool isStateComponentTxn(const Transaction & txn, const Path & path);
|
|||
|
||||
bool isStateDrvPathTxn(const Transaction & txn, const Path & drvPath);
|
||||
|
||||
bool isStateDrvTxn(const Transaction & txn, Derivation drv);
|
||||
bool isStateDrvTxn(const Transaction & txn, const Derivation & drv);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ Derivation derivationFromPath(const Path & drvPath)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
void computeFSClosure(const Path & storePath,
|
||||
PathSet & paths, bool flipDirection)
|
||||
{
|
||||
|
|
@ -30,10 +31,40 @@ void computeFSClosure(const Path & storePath,
|
|||
else
|
||||
store->queryReferences(storePath, references);
|
||||
|
||||
for (PathSet::iterator i = references.begin();
|
||||
i != references.end(); ++i)
|
||||
for (PathSet::iterator i = references.begin(); i != references.end(); ++i)
|
||||
computeFSClosure(*i, paths, flipDirection);
|
||||
}
|
||||
*/
|
||||
|
||||
void computeFSClosure(const Path & path, PathSet & paths, const bool & withState, bool flipDirection)
|
||||
{
|
||||
if (paths.find(path) != paths.end()) return;
|
||||
|
||||
paths.insert(path);
|
||||
|
||||
PathSet references;
|
||||
PathSet stateReferences;
|
||||
|
||||
if (flipDirection){
|
||||
store->queryReferrers(path, references);
|
||||
if(withState)
|
||||
store->queryStateReferrers(path, stateReferences);
|
||||
}
|
||||
else{
|
||||
store->queryReferences(path, references);
|
||||
if(withState)
|
||||
store->queryStateReferences(path, stateReferences);
|
||||
}
|
||||
|
||||
PathSet allReferences;
|
||||
if(withState)
|
||||
allReferences = mergePathSets(references, stateReferences);
|
||||
else
|
||||
allReferences = references;
|
||||
|
||||
for (PathSet::iterator i = allReferences.begin(); i != allReferences.end(); ++i)
|
||||
computeFSClosure(*i, paths, withState, flipDirection);
|
||||
}
|
||||
|
||||
|
||||
Path findOutput(const Derivation & drv, string id)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Derivation derivationFromPath(const Path & drvPath);
|
|||
`referrers' relation instead of the `references' relation is
|
||||
returned. */
|
||||
void computeFSClosure(const Path & storePath,
|
||||
PathSet & paths, bool flipDirection = false);
|
||||
PathSet & paths, const bool & withState, bool flipDirection = false);
|
||||
|
||||
/* Return the path corresponding to the output identifier `id' in the
|
||||
given derivation. */
|
||||
|
|
|
|||
|
|
@ -421,9 +421,15 @@ bool RemoteStore::isStateDrvPath(const Path & drvpath)
|
|||
}
|
||||
|
||||
//TODO
|
||||
bool RemoteStore::isStateDrv(Derivation drv)
|
||||
bool RemoteStore::isStateDrv(const Derivation & drv)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO
|
||||
void RemoteStore::storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,9 @@ public:
|
|||
|
||||
bool isStateDrvPath(const Path & drvpath);
|
||||
|
||||
bool isStateDrv(Derivation drv);
|
||||
bool isStateDrv(const Derivation & drv);
|
||||
|
||||
void storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState);
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -203,7 +203,9 @@ public:
|
|||
virtual bool isStateDrvPath(const Path & drvpath) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual bool isStateDrv(Derivation drv) = 0;
|
||||
virtual bool isStateDrv(const Derivation & drv) = 0;
|
||||
|
||||
virtual void storePathRequisites(const Path & storePath, const bool includeOutputs, PathSet & paths, const bool & withState) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue