diff options
author | Michael Raskin <7c6f434c@mail.ru> | 2007-12-30T09·30+0000 |
---|---|---|
committer | Michael Raskin <7c6f434c@mail.ru> | 2007-12-30T09·30+0000 |
commit | 2196cb67c5a47eeb822351f1669c201e16ea6ebc (patch) | |
tree | 531491033cdfc7745a36dcba64866aeffc2d0849 /src/libstore | |
parent | df303666bceb5715e706478fad0325447a2a52f6 (diff) |
Added a way to include derivation with its outputs and dependencies - exportBuildReferenceGraph
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/build.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc index d46286713253..6f045dbc3774 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1619,6 +1619,44 @@ void DerivationGoal::startBuilder() makeValidityRegistration(refs, false)); } + // The same for derivations + s = drv.env["exportBuildReferencesGraph"]; + ss = tokenizeString(s); + if (ss.size() % 2 != 0) + throw BuildError(format("odd number of tokens in `exportReferencesGraph': `%1%'") % s); + for (Strings::iterator i = ss.begin(); i != ss.end(); ) { + string fileName = *i++; + checkStoreName(fileName); /* !!! abuse of this function */ + + /* Check that the store path is valid. */ + Path storePath = *i++; + if (!isInStore(storePath)) + throw BuildError(format("`exportReferencesGraph' contains a non-store path `%1%'") + % storePath); + storePath = toStorePath(storePath); + if (!store->isValidPath(storePath)) + throw BuildError(format("`exportReferencesGraph' contains an invalid path `%1%'") + % storePath); + + /* Write closure info to `fileName'. */ + PathSet refs1,refs; + computeFSClosure(storePath, refs1); + for (PathSet::iterator j = refs1.begin(); j != refs1.end() ; j++) { + refs.insert (*j); + if (isDerivation (*j)) { + Derivation deriv = derivationFromPath (*j); + for (DerivationOutputs::iterator k=deriv.outputs.begin(); + k != deriv.outputs.end(); k++) { + refs.insert(k->second.path); + } + } + } + /* !!! in secure Nix, the writing should be done on the + build uid for security (maybe). */ + writeStringToFile(tmpDir + "/" + fileName, + makeValidityRegistration(refs, false)); + } + /* If `build-users-group' is not empty, then we have to build as one of the members of that group. */ |