2005-01-19 16:39:47 +00:00
|
|
|
#include "build.hh"
|
2004-06-18 18:09:32 +00:00
|
|
|
|
|
|
|
|
2005-01-19 11:16:11 +00:00
|
|
|
Derivation derivationFromPath(const Path & drvPath)
|
2004-06-18 18:09:32 +00:00
|
|
|
{
|
2005-01-19 11:16:11 +00:00
|
|
|
assertStorePath(drvPath);
|
|
|
|
ensurePath(drvPath);
|
|
|
|
ATerm t = ATreadFromNamedFile(drvPath.c_str());
|
|
|
|
if (!t) throw Error(format("cannot read aterm from `%1%'") % drvPath);
|
|
|
|
return parseDerivation(t);
|
2004-06-18 18:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-19 11:16:11 +00:00
|
|
|
void computeFSClosure(const Path & storePath,
|
2005-01-25 11:18:03 +00:00
|
|
|
PathSet & paths, bool flipDirection)
|
2005-01-19 11:16:11 +00:00
|
|
|
{
|
|
|
|
if (paths.find(storePath) != paths.end()) return;
|
|
|
|
paths.insert(storePath);
|
|
|
|
|
|
|
|
PathSet references;
|
2005-01-25 11:18:03 +00:00
|
|
|
if (flipDirection)
|
2005-12-13 21:04:48 +00:00
|
|
|
queryReferrers(noTxn, storePath, references);
|
2005-01-25 11:18:03 +00:00
|
|
|
else
|
2005-02-08 13:23:55 +00:00
|
|
|
queryReferences(noTxn, storePath, references);
|
2005-01-19 11:16:11 +00:00
|
|
|
|
|
|
|
for (PathSet::iterator i = references.begin();
|
|
|
|
i != references.end(); ++i)
|
2005-01-25 11:18:03 +00:00
|
|
|
computeFSClosure(*i, paths, flipDirection);
|
2005-01-19 11:16:11 +00:00
|
|
|
}
|
2005-02-14 17:35:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
Path findOutput(const Derivation & drv, string id)
|
|
|
|
{
|
|
|
|
for (DerivationOutputs::const_iterator i = drv.outputs.begin();
|
|
|
|
i != drv.outputs.end(); ++i)
|
|
|
|
if (i->first == id) return i->second.path;
|
|
|
|
throw Error(format("derivation has no output `%1%'") % id);
|
|
|
|
}
|