* Change extension .store' to .drv'.
* Re-enable `nix-store --query --requisites'.
This commit is contained in:
parent
863dcff6c5
commit
06c77bf7a8
12 changed files with 120 additions and 139 deletions
|
|
@ -26,65 +26,39 @@ void computeFSClosure(const Path & storePath,
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
PathSet storeExprRoots(const Path & nePath)
|
||||
{
|
||||
PathSet paths;
|
||||
|
||||
StoreExpr ne = storeExprFromPath(nePath);
|
||||
|
||||
if (ne.type == StoreExpr::neClosure)
|
||||
paths.insert(ne.closure.roots.begin(), ne.closure.roots.end());
|
||||
else if (ne.type == StoreExpr::neDerivation)
|
||||
for (DerivationOutputs::iterator i = ne.derivation.outputs.begin();
|
||||
i != ne.derivation.outputs.end(); ++i)
|
||||
paths.insert(i->second.path);
|
||||
else abort();
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
|
||||
static void requisitesWorker(const Path & nePath,
|
||||
bool includeExprs, bool includeSuccessors,
|
||||
PathSet & paths, PathSet & doneSet)
|
||||
void storePathRequisites(const Path & storePath,
|
||||
bool includeOutputs, PathSet & paths)
|
||||
{
|
||||
checkInterrupt();
|
||||
|
||||
if (doneSet.find(nePath) != doneSet.end()) return;
|
||||
doneSet.insert(nePath);
|
||||
if (paths.find(storePath) != paths.end()) return;
|
||||
|
||||
StoreExpr ne = storeExprFromPath(nePath);
|
||||
if (isDerivation(storePath)) {
|
||||
|
||||
if (ne.type == StoreExpr::neClosure)
|
||||
for (ClosureElems::iterator i = ne.closure.elems.begin();
|
||||
i != ne.closure.elems.end(); ++i)
|
||||
paths.insert(i->first);
|
||||
|
||||
else if (ne.type == StoreExpr::neDerivation)
|
||||
for (PathSet::iterator i = ne.derivation.inputs.begin();
|
||||
i != ne.derivation.inputs.end(); ++i)
|
||||
requisitesWorker(*i,
|
||||
includeExprs, includeSuccessors, paths, doneSet);
|
||||
paths.insert(storePath);
|
||||
|
||||
Derivation drv = derivationFromPath(storePath);
|
||||
|
||||
else abort();
|
||||
for (PathSet::iterator i = drv.inputDrvs.begin();
|
||||
i != drv.inputDrvs.end(); ++i)
|
||||
storePathRequisites(*i, includeOutputs, paths);
|
||||
|
||||
if (includeExprs) paths.insert(nePath);
|
||||
for (PathSet::iterator i = drv.inputSrcs.begin();
|
||||
i != drv.inputSrcs.end(); ++i)
|
||||
storePathRequisites(*i, includeOutputs, paths);
|
||||
|
||||
Path nfPath;
|
||||
if (includeSuccessors && querySuccessor(nePath, nfPath))
|
||||
requisitesWorker(nfPath, includeExprs, includeSuccessors,
|
||||
paths, doneSet);
|
||||
if (includeOutputs) {
|
||||
|
||||
for (DerivationOutputs::iterator i = drv.outputs.begin();
|
||||
i != drv.outputs.end(); ++i)
|
||||
if (isValidPath(i->second.path))
|
||||
storePathRequisites(i->second.path, includeOutputs, paths);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
computeFSClosure(storePath, paths);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PathSet storeExprRequisites(const Path & nePath,
|
||||
bool includeExprs, bool includeSuccessors)
|
||||
{
|
||||
PathSet paths;
|
||||
PathSet doneSet;
|
||||
requisitesWorker(nePath, includeExprs, includeSuccessors,
|
||||
paths, doneSet);
|
||||
return paths;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1307,6 +1307,9 @@ void SubstitutionGoal::init()
|
|||
return;
|
||||
}
|
||||
|
||||
/* !!! build the outgoing references of this path first to
|
||||
maintain the closure invariant! */
|
||||
|
||||
/* Otherwise, get the substitutes. */
|
||||
subs = querySubstitutes(storePath);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "storeexpr.hh"
|
||||
|
||||
|
||||
/* Perform the specified derivation, if necessary. That is, do
|
||||
whatever is necessary to create the output paths of the
|
||||
derivation. If the output paths already exists, we're done. If
|
||||
|
|
@ -20,29 +19,29 @@ void ensurePath(const Path & storePath);
|
|||
through ensurePath(). */
|
||||
Derivation derivationFromPath(const Path & drvPath);
|
||||
|
||||
|
||||
/* Places in `paths' the set of all store paths in the file system
|
||||
/* Place in `paths' the set of all store paths in the file system
|
||||
closure of `storePath'; that is, all paths than can be directly or
|
||||
indirectly reached from it. `paths' is not cleared. */
|
||||
void computeFSClosure(const Path & storePath,
|
||||
PathSet & paths);
|
||||
|
||||
/* 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.
|
||||
|
||||
#if 0
|
||||
/* Get the list of root (output) paths of the given store
|
||||
expression. */
|
||||
PathSet storeExprRoots(const Path & nePath);
|
||||
|
||||
/* Get the list of paths that are required to realise the given store
|
||||
expression. For a derive expression, this is the union of
|
||||
requisites of the inputs; for a closure expression, it is the path
|
||||
of each element in the closure. If `includeExprs' is true, include
|
||||
the paths of the store expressions themselves. If
|
||||
`includeSuccessors' is true, include the requisites of
|
||||
successors. */
|
||||
PathSet storeExprRequisites(const Path & nePath,
|
||||
bool includeExprs, bool includeSuccessors);
|
||||
#endif
|
||||
Note that this function can be used to implement three different
|
||||
deployment policies:
|
||||
|
||||
- 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,
|
||||
bool includeOutputs, PathSet & paths);
|
||||
|
||||
#endif /* !__NORMALISE_H */
|
||||
|
|
|
|||
|
|
@ -217,6 +217,8 @@ void setReferences(const Transaction & txn, const Path & storePath,
|
|||
void queryReferences(const Path & storePath, PathSet & references)
|
||||
{
|
||||
Paths references2;
|
||||
if (!isValidPath(storePath))
|
||||
throw Error(format("path `%1%' is not valid") % storePath);
|
||||
nixDB.queryStrings(noTxn, dbReferences, storePath, references2);
|
||||
references.insert(references2.begin(), references2.end());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,10 @@ Hash hashTerm(ATerm t)
|
|||
}
|
||||
|
||||
|
||||
Path writeTerm(ATerm t, const string & suffix)
|
||||
Path writeDerivation(const Derivation & drv, const string & name)
|
||||
{
|
||||
char * s = ATwriteToString(t);
|
||||
if (!s) throw Error("cannot print aterm");
|
||||
return addTextToStore(suffix + ".store", string(s));
|
||||
return addTextToStore(name + drvExtension,
|
||||
atPrint(unparseDerivation(drv)));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -133,3 +132,11 @@ ATerm unparseDerivation(const Derivation & drv)
|
|||
ATreverse(args),
|
||||
ATreverse(env));
|
||||
}
|
||||
|
||||
|
||||
bool isDerivation(const string & fileName)
|
||||
{
|
||||
return
|
||||
fileName.size() >= drvExtension.size() &&
|
||||
string(fileName, fileName.size() - drvExtension.size()) == drvExtension;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,23 +5,11 @@
|
|||
#include "store.hh"
|
||||
|
||||
|
||||
/* Abstract syntax of store expressions. */
|
||||
/* Extension of derivations in the Nix store. */
|
||||
const string drvExtension = ".drv";
|
||||
|
||||
struct ClosureElem
|
||||
{
|
||||
PathSet refs;
|
||||
};
|
||||
|
||||
typedef map<Path, ClosureElem> ClosureElems;
|
||||
|
||||
/*
|
||||
struct Closure
|
||||
{
|
||||
PathSet roots;
|
||||
ClosureElems elems;
|
||||
};
|
||||
*/
|
||||
|
||||
/* Abstract syntax of derivations. */
|
||||
|
||||
struct DerivationOutput
|
||||
{
|
||||
|
|
@ -57,14 +45,18 @@ struct Derivation
|
|||
/* Hash an aterm. */
|
||||
Hash hashTerm(ATerm t);
|
||||
|
||||
/* Write an aterm to the Nix store directory, and return its path. */
|
||||
Path writeTerm(ATerm t, const string & suffix);
|
||||
/* Write a derivation to the Nix store, and return its path. */
|
||||
Path writeDerivation(const Derivation & drv, const string & name);
|
||||
|
||||
/* Parse a store expression. */
|
||||
/* Parse a derivation. */
|
||||
Derivation parseDerivation(ATerm t);
|
||||
|
||||
/* Parse a store expression. */
|
||||
/* Parse a derivation. */
|
||||
ATerm unparseDerivation(const Derivation & drv);
|
||||
|
||||
/* Check whether a file name ends with the extensions for
|
||||
derivations. */
|
||||
bool isDerivation(const string & fileName);
|
||||
|
||||
|
||||
#endif /* !__STOREEXPR_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue