mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 20:20:58 +01:00
Finished set-up for nix-state, now: adding runtime state parameters & exclude state-identifier as input from state-hash
This commit is contained in:
parent
0a303ea2c0
commit
fbd1b78a9d
10 changed files with 120 additions and 74 deletions
|
|
@ -41,7 +41,7 @@ struct DerivationStateOutput
|
|||
string hash;
|
||||
string enabled;
|
||||
string shared; //none, full, group
|
||||
string synchronization; //none, ... ?
|
||||
string synchronization; //none, exclusive-lock-on-own-state-dir, exclusive-lock-on-all-(sub)-states-dir
|
||||
string createDirsBeforeInstall;
|
||||
DerivationStateOutput()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ LocalStore::LocalStore(bool reserveSpace)
|
|||
dbReferrers = nixDB.openTable("referrers", true); /* must be sorted */
|
||||
dbSubstitutes = nixDB.openTable("substitutes");
|
||||
dbDerivers = nixDB.openTable("derivers");
|
||||
dbStateCounters = nixDB.openTable("statecounters");
|
||||
|
||||
int curSchema = 0;
|
||||
Path schemaFN = nixDBPath + "/schema";
|
||||
|
|
@ -1095,6 +1096,59 @@ void verifyStore(bool checkContents)
|
|||
txn.commit();
|
||||
}
|
||||
|
||||
void setStatePathsInterval(const PathSet & statePaths, const vector<int> & intervals, bool allZero)
|
||||
{
|
||||
if(!allZero && statePaths.size() != intervals.size()){
|
||||
throw Error("the number of statepaths and intervals must be equal");
|
||||
}
|
||||
|
||||
Transaction txn(nixDB);
|
||||
|
||||
int n=0;
|
||||
for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i)
|
||||
{
|
||||
printMsg(lvlError, format("PATH: %1%") % *i);
|
||||
|
||||
int interval=0;
|
||||
if(!allZero)
|
||||
interval = intervals.at(n);
|
||||
|
||||
nixDB.setString(txn, dbStateCounters, *i, int2String(interval));
|
||||
n++;
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
void LocalStore::setStatePathsInterval(const PathSet & statePaths, const vector<int> & intervals, bool allZero)
|
||||
{
|
||||
nix::setStatePathsInterval(statePaths, intervals, allZero);
|
||||
}
|
||||
|
||||
vector<int> getStatePathsInterval(const PathSet & statePaths)
|
||||
{
|
||||
Transaction txn(nixDB); //TODO should u do a transaction here? ... this might delay the process ...
|
||||
|
||||
vector<int> intervals;
|
||||
string data;
|
||||
|
||||
for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i){
|
||||
|
||||
nixDB.queryString(txn, dbStateCounters, *i, data);
|
||||
printMsg(lvlError, format("Data %1%") % data);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
|
||||
return intervals;
|
||||
}
|
||||
|
||||
vector<int> LocalStore::getStatePathsInterval(const PathSet & statePaths)
|
||||
{
|
||||
return nix::getStatePathsInterval(statePaths);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Upgrade from schema 1 (Nix <= 0.7) to schema 2 (Nix >= 0.8). */
|
||||
static void upgradeStore07()
|
||||
|
|
|
|||
|
|
@ -75,6 +75,10 @@ public:
|
|||
|
||||
void collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||
bool ignoreLiveness, PathSet & result, unsigned long long & bytesFreed);
|
||||
|
||||
void setStatePathsInterval(const PathSet & statePath, const vector<int> & intervals, bool allZero = false);
|
||||
|
||||
vector<int> getStatePathsInterval(const PathSet & statePaths);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -375,5 +375,18 @@ void RemoteStore::processStderr(Sink * sink, Source * source)
|
|||
throw Error("protocol error processing standard error");
|
||||
}
|
||||
|
||||
//TODO
|
||||
void RemoteStore::setStatePathsInterval(const PathSet & statePaths, const vector<int> & intervals, bool allZero)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//TODO
|
||||
vector<int> RemoteStore::getStatePathsInterval(const PathSet & statePaths)
|
||||
{
|
||||
vector<int> intervals;
|
||||
return intervals;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,10 @@ public:
|
|||
|
||||
void collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||
bool ignoreLiveness, PathSet & result, unsigned long long & bytesFreed);
|
||||
|
||||
void setStatePathsInterval(const PathSet & statePath, const vector<int> & intervals, bool allZero = false);
|
||||
|
||||
vector<int> getStatePathsInterval(const PathSet & statePaths);
|
||||
|
||||
private:
|
||||
AutoCloseFD fdSocket;
|
||||
|
|
|
|||
|
|
@ -179,6 +179,12 @@ public:
|
|||
`bytesFreed'. */
|
||||
virtual void collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||
bool ignoreLiveness, PathSet & result, unsigned long long & bytesFreed) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual void setStatePathsInterval(const PathSet & statePath, const vector<int> & intervals, bool allZero = false) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual vector<int> getStatePathsInterval(const PathSet & statePaths) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,14 @@
|
|||
#include "util.hh"
|
||||
#include "derivations.hh"
|
||||
#include "store-api.hh"
|
||||
#include "local-store.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const DerivationStateOutputs & stateOutputs, const StringPairs & env)
|
||||
{
|
||||
string stateDir = stateOutputs.find("state")->second.statepath;
|
||||
Path statePath = stateOutputs.find("state")->second.statepath;
|
||||
string stateDir = statePath;
|
||||
string drvName = env.find("name")->second;
|
||||
|
||||
//Convert the map into a sortable vector
|
||||
|
|
@ -37,18 +39,20 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
|
|||
vector<int> subversionedpathsInterval;
|
||||
vector<string> nonversionedpaths; //of type none, no versioning needed
|
||||
vector<string> checkoutcommands;
|
||||
|
||||
PathSet statePaths;
|
||||
|
||||
for (vector<DerivationStateOutputDir>::iterator i = stateDirsVector.begin(); i != stateDirsVector.end(); ++i)
|
||||
{
|
||||
DerivationStateOutputDir d = *(i);
|
||||
|
||||
string thisdir = d.path;
|
||||
string fullstatedir = stateDir + "/" + thisdir;
|
||||
Path statePath = fullstatedir; //TODO call coerce function
|
||||
|
||||
//calc create repos for this state location
|
||||
Hash hash = hashString(htSHA256, stateDir + thisdir);
|
||||
string repos = makeStateReposPath("stateOutput:staterepospath", hash, drvName);
|
||||
|
||||
string repos = makeStateReposPath("stateOutput:staterepospath", hash, drvName);
|
||||
|
||||
//Were going to execute svn shell commands
|
||||
executeAndPrintShellCommand(svnadminbin + " create " + repos, "svnadmin"); //TODO create as nixbld.nixbld chmod 700
|
||||
|
||||
|
|
@ -67,8 +71,10 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
|
|||
checkoutcommands.push_back(checkoutcommand);
|
||||
subversionedpaths.push_back(fullstatedir);
|
||||
|
||||
if(d.type == "interval")
|
||||
if(d.type == "interval"){
|
||||
statePaths.insert(statePath);
|
||||
subversionedpathsInterval.push_back(d.getInterval());
|
||||
}
|
||||
else
|
||||
subversionedpathsInterval.push_back(0);
|
||||
|
||||
|
|
@ -78,6 +84,10 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
|
|||
}
|
||||
}
|
||||
|
||||
//Add the statePaths that have an interval
|
||||
vector<int> empty;
|
||||
store->setStatePathsInterval(statePaths, empty, true);
|
||||
|
||||
//create super commit script
|
||||
printMsg(lvlError, format("svnbin=%1%") % svnbin);
|
||||
string subversionedstatepathsarray = "subversionedpaths=( ";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue