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

in the middle of adding nixStoreState ...

This commit is contained in:
Wouter den Breejen 2007-05-18 19:50:58 +00:00
parent 4c63f18dcc
commit 8a7874d77d
11 changed files with 138 additions and 22 deletions

View file

@ -588,6 +588,9 @@ private:
/* The temporary directory. */
Path tmpDir;
/* The state directory. */
Path stateDir;
/* File descriptor for the log file. */
AutoCloseFD fdLogFile;
@ -759,7 +762,7 @@ void DerivationGoal::haveDerivation()
assert(store->isValidPath(drvPath));
/* Get the derivation. */
drv = derivationFromPath(drvPath);
drv = derivationFromPath(drvPath); //wouter look here
for (DerivationOutputs::iterator i = drv.outputs.begin();
i != drv.outputs.end(); ++i)
@ -1370,6 +1373,11 @@ void DerivationGoal::startBuilder()
/* Create a temporary directory where the build will take
place. */
tmpDir = createTempDir();
/* Create the state directory where the component can store it's state files place */
stateDir = createStateDirs(drv.stateOutputDirs, drv.stateOutputs);
//TODO create the startupscript
/* For convenience, set an environment pointing to the top build
directory. */

View file

@ -82,6 +82,34 @@ Derivation parseDerivation(ATerm t)
out.hash = aterm2String(hash);
drv.outputs[aterm2String(id)] = out;
}
//parse state part
for (ATermIterator i(stateOuts); i; ++i) {
ATerm id, statepath, hashAlgo, hash, enabled, shared, synchronization;
if (!matchDerivationStateOutput(*i, id, statepath, hashAlgo, hash, enabled, shared, synchronization))
throwBadDrv(t);
DerivationStateOutput stateOut;
stateOut.statepath = aterm2String(statepath);
//checkPath(stateOut.path); //should we check the statpath .... ???
stateOut.hashAlgo = aterm2String(hashAlgo);
stateOut.hash = aterm2String(hash);
stateOut.enabled = aterm2String(enabled);
stateOut.shared = aterm2String(shared);
stateOut.synchronization = aterm2String(synchronization);
drv.stateOutputs[aterm2String(id)] = stateOut;
}
//parse state dirs part
for (ATermIterator i(stateOutDirs); i; ++i) {
ATerm id, path, type, interval;
if (!matchDerivationStateOutputDir(*i, id, path, type, interval))
throwBadDrv(t);
DerivationStateOutputDir stateOutDirs;
stateOutDirs.path = aterm2String(path);
stateOutDirs.type = aterm2String(type);
stateOutDirs.interval = aterm2String(interval);
drv.stateOutputDirs[aterm2String(id)] = stateOutDirs;
}
for (ATermIterator i(inDrvs); i; ++i) {
ATerm drvPath;

View file

@ -69,6 +69,12 @@ struct DerivationStateOutputDir
this->type = type;
this->interval = interval;
}
//sort function
/*bool operator<(const DerivationStateOutputDir& a, const DerivationStateOutputDir& b) {
return a.path < b.path;
} */
bool operator<(const DerivationStateOutputDir& a) const { return path < a.path; }
};

View file

@ -9,6 +9,7 @@ namespace nix {
string nixStore = "/UNINIT";
string nixStoreState = "/UNINIT";
string nixDataDir = "/UNINIT";
string nixLogDir = "/UNINIT";
string nixStateDir = "/UNINIT";

View file

@ -18,8 +18,8 @@ extern string nixDataDir; /* !!! fix */
/* nixLogDir is the directory where we log various operations. */
extern string nixLogDir;
/* nixStateDir is the directory where state is stored. */
extern string nixStateDir;
/* nixStateDir is the directory where the state dirs of the components are stored. */
extern string nixStoreState;
/* nixDBPath is the path name of our Berkeley DB environment. */
extern string nixDBPath;

View file

@ -66,8 +66,7 @@ void checkStoreName(const string & name)
}
Path makeStorePath(const string & type,
const Hash & hash, const string & suffix)
Path makeStorePath(const string & type, const Hash & hash, const string & suffix)
{
/* e.g., "source:sha256:1abc...:/nix/store:foo.tar.gz" */
string s = type + ":sha256:" + printHash(hash) + ":"
@ -80,6 +79,20 @@ Path makeStorePath(const string & type,
+ "-" + suffix;
}
Path makeStatePath(const string & type, const Hash & hash, const string & suffix)
{
/* e.g., "source:sha256:1abc...:/nix/store:foo.tar.gz" */
string s = type + ":sha256:" + printHash(hash) + ":"
+ nixStoreState + ":" + suffix;
checkStoreName(suffix);
return nixStoreState + "/"
+ printHash32(compressHash(hashString(htSHA256, s), 20))
+ "-" + suffix;
}
Path makeFixedOutputPath(bool recursive,
string hashAlgo, Hash hash, string name)