mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
Before adjusting computeFSClosure
This commit is contained in:
parent
b32691da2b
commit
7eb2f61797
5 changed files with 68 additions and 31 deletions
|
|
@ -582,6 +582,9 @@ private:
|
||||||
/* Referenceable paths (i.e., input and output paths). */
|
/* Referenceable paths (i.e., input and output paths). */
|
||||||
PathSet allPaths;
|
PathSet allPaths;
|
||||||
|
|
||||||
|
/* Referenceable paths (i.e., input and output paths). */
|
||||||
|
PathSet allStatePaths;
|
||||||
|
|
||||||
/* User selected for running the builder. */
|
/* User selected for running the builder. */
|
||||||
UserLock buildUser;
|
UserLock buildUser;
|
||||||
|
|
||||||
|
|
@ -1295,8 +1298,7 @@ bool DerivationGoal::prepareBuild()
|
||||||
running the build hook. */
|
running the build hook. */
|
||||||
|
|
||||||
/* The outputs are referenceable paths. */
|
/* The outputs are referenceable paths. */
|
||||||
for (DerivationOutputs::iterator i = drv.outputs.begin();
|
for (DerivationOutputs::iterator i = drv.outputs.begin(); i != drv.outputs.end(); ++i)
|
||||||
i != drv.outputs.end(); ++i)
|
|
||||||
{
|
{
|
||||||
debug(format("building path `%1%'") % i->second.path);
|
debug(format("building path `%1%'") % i->second.path);
|
||||||
allPaths.insert(i->second.path);
|
allPaths.insert(i->second.path);
|
||||||
|
|
@ -1305,16 +1307,14 @@ bool DerivationGoal::prepareBuild()
|
||||||
/* Determine the full set of input paths. */
|
/* Determine the full set of input paths. */
|
||||||
|
|
||||||
/* First, the input derivations. */
|
/* First, the input derivations. */
|
||||||
for (DerivationInputs::iterator i = drv.inputDrvs.begin();
|
for (DerivationInputs::iterator i = drv.inputDrvs.begin(); i != drv.inputDrvs.end(); ++i)
|
||||||
i != drv.inputDrvs.end(); ++i)
|
|
||||||
{
|
{
|
||||||
/* Add the relevant output closures of the input derivation
|
/* Add the relevant output closures of the input derivation
|
||||||
`*i' as input paths. Only add the closures of output paths
|
`*i' as input paths. Only add the closures of output paths
|
||||||
that are specified as inputs. */
|
that are specified as inputs. */
|
||||||
assert(store->isValidPath(i->first));
|
assert(store->isValidPath(i->first));
|
||||||
Derivation inDrv = derivationFromPath(i->first);
|
Derivation inDrv = derivationFromPath(i->first);
|
||||||
for (StringSet::iterator j = i->second.begin();
|
for (StringSet::iterator j = i->second.begin(); j != i->second.end(); ++j)
|
||||||
j != i->second.end(); ++j)
|
|
||||||
if (inDrv.outputs.find(*j) != inDrv.outputs.end())
|
if (inDrv.outputs.find(*j) != inDrv.outputs.end())
|
||||||
computeFSClosure(inDrv.outputs[*j].path, inputPaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
computeFSClosure(inDrv.outputs[*j].path, inputPaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||||
else
|
else
|
||||||
|
|
@ -1324,8 +1324,7 @@ bool DerivationGoal::prepareBuild()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Second, the input sources. */
|
/* Second, the input sources. */
|
||||||
for (PathSet::iterator i = drv.inputSrcs.begin();
|
for (PathSet::iterator i = drv.inputSrcs.begin(); i != drv.inputSrcs.end(); ++i)
|
||||||
i != drv.inputSrcs.end(); ++i)
|
|
||||||
computeFSClosure(*i, inputPaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
computeFSClosure(*i, inputPaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||||
|
|
||||||
debug(format("added input paths %1%") % showPaths(inputPaths));
|
debug(format("added input paths %1%") % showPaths(inputPaths));
|
||||||
|
|
@ -1759,7 +1758,7 @@ void DerivationGoal::computeClosure()
|
||||||
* [scan for and state references and component references in the state path] //3,4
|
* [scan for and state references and component references in the state path] //3,4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PathSet allStatePaths;
|
PathSet allStatePaths2;
|
||||||
for (PathSet::const_iterator i = allPaths.begin(); i != allPaths.end(); i++){
|
for (PathSet::const_iterator i = allPaths.begin(); i != allPaths.end(); i++){
|
||||||
Path componentPath = *i;
|
Path componentPath = *i;
|
||||||
|
|
||||||
|
|
@ -1772,7 +1771,7 @@ void DerivationGoal::computeClosure()
|
||||||
//The we can dismiss the call to queryDeriversStatePath(...), and we only have to do registerValidPath once
|
//The we can dismiss the call to queryDeriversStatePath(...), and we only have to do registerValidPath once
|
||||||
|
|
||||||
PathSet stateRefs = queryDeriversStatePath(txn, componentPath ,"*",getCallingUserName());
|
PathSet stateRefs = queryDeriversStatePath(txn, componentPath ,"*",getCallingUserName());
|
||||||
allStatePaths = mergePathSets(stateRefs, allStatePaths);
|
allStatePaths2 = mergePathSets(stateRefs, allStatePaths2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1782,10 +1781,10 @@ void DerivationGoal::computeClosure()
|
||||||
Path path = i->second.path;
|
Path path = i->second.path;
|
||||||
|
|
||||||
//We scan for state references in the component path
|
//We scan for state references in the component path
|
||||||
PathSet output_state_references = scanForReferences(path, allStatePaths);
|
PathSet output_state_references = scanForReferences(path, allStatePaths2);
|
||||||
|
|
||||||
//debugging
|
//debugging
|
||||||
for (PathSet::const_iterator i = allStatePaths.begin(); i != allStatePaths.end(); i++)
|
for (PathSet::const_iterator i = allStatePaths2.begin(); i != allStatePaths2.end(); i++)
|
||||||
debug(format("all possible StatePaths: %1%") % (*i));
|
debug(format("all possible StatePaths: %1%") % (*i));
|
||||||
for (PathSet::const_iterator i = output_state_references.begin(); i != output_state_references.end(); i++)
|
for (PathSet::const_iterator i = output_state_references.begin(); i != output_state_references.end(); i++)
|
||||||
debug(format("state References scanned: %1%") % (*i));
|
debug(format("state References scanned: %1%") % (*i));
|
||||||
|
|
@ -1804,7 +1803,7 @@ void DerivationGoal::computeClosure()
|
||||||
printMsg(lvlTalkative, format("scanning for component and state references inside `%1%'") % statePath);
|
printMsg(lvlTalkative, format("scanning for component and state references inside `%1%'") % statePath);
|
||||||
|
|
||||||
state_references = scanForReferences(statePath, allPaths);
|
state_references = scanForReferences(statePath, allPaths);
|
||||||
state_stateReferences = scanForReferences(statePath, allStatePaths);
|
state_stateReferences = scanForReferences(statePath, allStatePaths2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Register all outputs now valid
|
//Register all outputs now valid
|
||||||
|
|
|
||||||
|
|
@ -1549,6 +1549,7 @@ void LocalStore::storePathStateRequisitesOnly(const Path & storePath, const bool
|
||||||
* Not used yet ......................... (should we use it .... ???)
|
* Not used yet ......................... (should we use it .... ???)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
void getDependenciesAtBuildTime(const Transaction & txn, const Path & drvPath)
|
void getDependenciesAtBuildTime(const Transaction & txn, const Path & drvPath)
|
||||||
{
|
{
|
||||||
Derivation drv = derivationFromPath(drvPath);
|
Derivation drv = derivationFromPath(drvPath);
|
||||||
|
|
@ -1557,21 +1558,20 @@ void getDependenciesAtBuildTime(const Transaction & txn, const Path & drvPath)
|
||||||
|
|
||||||
//TODO THIS IS A DIRECT COPY FROM BUILD.CC WE SHOULD MERGE !!!!!!!!!!!!1!!!!!!!!!!!!!
|
//TODO THIS IS A DIRECT COPY FROM BUILD.CC WE SHOULD MERGE !!!!!!!!!!!!1!!!!!!!!!!!!!
|
||||||
|
|
||||||
/* The outputs are referenceable paths. */
|
// The outputs are referenceable paths.
|
||||||
for (DerivationOutputs::iterator i = drv.outputs.begin();
|
for (DerivationOutputs::iterator i = drv.outputs.begin(); i != drv.outputs.end(); ++i)
|
||||||
i != drv.outputs.end(); ++i)
|
|
||||||
{
|
{
|
||||||
debug(format("building path `%1%'") % i->second.path);
|
debug(format("building path `%1%'") % i->second.path);
|
||||||
allPaths.insert(i->second.path);
|
allPaths.insert(i->second.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* First, the input derivations. */
|
// First, the input derivations.
|
||||||
for (DerivationInputs::iterator i = drv.inputDrvs.begin();
|
for (DerivationInputs::iterator i = drv.inputDrvs.begin();
|
||||||
i != drv.inputDrvs.end(); ++i)
|
i != drv.inputDrvs.end(); ++i)
|
||||||
{
|
{
|
||||||
/* Add the relevant output closures of the input derivation
|
// Add the relevant output closures of the input derivation
|
||||||
`*i' as input paths. Only add the closures of output paths
|
// `*i' as input paths. Only add the closures of output paths
|
||||||
that are specified as inputs. */
|
// that are specified as inputs.
|
||||||
assert(store->isValidPath(i->first));
|
assert(store->isValidPath(i->first));
|
||||||
Derivation inDrv = derivationFromPath(i->first);
|
Derivation inDrv = derivationFromPath(i->first);
|
||||||
for (StringSet::iterator j = i->second.begin(); j != i->second.end(); ++j)
|
for (StringSet::iterator j = i->second.begin(); j != i->second.end(); ++j)
|
||||||
|
|
@ -1581,7 +1581,7 @@ void getDependenciesAtBuildTime(const Transaction & txn, const Path & drvPath)
|
||||||
throw Error(format("derivation `%1%' requires non-existent output `%2%' from input derivation `%3%'") % drvPath % *j % i->first);
|
throw Error(format("derivation `%1%' requires non-existent output `%2%' from input derivation `%3%'") % drvPath % *j % i->first);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Second, the input sources. */
|
// Second, the input sources.
|
||||||
for (PathSet::iterator i = drv.inputSrcs.begin(); i != drv.inputSrcs.end(); ++i)
|
for (PathSet::iterator i = drv.inputSrcs.begin(); i != drv.inputSrcs.end(); ++i)
|
||||||
computeFSClosure(*i, inputPaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
computeFSClosure(*i, inputPaths, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||||
|
|
||||||
|
|
@ -1591,6 +1591,7 @@ void getDependenciesAtBuildTime(const Transaction & txn, const Path & drvPath)
|
||||||
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i)
|
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i)
|
||||||
printMsg(lvlError, format("ALLPATHS2: %1%") % *i);
|
printMsg(lvlError, format("ALLPATHS2: %1%") % *i);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void scanForAllReferences(const Transaction & txn, const Path & statePath)
|
void scanForAllReferences(const Transaction & txn, const Path & statePath)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -43,13 +43,13 @@ bool isStatePath(const Path & path)
|
||||||
void assertStorePath(const Path & path)
|
void assertStorePath(const Path & path)
|
||||||
{
|
{
|
||||||
if (!isStorePath(path))
|
if (!isStorePath(path))
|
||||||
throw Error(format("component path `%1%' is not in the Nix store (1)") % path); //TODO bug: this prints an empty path ...
|
throw Error(format("component path `%1%' is not in the Nix store") % path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertStatePath(const Path & path)
|
void assertStatePath(const Path & path)
|
||||||
{
|
{
|
||||||
if (!isStatePath(path))
|
if (!isStatePath(path))
|
||||||
throw Error(format("state path `%1%' is not in the Nix state-store (1)") % path); //TODO bug: this prints an empty path ...
|
throw Error(format("state path `%1%' is not in the Nix state-store") % path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -64,6 +64,26 @@ Path toStorePath(const Path & path)
|
||||||
return Path(path, 0, slash);
|
return Path(path, 0, slash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Path toStoreOrStatePath(const Path & path)
|
||||||
|
{
|
||||||
|
bool isStorePath = isInStore(path);
|
||||||
|
bool isStateStore = isInStateStore(path);
|
||||||
|
|
||||||
|
if (!isStorePath && !isStateStore)
|
||||||
|
throw Error(format("path `%1%' is not in the Nix store or Nix state store") % path);
|
||||||
|
|
||||||
|
Path::size_type slash;
|
||||||
|
if(isStorePath)
|
||||||
|
slash = path.find('/', nixStore.size() + 1);
|
||||||
|
else
|
||||||
|
slash = path.find('/', nixStoreState.size() + 1);
|
||||||
|
|
||||||
|
if (slash == Path::npos)
|
||||||
|
return path;
|
||||||
|
else
|
||||||
|
return Path(path, 0, slash);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void checkStoreName(const string & name)
|
void checkStoreName(const string & name)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ void checkStoreName(const string & name);
|
||||||
/* Chop off the parts after the top-level store name, e.g.,
|
/* Chop off the parts after the top-level store name, e.g.,
|
||||||
/nix/store/abcd-foo/bar => /nix/store/abcd-foo. */
|
/nix/store/abcd-foo/bar => /nix/store/abcd-foo. */
|
||||||
Path toStorePath(const Path & path);
|
Path toStorePath(const Path & path);
|
||||||
|
Path toStoreOrStatePath(const Path & path);
|
||||||
|
|
||||||
/* Constructs a unique store path name. */
|
/* Constructs a unique store path name. */
|
||||||
Path makeStorePath(const string & type,
|
Path makeStorePath(const string & type,
|
||||||
|
|
|
||||||
|
|
@ -29,18 +29,32 @@ static Path gcRoot;
|
||||||
static int rootNr = 0;
|
static int rootNr = 0;
|
||||||
static bool indirectRoot = false;
|
static bool indirectRoot = false;
|
||||||
|
|
||||||
|
//Fixes the path and checks if it is a store path , see also toStorePath
|
||||||
static Path fixPath(Path path)
|
static Path fixPath(Path path)
|
||||||
{
|
{
|
||||||
path = absPath(path);
|
path = absPath(path);
|
||||||
while (!isInStore(path)) {
|
while (!isInStore(path)) {
|
||||||
if (!isLink(path)) break;
|
if (!isLink(path))
|
||||||
|
break;
|
||||||
string target = readLink(path);
|
string target = readLink(path);
|
||||||
path = absPath(target, dirOf(path));
|
path = absPath(target, dirOf(path));
|
||||||
}
|
}
|
||||||
return toStorePath(path);
|
return toStorePath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Fixes the path and checks if it is a store or state path
|
||||||
|
static Path fixStoreOrStatePath(Path path)
|
||||||
|
{
|
||||||
|
path = absPath(path);
|
||||||
|
while (!isInStore(path) && !isInStateStore(path)) {
|
||||||
|
if (!isLink(path))
|
||||||
|
break;
|
||||||
|
string target = readLink(path);
|
||||||
|
path = absPath(target, dirOf(path));
|
||||||
|
}
|
||||||
|
return toStoreOrStatePath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static Path useDeriver(Path path)
|
static Path useDeriver(Path path)
|
||||||
{
|
{
|
||||||
|
|
@ -162,10 +176,13 @@ static void opPrintFixedPath(Strings opFlags, Strings opArgs)
|
||||||
parseHash16or32(parseHashType(hashAlgo), hash), name);
|
parseHash16or32(parseHashType(hashAlgo), hash), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* .....??
|
||||||
|
*/
|
||||||
static Path maybeUseOutput(const Path & storePath, bool useOutput, bool forceRealise)
|
static Path maybeUseOutput(const Path & storePath, bool useOutput, bool forceRealise)
|
||||||
{
|
{
|
||||||
if (forceRealise) realisePath(storePath);
|
if (forceRealise)
|
||||||
|
realisePath(storePath);
|
||||||
if (useOutput && isDerivation(storePath)) {
|
if (useOutput && isDerivation(storePath)) {
|
||||||
Derivation drv = derivationFromPath(storePath);
|
Derivation drv = derivationFromPath(storePath);
|
||||||
return findOutput(drv, "out");
|
return findOutput(drv, "out");
|
||||||
|
|
@ -286,7 +303,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
||||||
for (Strings::iterator i = opArgs.begin();
|
for (Strings::iterator i = opArgs.begin();
|
||||||
i != opArgs.end(); ++i)
|
i != opArgs.end(); ++i)
|
||||||
{
|
{
|
||||||
Path path = maybeUseOutput(fixPath(*i), useOutput, forceRealise); //TODO This hangs on state paths ...
|
Path path = maybeUseOutput(fixStoreOrStatePath(*i), useOutput, forceRealise);
|
||||||
if (query == qRequisites) store->storePathRequisites(path, includeOutputs, paths, false);
|
if (query == qRequisites) store->storePathRequisites(path, includeOutputs, paths, false);
|
||||||
else if (query == qRequisitesState) store->storePathStateRequisitesOnly(path, includeOutputs, paths);
|
else if (query == qRequisitesState) store->storePathStateRequisitesOnly(path, includeOutputs, paths);
|
||||||
else if (query == qRequisitesFull) store->storePathRequisites(path, includeOutputs, paths, true);
|
else if (query == qRequisitesFull) store->storePathRequisites(path, includeOutputs, paths, true);
|
||||||
|
|
@ -339,7 +356,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case qTree: {
|
case qTree: { //TODO include state path?
|
||||||
PathSet done;
|
PathSet done;
|
||||||
for (Strings::iterator i = opArgs.begin();
|
for (Strings::iterator i = opArgs.begin();
|
||||||
i != opArgs.end(); ++i)
|
i != opArgs.end(); ++i)
|
||||||
|
|
@ -347,7 +364,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case qGraph: {
|
case qGraph: { //TOOD include state path?
|
||||||
PathSet roots;
|
PathSet roots;
|
||||||
for (Strings::iterator i = opArgs.begin();
|
for (Strings::iterator i = opArgs.begin();
|
||||||
i != opArgs.end(); ++i)
|
i != opArgs.end(); ++i)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue