1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-26 04:00:59 +01:00

* Before consolidating/building, consider all trusted paths in the

equivalence classes of the input derivations.
  
* Set the equivalence class for paths produced through rewriting.
This commit is contained in:
Eelco Dolstra 2005-05-30 13:14:26 +00:00
parent cfe428f69c
commit 94e3e4c69d
3 changed files with 45 additions and 15 deletions

View file

@ -969,13 +969,16 @@ bool DerivationGoal::prepareBuild()
j != i->second.end(); ++j) j != i->second.end(); ++j)
{ {
OutputEqClass eqClass = findOutputEqClass(inDrv, *j); OutputEqClass eqClass = findOutputEqClass(inDrv, *j);
Path input = findTrustedEqClassMember(eqClass, currentTrustId); PathSet inputs = findTrustedEqClassMembers(eqClass, currentTrustId);
if (input == "") if (inputs.size() == 0)
/* !!! shouldn't happen, except for garbage
collection? */
throw Error(format("output `%1%' of derivation `%2%' is missing!") throw Error(format("output `%1%' of derivation `%2%' is missing!")
% *j % i->first); % *j % i->first);
rewrites[hashPartOf(eqClass)] = hashPartOf(input); for (PathSet::iterator k = inputs.begin(); k != inputs.end(); ++k) {
rewrites[hashPartOf(eqClass)] = hashPartOf(*k);
computeFSClosure(input, inputPaths); computeFSClosure(*k, inputPaths);
}
} }
} }
@ -1333,9 +1336,8 @@ DerivationGoal::OutputEqClasses DerivationGoal::checkOutputValidity(bool returnV
for (DerivationOutputs::iterator i = drv.outputs.begin(); for (DerivationOutputs::iterator i = drv.outputs.begin();
i != drv.outputs.end(); ++i) i != drv.outputs.end(); ++i)
{ {
Path path = findTrustedEqClassMember(i->second.eqClass, currentTrustId); PathSet paths = findTrustedEqClassMembers(i->second.eqClass, currentTrustId);
if (path != "") { if (paths.size() > 0) {
assert(isValidPath(path));
if (returnValid) result.insert(i->second.eqClass); if (returnValid) result.insert(i->second.eqClass);
} else { } else {
if (!returnValid) result.insert(i->second.eqClass); if (!returnValid) result.insert(i->second.eqClass);

View file

@ -1,5 +1,6 @@
#include "build.hh" #include "build.hh"
#include "misc.hh" #include "misc.hh"
#include "globals.hh"
Derivation derivationFromPath(const Path & drvPath) Derivation derivationFromPath(const Path & drvPath)
@ -39,16 +40,27 @@ OutputEqClass findOutputEqClass(const Derivation & drv, const string & id)
} }
Path findTrustedEqClassMember(const OutputEqClass & eqClass, PathSet findTrustedEqClassMembers(const OutputEqClass & eqClass,
const TrustId & trustId) const TrustId & trustId)
{ {
OutputEqMembers members; OutputEqMembers members;
queryOutputEqMembers(noTxn, eqClass, members); queryOutputEqMembers(noTxn, eqClass, members);
PathSet result;
for (OutputEqMembers::iterator j = members.begin(); j != members.end(); ++j) for (OutputEqMembers::iterator j = members.begin(); j != members.end(); ++j)
if (j->trustId == trustId || j->trustId == "root") return j->path; if (j->trustId == trustId || j->trustId == "root") result.insert(j->path);
return ""; return result;
}
Path findTrustedEqClassMember(const OutputEqClass & eqClass,
const TrustId & trustId)
{
PathSet paths = findTrustedEqClassMembers(eqClass, trustId);
if (paths.size() == 0)
throw Error(format("no output path in equivalence class `%1%' is known") % eqClass);
return *(paths.begin());
} }
@ -152,6 +164,17 @@ static Path maybeRewrite(const Path & path, const PathSet & selection,
hashPartOf(path), namePartOf(path), hashPartOf(path), namePartOf(path),
references, rewrites); references, rewrites);
/* !!! we don't know which eqClass `path' is in! That is to say,
we don't know which one is intended here. */
OutputEqClasses classes;
queryOutputEqClasses(noTxn, path, classes);
for (PathSet::iterator i = classes.begin(); i != classes.end(); ++i) {
Transaction txn;
createStoreTransaction(txn);
addOutputEqMember(txn, *i, currentTrustId, newPath);
txn.commit();
}
nrRewrites++; nrRewrites++;
printMsg(lvlError, format("rewrote `%1%' to `%2%'") % path % newPath); printMsg(lvlError, format("rewrote `%1%' to `%2%'") % path % newPath);
@ -181,7 +204,7 @@ PathSet consolidatePaths(const PathSet & paths, bool checkOnly,
classMap[*j].insert(*i); classMap[*j].insert(*i);
} }
printMsg(lvlError, format("found %1% sources") % sources.size()); printMsg(lvlError, format("found %1% sources %2%") % sources.size() % showPaths(sources));
bool conflict = false; bool conflict = false;
for (ClassMap::iterator i = classMap.begin(); i != classMap.end(); ++i) for (ClassMap::iterator i = classMap.begin(); i != classMap.end(); ++i)

View file

@ -26,9 +26,14 @@ OutputEqClass findOutputEqClass(const Derivation & drv,
const string & id); const string & id);
/* Return any trusted path (wrt to the given trust ID) in the given /* Return anll trusted path (wrt to the given trust ID) in the given
output path equivalence class, or "" if no such path currently output path equivalence class, or an empty set if no such paths
exists. */ currently exist. */
PathSet findTrustedEqClassMembers(const OutputEqClass & eqClass,
const TrustId & trustId);
/* Like `findTrustedEqClassMembers', but returns an arbitrary trusted
path, or throws an exception if no such path currently exists. */
Path findTrustedEqClassMember(const OutputEqClass & eqClass, Path findTrustedEqClassMember(const OutputEqClass & eqClass,
const TrustId & trustId); const TrustId & trustId);