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

* Maintain the output path equivalence class, and use it. Now we can

actually build stuff with dependencies.
This commit is contained in:
Eelco Dolstra 2005-05-25 20:47:04 +00:00
parent f2802aa7ba
commit 75454567f7
4 changed files with 80 additions and 5 deletions

View file

@ -139,6 +139,10 @@ static void initAndRun(int argc, char * * argv)
/* ATerm stuff. !!! find a better place to put this */
initDerivationsHelpers();
/* Random number generator needed by makeRandomStorePath(); !!!
improve. */
srand(time(0));
/* Put the arguments in a vector. */
Strings args, remaining;

View file

@ -914,7 +914,7 @@ bool DerivationGoal::prepareBuild()
rewrites[hashPartOf(i->second.eqClass)] = hashPartOf(tmpPath);
tmpOutputs[i->second.eqClass] = tmpPath;
}
/* Obtain locks on all output paths. The locks are automatically
released when we exit this function or Nix crashes. */
/* !!! BUG: this could block, which is not allowed. */
@ -959,6 +959,7 @@ bool DerivationGoal::prepareBuild()
debug(format("building path `%1%'") % i->second.path);
allPaths.insert(i->second.path);
}
#endif
/* Determine the full set of input paths. */
@ -973,9 +974,25 @@ bool DerivationGoal::prepareBuild()
Derivation inDrv = derivationFromPath(i->first);
for (StringSet::iterator j = i->second.begin();
j != i->second.end(); ++j)
if (inDrv.outputs.find(*j) != inDrv.outputs.end())
if (inDrv.outputs.find(*j) != inDrv.outputs.end()) {
OutputEqClass eqClass = inDrv.outputs[*j].eqClass;
OutputEqMembers members;
queryOutputEqMembers(noTxn, eqClass, members);
if (members.size() == 0)
throw Error(format("output equivalence class `%1%' has no members!")
% eqClass);
Path input = members.front().path;
rewrites[hashPartOf(eqClass)] = hashPartOf(input);
#if 0
computeFSClosure(inDrv.outputs[*j].path, inputPaths);
else
#endif
} else
throw Error(
format("derivation `%1%' requires non-existent output `%2%' from input derivation `%3%'")
% drvPath % *j % i->first);
@ -989,7 +1006,6 @@ bool DerivationGoal::prepareBuild()
debug(format("added input paths %1%") % showPaths(inputPaths));
allPaths.insert(inputPaths.begin(), inputPaths.end());
#endif
return true;
}
@ -1144,6 +1160,15 @@ void DerivationGoal::computeClosure()
Path finalPath = addToStore(i->second, hashPartOf(i->second),
namePartOf(i->second));
printMsg(lvlError, format("produced final path `%1%'") % finalPath);
/* Register the fact that this output path is a member of some
output path equivalence class (for a certain user, at
least). This is how subsequent derivations will be able to
find it. */
Transaction txn;
createStoreTransaction(txn);
addOutputEqMember(txn, i->first, "root", finalPath);
txn.commit();
}
#if 0

View file

@ -448,10 +448,52 @@ void queryReferers(const Transaction & txn,
}
void addOutputEqMember(const Transaction & txn,
const OutputEqClass & eqClass, const TrustId & trustId,
const Path & path)
{
OutputEqMembers members;
queryOutputEqMembers(txn, eqClass, members);
for (OutputEqMembers::iterator i = members.begin();
i != members.end(); ++i)
if (i->trustId == trustId && i->path == path) return;
OutputEqMember member;
member.trustId = trustId;
member.path = path;
members.push_back(member);
Strings ss;
for (OutputEqMembers::iterator i = members.begin();
i != members.end(); ++i)
{
Strings ss2;
ss2.push_back(i->trustId);
ss2.push_back(i->path);
ss.push_back(packStrings(ss2));
}
nixDB.setStrings(txn, dbEquivalences, eqClass, ss);
}
void queryOutputEqMembers(const Transaction & txn,
const OutputEqClass & eqClass, OutputEqMembers & members)
{
assert(0);
Strings ss;
nixDB.queryStrings(txn, dbEquivalences, eqClass, ss);
for (Strings::iterator i = ss.begin(); i != ss.end(); ++i) {
Strings ss2 = unpackStrings(*i);
if (ss2.size() != 2) continue;
Strings::iterator j = ss2.begin();
OutputEqMember member;
member.trustId = *j++;
member.path = *j++;
members.push_back(member);
}
}

View file

@ -187,6 +187,10 @@ void queryReferences(const Transaction & txn,
void queryReferers(const Transaction & txn,
const Path & storePath, PathSet & referers);
void addOutputEqMember(const Transaction & txn,
const OutputEqClass & eqClass, const TrustId & trustId,
const Path & path);
void queryOutputEqMembers(const Transaction & txn,
const OutputEqClass & eqClass, OutputEqMembers & members);