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

Fixed some more remote-store store bugs. Users can now add state store components with nix-env. Paths in /nix/state are now chowned and chmodded to their owners

This commit is contained in:
Wouter den Breejen 2007-08-30 18:20:20 +00:00
parent 627afcc1aa
commit 30cf65af26
24 changed files with 327 additions and 255 deletions

View file

@ -1083,7 +1083,7 @@ static string makeValidityRegistration(const PathSet & paths,
s += deriver + "\n";
PathSet references;
store->queryReferences(*i, references, -1); //TODO check if this is ok
store->queryReferences(*i, references, 0); //TODO check if this is ok
s += (format("%1%\n") % references.size()).str();
@ -1200,7 +1200,7 @@ DerivationGoal::HookReply DerivationGoal::tryBuildHook()
*probably* already has it.) */
PathSet allInputs;
allInputs.insert(inputPaths.begin(), inputPaths.end());
computeFSClosure(drvPath, allInputs, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
computeFSClosure(drvPath, allInputs, true, false, 0); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
string s;
for (PathSet::iterator i = allInputs.begin();
@ -1323,8 +1323,8 @@ bool DerivationGoal::prepareBuild()
Derivation inDrv = derivationFromPathTxn(noTxn, i->first);
for (StringSet::iterator j = i->second.begin(); j != i->second.end(); ++j)
if (inDrv.outputs.find(*j) != inDrv.outputs.end()){
computeFSClosure(inDrv.outputs[*j].path, inputPaths, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE (done?)
computeFSClosure(inDrv.outputs[*j].path, inputStatePaths, false, true, -1); //TODO!!!!!!!!!!!!! HOW CAN THESE PATHS ALREADY BE VALID ..... ?????????????????????
computeFSClosure(inDrv.outputs[*j].path, inputPaths, true, false, 0); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE (done?)
computeFSClosure(inDrv.outputs[*j].path, inputStatePaths, false, true, 0); //TODO!!!!!!!!!!!!! HOW CAN THESE PATHS ALREADY BE VALID ..... ?????????????????????
}
else
throw BuildError(
@ -1334,8 +1334,8 @@ bool DerivationGoal::prepareBuild()
/* Second, the input sources. */
for (PathSet::iterator i = drv.inputSrcs.begin(); i != drv.inputSrcs.end(); ++i){
computeFSClosure(*i, inputPaths, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE (done?)
computeFSClosure(*i, inputStatePaths, false, true, -1);
computeFSClosure(*i, inputPaths, true, false, 0); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE (done?)
computeFSClosure(*i, inputStatePaths, false, true, 0);
}
debug(format("added input paths %1%") % showPaths(inputPaths));
@ -1400,7 +1400,7 @@ void DerivationGoal::startBuilder()
checkStatePath(drv);
if(drv.stateOutputs.find("state")->second.getCreateDirsBeforeInstall())
createStateDirsTxn(noTxn, drv.stateOutputDirs, drv.stateOutputs);
createSubStateDirsTxn(noTxn, drv.stateOutputDirs, drv.stateOutputs);
}
/* For convenience, set an environment pointing to the top build
@ -1463,7 +1463,7 @@ void DerivationGoal::startBuilder()
/* Write closure info to `fileName'. */
PathSet refs;
computeFSClosure(storePath, refs, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
computeFSClosure(storePath, refs, true, false, 0); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
/* !!! in secure Nix, the writing should be done on the
build uid for security (maybe). */
writeStringToFile(tmpDir + "/" + fileName,
@ -1640,7 +1640,7 @@ void DerivationGoal::computeClosure()
//We create state dirs only when state is enabled and when the dirs need to be created after the installation
if(drv.stateOutputs.size() != 0)
if(!drv.stateOutputs.find("state")->second.getCreateDirsBeforeInstall())
createStateDirsTxn(noTxn, drv.stateOutputDirs, drv.stateOutputs);
createSubStateDirsTxn(noTxn, drv.stateOutputDirs, drv.stateOutputs);
/*
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i)
@ -1795,7 +1795,7 @@ void DerivationGoal::computeClosure()
contentHashes[i->second.path],
allReferences[i->second.path], //set of component-references
allStateReferences[i->second.path], //set of state-references
drvPath, -1);
drvPath, 0);
}
//Register the state path valid
@ -1808,7 +1808,7 @@ void DerivationGoal::computeClosure()
Hash(), //emtpy hash
state_references,
state_stateReferences,
drvPath, -1);
drvPath, 0);
//Commit state (we only include our own state in the rivisionMapping (but other build component states might have been changed !!!! TODO)
RevisionClosure rivisionMapping;
@ -1816,7 +1816,7 @@ void DerivationGoal::computeClosure()
//Save the new revision
setStateRevisionsTxn(txn, rivisionMapping, statePath, "Initial build revision.");
//Shared state
Path sharedState = drv.stateOutputs.find("state")->second.sharedState;
if(sharedState != ""){
@ -1827,6 +1827,10 @@ void DerivationGoal::computeClosure()
//Set in database
setSharedStateTxn(txn, sharedState, statePath);
}
//If not shared: create the dir and set the rights
else{
setStatePathRights(statePath, queryCallingUsername(), "nixbld", "700");
}
}
txn.commit();
@ -2049,7 +2053,7 @@ void SubstitutionGoal::init()
/* To maintain the closure invariant, we first have to realise the
paths referenced by this one. */
store->queryReferences(storePath, references, -1);
store->queryReferences(storePath, references, 0);
for (PathSet::iterator i = references.begin();
i != references.end(); ++i)

View file

@ -449,25 +449,25 @@ void Database::enumTable(const Transaction & txn, TableId table,
/* State specific db functions */
Path Database::mergeToDBKey(const Path & statePath, const int revision)
Path Database::mergeToDBKey(const Path & statePath, const unsigned int intvalue)
{
string prefix = "-KEY-";
return statePath + prefix + int2String(revision);
return statePath + prefix + unsignedInt2String(intvalue);
}
void Database::splitDBKey(const Path & revisionedStatePath, Path & statePath, int & revision)
void Database::splitDBKey(const Path & revisionedStatePath, Path & statePath, unsigned int & intvalue)
{
string prefix = "-KEY-";
int pos = revisionedStatePath.find_last_of(prefix);
statePath = revisionedStatePath.substr(0, pos - prefix.length() + 1);
//printMsg(lvlError, format("'%2%' - '%1%'") % revisionedStatePath.substr(pos+1, revisionedStatePath.length()) % int2String(pos));
bool succeed = string2Int(revisionedStatePath.substr(pos+1, revisionedStatePath.length()), revision);
bool succeed = string2UnsignedInt(revisionedStatePath.substr(pos+1, revisionedStatePath.length()), intvalue);
if(!succeed)
throw Error(format("Malformed revision value of path '%1%'") % revisionedStatePath);
}
int Database::getNewRevisionNumber(const Transaction & txn, TableId table,
unsigned int Database::getNewRevisionNumber(const Transaction & txn, TableId table,
const Path & statePath)
{
//query
@ -476,37 +476,37 @@ int Database::getNewRevisionNumber(const Transaction & txn, TableId table,
if(!notEmpty){
setString(txn, table, statePath, int2String(1));
return 1;
return 1; //we begin counting from 1 since 0 is a special value representing the last revision
}
int revision;
bool succeed = string2Int(data, revision);
unsigned int revision;
bool succeed = string2UnsignedInt(data, revision);
if(!succeed)
throw Error(format("Malformed revision counter value of path '%1%'") % statePath);
revision++;
setString(txn, table, statePath, int2String(revision));
setString(txn, table, statePath, unsignedInt2String(revision));
return revision;
}
bool Database::lookupHighestRevivison(const Strings & keys, const Path & statePath, string & key, int lowerthan)
bool Database::lookupHighestRevivison(const Strings & keys, const Path & statePath, string & key, unsigned int lowerthan)
{
int highestRev = -1;
unsigned int highestRev = 0;
//Lookup which key we need
for (Strings::const_iterator i = keys.begin(); i != keys.end(); ++i) {
if((*i).substr(0, statePath.length()) != statePath || (*i).length() == statePath.length()) //dont check the new-revision key or other keys
if((*i).substr(0, statePath.length()) != statePath || (*i).length() == statePath.length()) //dont check the new-revision key or other keys
continue;
//printMsg(lvlError, format("'%1%' - '%2%'") % *i % statePath);
Path getStatePath;
int getRevision;
unsigned int getRevision;
splitDBKey(*i, getStatePath, getRevision);
if(getRevision > highestRev){
if(lowerthan != -1){
if(lowerthan != 0){
if(getRevision <= lowerthan) //if we have an uppper limit, see to it that we downt go over it
highestRev = getRevision;
}
@ -515,14 +515,14 @@ bool Database::lookupHighestRevivison(const Strings & keys, const Path & statePa
}
}
if(highestRev == -1) //no records found
if(highestRev == 0) //no records found
return false;
key = mergeToDBKey(statePath, highestRev); //final key that matches revision + statePath
return true;
}
bool Database::revisionToTimeStamp(const Transaction & txn, TableId revisions_table, const Path & statePath, const int revision, int & timestamp)
bool Database::revisionToTimeStamp(const Transaction & txn, TableId revisions_table, const Path & statePath, const int revision, unsigned int & timestamp)
{
string key = mergeToDBKey(statePath, revision);
Strings references;
@ -539,14 +539,16 @@ bool Database::revisionToTimeStamp(const Transaction & txn, TableId revisions_ta
}
void Database::setStateReferences(const Transaction & txn, TableId references_table, TableId revisions_table,
const Path & statePath, const Strings & references, int revision, int timestamp)
const Path & statePath, const Strings & references, const unsigned int revision, const unsigned int timestamp)
{
//printMsg(lvlError, format("setStateReferences '%1%' for '%2%'") % references_table % statePath);
if(revision == -1 && timestamp == -1)
timestamp = getTimeStamp();
if(revision != -1 && timestamp == -1){
bool found = revisionToTimeStamp(txn, revisions_table, statePath, revision, timestamp);
//Find the timestamp if we need
unsigned int timestamp2 = timestamp;
if(revision == 0 && timestamp == 0)
timestamp2 = getTimeStamp();
else if(revision != 0 && timestamp == 0){
bool found = revisionToTimeStamp(txn, revisions_table, statePath, revision, timestamp2);
if(!found)
throw Error(format("Revision '%1%' cannot be matched to a timestamp...") % revision);
}
@ -556,12 +558,12 @@ void Database::setStateReferences(const Transaction & txn, TableId references_ta
//Warning if it already exists
Strings empty;
if( queryStrings(txn, references_table, mergeToDBKey(statePath, timestamp), empty) )
if( queryStrings(txn, references_table, mergeToDBKey(statePath, timestamp2), empty) )
printMsg(lvlError, format("Warning: The timestamp '%1%' (now: '%5%') / revision '%4%' already exists for set-references of path '%2%' with db '%3%'")
% timestamp % statePath % references_table % revision % getTimeStamp());
% timestamp2 % statePath % references_table % revision % getTimeStamp());
//Create the key
string key = mergeToDBKey(statePath, timestamp);
string key = mergeToDBKey(statePath, timestamp2);
//printMsg(lvlError, format("Set references '%1%'") % key);
//for (Strings::const_iterator i = references.begin(); i != references.end(); ++i)
@ -572,13 +574,14 @@ void Database::setStateReferences(const Transaction & txn, TableId references_ta
}
bool Database::queryStateReferences(const Transaction & txn, TableId references_table, TableId revisions_table,
const Path & statePath, Strings & references, int revision, int timestamp)
const Path & statePath, Strings & references, const unsigned int revision, const unsigned int timestamp)
{
//printMsg(lvlError, format("queryStateReferences '%1%' with revision '%2%'") % references_table % revision);
//Convert revision to timestamp number useing the revisions_table
if(timestamp == -1 && revision != -1){
bool found = revisionToTimeStamp(txn, revisions_table, statePath, revision, timestamp);
unsigned int timestamp2 = timestamp;
if(timestamp == 0 && revision != 0){
bool found = revisionToTimeStamp(txn, revisions_table, statePath, revision, timestamp2);
if(!found) //we are asked for references of some revision, but there are no references registered yet, so we return false;
return false;
}
@ -588,7 +591,7 @@ bool Database::queryStateReferences(const Transaction & txn, TableId references_
//Mabye we need the latest timestamp?
string key = "";
if(timestamp == -1){
if(timestamp2 == 0){
bool foundsomething = lookupHighestRevivison(keys, statePath, key);
if(!foundsomething)
return false;
@ -597,21 +600,21 @@ bool Database::queryStateReferences(const Transaction & txn, TableId references_
}
//If a specific key is given: check if this timestamp exists key in the table
key = mergeToDBKey(statePath, timestamp);
key = mergeToDBKey(statePath, timestamp2);
bool found = false;
for (Strings::const_iterator i = keys.begin(); i != keys.end(); ++i) {
if(key == *i){
found = true;
key = mergeToDBKey(statePath, timestamp);
key = mergeToDBKey(statePath, timestamp2);
}
}
//If it doesn't exist in the table then find the highest key lower than it
if(!found){
bool foundsomething = lookupHighestRevivison(keys, statePath, key, -1);
bool foundsomething = lookupHighestRevivison(keys, statePath, key, 0);
if(!foundsomething)
return false;
//printMsg(lvlError, format("Warning: References for timestamp '%1%' not was not found, so taking the highest rev-key possible for statePath '%2%'") % timestamp % statePath);
//printMsg(lvlError, format("Warning: References for timestamp '%1%' not was not found, so taking the highest rev-key possible for statePath '%2%'") % timestamp2 % statePath);
}
return queryStrings(txn, references_table, key, references); //now that we have the key, we can query the references
@ -623,11 +626,11 @@ void Database::setStateRevisions(const Transaction & txn, TableId revisions_tabl
if( !isStatePath(rootStatePath) ) //weak check on statePath
throw Error(format("StatePath '%1%' is not a statepath") % rootStatePath);
int ts = getTimeStamp();
unsigned int timestamp = getTimeStamp();
//Insert all ss_epochs into snapshots_table with the current ts.
for (RevisionClosure::const_iterator i = revisions.begin(); i != revisions.end(); ++i){
string key = mergeToDBKey((*i).first, ts);
string key = mergeToDBKey((*i).first, timestamp);
Strings data;
//the map<> takes care of the sorting on the Path
for (Snapshots::const_iterator j = (*i).second.begin(); j != (*i).second.end(); ++j)
@ -639,25 +642,25 @@ void Database::setStateRevisions(const Transaction & txn, TableId revisions_tabl
for (RevisionClosure::const_iterator i = revisions.begin(); i != revisions.end(); ++i){
Path statePath = (*i).first;
int revision = getNewRevisionNumber(txn, revisions_table, statePath); //get a new revision number
unsigned int revision = getNewRevisionNumber(txn, revisions_table, statePath); //get a new revision number
string key = mergeToDBKey(statePath, revision);
//get all its requisites
PathSet statePath_references;
storePathRequisitesTxn(txn, statePath, false, statePath_references, false, true, -1);
storePathRequisitesTxn(txn, statePath, false, statePath_references, false, true, 0);
statePath_references.insert(statePath);
//save in db
Strings data;
for (PathSet::const_iterator j = statePath_references.begin(); j != statePath_references.end(); ++j)
data.push_back(mergeToDBKey(*j, ts));
data.push_back(mergeToDBKey(*j, timestamp));
setStrings(txn, revisions_table, key, data, false); //The false makes sure also empty revisions are set
//save the date and comments
Strings metadata;
metadata.push_back(int2String(ts));
metadata.push_back(unsignedInt2String(timestamp));
//get all paths that point to the same state (using shareing) and check if one of them equals the rootStatePath
PathSet sharedWith = getSharedWithPathSetRecTxn(txn, statePath);
@ -671,11 +674,11 @@ void Database::setStateRevisions(const Transaction & txn, TableId revisions_tabl
}
bool Database::queryStateRevisions(const Transaction & txn, TableId revisions_table, TableId snapshots_table,
const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, int root_revision)
const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const unsigned int root_revision)
{
string key;
if(root_revision == -1){
if(root_revision == 0){
Strings keys;
enumTable(txn, revisions_table, keys); //get all revisions
bool foundsomething = lookupHighestRevivison(keys, statePath, key);
@ -690,13 +693,13 @@ bool Database::queryStateRevisions(const Transaction & txn, TableId revisions_ta
bool notempty = queryStrings(txn, revisions_table, key, statePaths);
if(!notempty)
throw Error(format("Root revision '%1%' not found of statePath '%2%'") % int2String(root_revision) % statePath);
throw Error(format("Root revision '%1%' not found of statePath '%2%'") % unsignedInt2String(root_revision) % statePath);
//For each statePath add the revisions
for (Strings::iterator i = statePaths.begin(); i != statePaths.end(); ++i){
Path getStatePath;
int getTimestamp;
unsigned int getTimestamp;
splitDBKey(*i, getStatePath, getTimestamp);
//query state versioined directorys/files
@ -732,7 +735,6 @@ bool Database::queryStateRevisions(const Transaction & txn, TableId revisions_ta
timestamps[getStatePath] = getTimestamp;
}
return notempty;
}
@ -749,7 +751,7 @@ bool Database::queryAvailableStateRevisions(const Transaction & txn, TableId rev
continue;
Path getStatePath;
int getRevision;
unsigned int getRevision;
splitDBKey(*i, getStatePath, getRevision);
//save the date and comments

View file

@ -61,10 +61,10 @@ private:
void open2(const string & path, bool removeOldEnv);
/* TODO */
bool lookupHighestRevivison(const Strings & keys, const Path & statePath, string & key, int lowerthan = -1);
bool lookupHighestRevivison(const Strings & keys, const Path & statePath, string & key, unsigned int lowerthan = 0);
/* TODO */
int getNewRevisionNumber(const Transaction & txn, TableId table, const Path & statePath);
unsigned int getNewRevisionNumber(const Transaction & txn, TableId table, const Path & statePath);
public:
Database();
@ -97,21 +97,21 @@ public:
Strings & keys, const string & keyPrefix = "");
/* TODO */
Path mergeToDBKey(const Path & statePath, const int revision);
Path mergeToDBKey(const Path & statePath, const unsigned int intvalue);
/* TODO */
void splitDBKey(const Path & revisionedStatePath, Path & statePath, int & revision);
void splitDBKey(const Path & revisionedStatePath, Path & statePath, unsigned int & intvalue);
/* TODO */
bool revisionToTimeStamp(const Transaction & txn, TableId revisions_table, const Path & statePath, const int revision, int & timestamp);
bool revisionToTimeStamp(const Transaction & txn, TableId revisions_table, const Path & statePath, const int revision, unsigned int & timestamp);
/* Set the stateReferences for a specific revision (and older until the next higher revision number in the table) */
void setStateReferences(const Transaction & txn, TableId references_table, TableId revisions_table,
const Path & statePath, const Strings & references, int revision = -1, int timestamp = -1);
const Path & statePath, const Strings & references, const unsigned int revision = 0, const unsigned int timestamp = 0);
/* Returns the references for a specific revision (and older until the next higher revision number in the table) */
bool queryStateReferences(const Transaction & txn, TableId references_table, TableId revisions_table,
const Path & statePath, Strings & references, int revision = -1, int timestamp = -1);
const Path & statePath, Strings & references, const unsigned int revision = 0, const unsigned int timestamp = 0);
/* Set the revision number of the statePath and the revision numbers of all state paths in the references closure */
void setStateRevisions(const Transaction & txn, TableId revisions_table, TableId revisions_comments,
@ -119,7 +119,7 @@ public:
/* Returns all the revision numbers of the state references closure of the given state path */
bool queryStateRevisions(const Transaction & txn, TableId revisions_table, TableId snapshots_table,
const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, int root_revision = -1);
const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const unsigned int root_revision = 0);
/* Returns all available revision numbers of the given state path */
bool queryAvailableStateRevisions(const Transaction & txn, TableId revisions_table, TableId revisions_comments,

View file

@ -406,7 +406,7 @@ static void dfsVisit(const PathSet & paths, const Path & path,
PathSet references;
if (store->isValidPath(path))
store->queryReferences(path, references, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
store->queryReferences(path, references, 0); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
for (PathSet::iterator i = references.begin();
i != references.end(); ++i)
@ -469,7 +469,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
roots under the `references' relation. */
PathSet livePaths;
for (PathSet::const_iterator i = roots.begin(); i != roots.end(); ++i)
computeFSClosure(canonPath(*i), livePaths, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO DELETE STATE??
computeFSClosure(canonPath(*i), livePaths, true, false, 0); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO DELETE STATE??
if (gcKeepDerivations) {
for (PathSet::iterator i = livePaths.begin();
@ -480,7 +480,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
turned off). */
Path deriver = store->queryDeriver(*i);
if (deriver != "" && store->isValidPath(deriver))
computeFSClosure(deriver, livePaths, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
computeFSClosure(deriver, livePaths, true, false, 0); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
}
}
@ -493,7 +493,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
for (DerivationOutputs::iterator j = drv.outputs.begin();
j != drv.outputs.end(); ++j)
if (store->isValidPath(j->second.path))
computeFSClosure(j->second.path, livePaths, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
computeFSClosure(j->second.path, livePaths, true, false, 0); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
}
}
@ -518,7 +518,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
PathSet tempRootsClosed;
for (PathSet::iterator i = tempRoots.begin(); i != tempRoots.end(); ++i)
if (store->isValidPath(*i))
computeFSClosure(*i, tempRootsClosed, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO .... STATE
computeFSClosure(*i, tempRootsClosed, true, false, 0); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO .... STATE
else
tempRootsClosed.insert(*i);

View file

@ -29,7 +29,7 @@ string thisSystem = "unset";
unsigned int maxSilentTime = 0;
static bool settingsRead = false;
uid_t callingUID = 0; //A root user will not set this value, so the default uid is 0
bool debugWorker = false; //TODO still experimental
bool debugWorker = false; //TODO Still experimental ! this gives an store already open at the second call
static std::map<string, Strings> settings;

View file

@ -140,7 +140,7 @@ static TableId dbStateRevisions = 0;
*/
static TableId dbStateRevisionsComments = 0;
/* dbStateSnapshots :: StatePath -> IntVector
/* dbStateSnapshots :: StatePath -> RevisionClosure
*
* This table stores the snapshot numbers the sub state files/folders
* at a certain timestamp. These snapshot numbers are just timestamps
@ -446,7 +446,7 @@ static string stripPrefix(const string & prefix, const string & s)
void setReferences(const Transaction & txn, const Path & store_or_statePath,
const PathSet & references, const PathSet & stateReferences, const int revision)
const PathSet & references, const PathSet & stateReferences, const unsigned int revision)
{
/* For unrealisable paths, we can only clear the references. */
if (references.size() > 0 && !isRealisableComponentOrStatePath(txn, store_or_statePath))
@ -482,11 +482,11 @@ void setReferences(const Transaction & txn, const Path & store_or_statePath,
else if(isRealisableStatePath(txn, store_or_statePath))
{
printMsg(lvlError, format("Setting references for statepath '%1%' (revision:%2%)") % store_or_statePath % int2String(revision));
printMsg(lvlError, format("Setting references for statepath '%1%' (revision:%2%)") % store_or_statePath % unsignedInt2String(revision));
//Write references to a special revision (since there are multiple revisions of a statePath)
//query the references of revision (-1 is query the latest references)
//query the references of revision (0 is query the latest references)
Paths oldStateReferences_s_c;
Paths oldStateReferences_s_s;
nixDB.queryStateReferences(txn, dbStateComponentReferences, dbStateRevisions, store_or_statePath, oldStateReferences_s_c, revision);
@ -495,7 +495,7 @@ void setReferences(const Transaction & txn, const Path & store_or_statePath,
PathSet oldReferences = PathSet(oldStateReferences_s_c.begin(), oldStateReferences_s_c.end());
PathSet oldStateReferences = PathSet(oldStateReferences_s_s.begin(), oldStateReferences_s_s.end());
//set the references of revision (-1 insert as a new timestamp)
//set the references of revision (0 insert as a new timestamp)
nixDB.setStateReferences(txn, dbStateComponentReferences, dbStateRevisions, store_or_statePath, Paths(references.begin(), references.end()), revision);
nixDB.setStateReferences(txn, dbStateStateReferences, dbStateRevisions, store_or_statePath, Paths(stateReferences.begin(), stateReferences.end()), revision);
}
@ -504,7 +504,7 @@ void setReferences(const Transaction & txn, const Path & store_or_statePath,
}
void queryXReferencesTxn(const Transaction & txn, const Path & store_or_statePath, PathSet & references, const bool component_or_state, const int revision, int timestamp)
void queryXReferencesTxn(const Transaction & txn, const Path & store_or_statePath, PathSet & references, const bool component_or_state, const unsigned int revision, const unsigned int timestamp)
{
Paths references2;
TableId table1;
@ -531,17 +531,17 @@ void queryXReferencesTxn(const Transaction & txn, const Path & store_or_statePat
references.insert(references2.begin(), references2.end());
}
void LocalStore::queryReferences(const Path & storePath, PathSet & references, const int revision)
void LocalStore::queryReferences(const Path & storePath, PathSet & references, const unsigned int revision)
{
nix::queryXReferencesTxn(noTxn, storePath, references, revision, true);
}
void LocalStore::queryStateReferences(const Path & componentOrstatePath, PathSet & stateReferences, const int revision)
void LocalStore::queryStateReferences(const Path & componentOrstatePath, PathSet & stateReferences, const unsigned int revision)
{
nix::queryXReferencesTxn(noTxn, componentOrstatePath, stateReferences, revision, false);
}
static PathSet getXReferrers(const Transaction & txn, const Path & store_or_statePath, const bool component_or_state, const int revision)
static PathSet getXReferrers(const Transaction & txn, const Path & store_or_statePath, const bool component_or_state, const unsigned int revision)
{
TableId table = 0;
Path path;
@ -592,8 +592,8 @@ static PathSet getXReferrers(const Transaction & txn, const Path & store_or_stat
//printMsg(lvlError, format("we need state references: '%1%' '%2%' '%3%'") % path % store_or_statePath % table);
//Now in references of ALL referrers, (possibly lookup their latest TS based on revision)
int timestamp;
if(revision != -1){
unsigned int timestamp;
if(revision != 0){
bool succeed = nixDB.revisionToTimeStamp(txn, dbStateRevisions, path, revision, timestamp);
if(!succeed)
throw Error(format("Getreferrers cannot find timestamp for revision: '%1%'") % revision);
@ -601,16 +601,16 @@ static PathSet getXReferrers(const Transaction & txn, const Path & store_or_stat
Strings keys;
nixDB.enumTable(txn, table, keys);
map<string, int> latest;
map<string, unsigned int> latest;
for (Strings::const_iterator i = keys.begin(); i != keys.end(); ++i){
Path getStatePath;
int getRevision;
unsigned int getRevision;
nixDB.splitDBKey(*i, getStatePath, getRevision);
if(latest[getStatePath] == 0) //either it is unset
if(latest[getStatePath] == 0) //either it is unset
latest[getStatePath] = getRevision;
else if(latest[getStatePath] < getRevision){
if(revision != -1 && getRevision <= timestamp) //or it is greater, but not greater then the timestamp
if(revision != 0 && getRevision <= timestamp) //or it is greater, but not greater then the timestamp //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!! WERE COMPARING A REVISION TO A TIMESTAMP ???
latest[getStatePath] = getRevision;
else //we need the latest so greater is good
latest[getStatePath] = getRevision;
@ -619,7 +619,7 @@ static PathSet getXReferrers(const Transaction & txn, const Path & store_or_stat
//now check if they refer to 'path' (if you cant find it, then they dont referr to it)
PathSet referrers;
for (map<string, int>::const_iterator i = latest.begin(); i != latest.end(); ++i){
for (map<string, unsigned int>::const_iterator i = latest.begin(); i != latest.end(); ++i){
//printMsg(lvlError, format("AAAAA '%1%'") % (*i).first);
@ -635,18 +635,18 @@ static PathSet getXReferrers(const Transaction & txn, const Path & store_or_stat
}
}
static PathSet getReferrersTxn(const Transaction & txn, const Path & store_or_statePath, const int revision)
static PathSet getReferrersTxn(const Transaction & txn, const Path & store_or_statePath, const unsigned int revision)
{
return getXReferrers(txn, store_or_statePath, true, revision);
}
static PathSet getStateReferrersTxn(const Transaction & txn, const Path & store_or_statePath, const int revision)
static PathSet getStateReferrersTxn(const Transaction & txn, const Path & store_or_statePath, const unsigned int revision)
{
return getXReferrers(txn, store_or_statePath, false, revision);
}
void queryReferrersTxn(const Transaction & txn,
const Path & storePath, PathSet & referrers, const int revision)
const Path & storePath, PathSet & referrers, const unsigned int revision)
{
if (!isRealisableComponentOrStatePath(txn, storePath))
throw Error(format("path `%1%' is not valid") % storePath);
@ -655,12 +655,12 @@ void queryReferrersTxn(const Transaction & txn,
}
void LocalStore::queryReferrers(const Path & storePath,
PathSet & referrers, const int revision)
PathSet & referrers, const unsigned int revision)
{
nix::queryReferrersTxn(noTxn, storePath, referrers, revision);
}
void queryStateReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const int revision)
void queryStateReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const unsigned int revision)
{
if (!isRealisableComponentOrStatePath(txn, storePath))
throw Error(format("path `%1%' is not valid") % storePath);
@ -668,7 +668,7 @@ void queryStateReferrersTxn(const Transaction & txn, const Path & storePath, Pat
stateReferrers.insert(stateReferrers2.begin(), stateReferrers2.end());
}
void LocalStore::queryStateReferrers(const Path & storePath, PathSet & stateReferrers, const int revision)
void LocalStore::queryStateReferrers(const Path & storePath, PathSet & stateReferrers, const unsigned int revision)
{
nix::queryStateReferrersTxn(noTxn, storePath, stateReferrers, revision);
}
@ -1026,7 +1026,7 @@ Path LocalStore::queryStatePathDrv(const Path & statePath)
void registerValidPath(const Transaction & txn,
const Path & component_or_state_path, const Hash & hash,
const PathSet & references, const PathSet & stateReferences,
const Path & deriver, const int revision)
const Path & deriver, const unsigned int revision)
{
ValidPathInfo info;
info.path = component_or_state_path;
@ -1237,7 +1237,7 @@ void LocalStore::exportPath(const Path & path, bool sign,
writeString(path, hashAndWriteSink);
PathSet references;
nix::queryXReferencesTxn(txn, path, references, true, -1); //TODO we can only now export the final revision //TODO also export the state references ???
nix::queryXReferencesTxn(txn, path, references, true, 0); //TODO we can only now export the final revision //TODO also export the state references ???
writeStringSet(references, hashAndWriteSink);
Path deriver = nix::queryDeriver(txn, path);
@ -1618,12 +1618,12 @@ IntVector LocalStore::getStatePathsInterval(const PathSet & statePaths)
TODO Change comment, this can also take state paths
*/
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision)
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const unsigned int revision)
{
nix::storePathRequisitesTxn(noTxn, storeOrstatePath, includeOutputs, paths, withComponents, withState, revision);
}
void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision)
void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const unsigned int revision)
{
computeFSClosureTxn(txn, storeOrstatePath, paths, withComponents, withState, revision);
@ -1640,7 +1640,7 @@ void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePa
}
}
void LocalStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision)
void LocalStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const unsigned int revision)
{
nix::storePathRequisites(storeOrstatePath, includeOutputs, paths, withComponents, withState, revision);
}
@ -1672,12 +1672,12 @@ void LocalStore::setStateRevisions(const RevisionClosure & revisions, const Path
nix::setStateRevisionsTxn(noTxn, revisions, rootStatePath, comment);
}
bool queryStateRevisionsTxn(const Transaction & txn, const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision)
bool queryStateRevisionsTxn(const Transaction & txn, const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const unsigned int revision)
{
return nixDB.queryStateRevisions(txn, dbStateRevisions, dbStateSnapshots, statePath, revisions, timestamps, revision);
}
bool LocalStore::queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision)
bool LocalStore::queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const unsigned int revision)
{
return nix::queryStateRevisionsTxn(noTxn, statePath, revisions, timestamps, revision);
}
@ -1735,6 +1735,18 @@ void setSharedStateTxn(const Transaction & txn, const Path & fromExisting, const
nixDB.setString(txn, dbSharedState, toNew, fromExisting);
}
void LocalStore::setSharedState(const Path & fromExisting, const Path & toNew)
{
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! LEGALITY CHECK IF THE PATH MAY BE SHARED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//TODO
//
Transaction txn(nixDB);
setSharedStateTxn(txn, fromExisting, toNew);
txn.commit();
}
bool querySharedStateTxn(const Transaction & txn, const Path & statePath, Path & shared_with)
{
return nixDB.queryString(txn, dbSharedState, statePath, shared_with);
@ -1768,12 +1780,12 @@ PathSet LocalStore::toNonSharedPathSet(const PathSet & statePaths)
return toNonSharedPathSetTxn(noTxn, statePaths);
}
void setStateComponentReferencesTxn(const Transaction & txn, const Path & statePath, const Strings & references, int revision, int timestamp)
void setStateComponentReferencesTxn(const Transaction & txn, const Path & statePath, const Strings & references, const unsigned int revision, const unsigned int timestamp)
{
nixDB.setStateReferences(txn, dbStateComponentReferences, dbStateRevisions, statePath, references, revision, timestamp);
}
void setStateStateReferencesTxn(const Transaction & txn, const Path & statePath, const Strings & references, int revision, int timestamp)
void setStateStateReferencesTxn(const Transaction & txn, const Path & statePath, const Strings & references, const unsigned int revision, const unsigned int timestamp)
{
nixDB.setStateReferences(txn, dbStateStateReferences, dbStateRevisions, statePath, references, revision, timestamp);
}
@ -1821,7 +1833,7 @@ PathSet getSharedWithPathSetRecTxn(const Transaction & txn, const Path & statePa
}
void LocalStore::revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const int revision_arg, const bool recursive)
void LocalStore::revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const unsigned int revision_arg, const bool recursive)
{
Transaction txn(nixDB);
revertToRevisionTxn(txn, componentPath, derivationPath, statePath, revision_arg, recursive);

View file

@ -51,13 +51,13 @@ public:
Path queryStatePathDrv(const Path & statePath);
void queryReferences(const Path & path, PathSet & references, const int revision);
void queryReferences(const Path & path, PathSet & references, const unsigned int revision);
void queryStateReferences(const Path & storePath, PathSet & stateReferences, const int revision);
void queryStateReferences(const Path & storePath, PathSet & stateReferences, const unsigned int revision);
void queryReferrers(const Path & path, PathSet & referrers, const int revision);
void queryReferrers(const Path & path, PathSet & referrers, const unsigned int revision);
void queryStateReferrers(const Path & path, PathSet & stateReferrers, const int revision);
void queryStateReferrers(const Path & path, PathSet & stateReferrers, const unsigned int revision);
Path addToStore(const Path & srcPath, bool fixed = false,
bool recursive = false, string hashAlgo = "",
@ -94,11 +94,11 @@ public:
bool isStateComponent(const Path & storePath);
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision);
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const unsigned int revision);
void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
bool queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision);
bool queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const unsigned int revision);
bool queryAvailableStateRevisions(const Path & statePath, RevisionInfos & revisions);
@ -112,7 +112,9 @@ public:
PathSet toNonSharedPathSet(const PathSet & statePaths);
void revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const int revision_arg, const bool recursive);
void revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const unsigned int revision_arg, const bool recursive);
void setSharedState(const Path & fromExisting, const Path & toNew);
};
@ -138,7 +140,7 @@ void clearSubstitutes();
void registerValidPath(const Transaction & txn,
const Path & component_or_state_path, const Hash & hash,
const PathSet & references, const PathSet & stateReferences,
const Path & deriver, const int revision);
const Path & deriver, const unsigned int revision);
struct ValidPathInfo
{
@ -147,7 +149,7 @@ struct ValidPathInfo
Hash hash;
PathSet references;
PathSet stateReferences;
int revision;
int unsigned revision;
};
typedef list<ValidPathInfo> ValidPathInfos;
@ -174,7 +176,7 @@ bool isValidPathTxn(const Transaction & txn, const Path & path);
-1 for revision means overwrite the last revision
*/
void setReferences(const Transaction & txn, const Path & store_or_statePath,
const PathSet & references, const PathSet & stateReferences, const int revision);
const PathSet & references, const PathSet & stateReferences, const unsigned int revision);
/* Sets the deriver of a store path. Use with care! */
void setDeriver(const Transaction & txn, const Path & path,
@ -219,17 +221,17 @@ bool isStateDrv(const Derivation & drv);
void queryAllValidPathsTxn(const Transaction & txn, PathSet & allComponentPaths, PathSet & allStatePaths);
bool isValidStatePathTxn(const Transaction & txn, const Path & path);
void queryXReferencesTxn(const Transaction & txn, const Path & path, PathSet & references, const bool component_or_state, const int revision, int timestamp = -1);
void queryXReferencesTxn(const Transaction & txn, const Path & path, PathSet & references, const bool component_or_state, const unsigned int revision, const unsigned int timestamp = 0);
//TODO THESE DONT BELONG HERE, REFACTOR CODE, EG MOVE FUNCTIONS AROUND
void setStateComponentReferencesTxn(const Transaction & txn, const Path & statePath, const Strings & references, int revision, int timestamp);
void setStateStateReferencesTxn(const Transaction & txn, const Path & statePath, const Strings & references, int revision, int timestamp);
void setStateComponentReferencesTxn(const Transaction & txn, const Path & statePath, const Strings & references, const unsigned int revision, const unsigned int timestamp);
void setStateStateReferencesTxn(const Transaction & txn, const Path & statePath, const Strings & references, const unsigned int revision, const unsigned int timestamp);
void queryReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & referrers, const int revision);
void queryStateReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const int revision);
void queryReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & referrers, const unsigned int revision);
void queryStateReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const unsigned int revision);
Path queryStatePathDrvTxn(const Transaction & txn, const Path & statePath);
void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision);
void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const unsigned int revision);
void setStateRevisionsTxn(const Transaction & txn, const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
bool isValidPathTxn(const Transaction & txn, const Path & path);
@ -246,7 +248,7 @@ PathSet getSharedWithPathSetRecTxn(const Transaction & txn, const Path & statePa
void ensurePathTxn(const Transaction & txn, const Path & path);
IntVector getStatePathsIntervalTxn(const Transaction & txn, const PathSet & statePaths);
bool queryStateRevisionsTxn(const Transaction & txn, const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision);
bool queryStateRevisionsTxn(const Transaction & txn, const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const unsigned int revision);
void setStatePathsIntervalTxn(const Transaction & txn, const PathSet & statePath, const IntVector & intervals, bool allZero = false);
}

View file

@ -142,7 +142,7 @@ void queryMissing(const PathSet & targets,
if (store->hasSubstitutes(p))
willSubstitute.insert(p);
PathSet refs;
store->queryReferences(p, todo, -1); //TODO?
store->queryReferences(p, todo, 0); //TODO?
}
}
}

View file

@ -216,22 +216,22 @@ Path RemoteStore::queryStatePathDrv(const Path & statePath)
}
void RemoteStore::queryReferences(const Path & path,
PathSet & references, const int revision)
PathSet & references, const unsigned int revision)
{
writeInt(wopQueryReferences, to);
writeString(path, to);
writeInt(revision, to);
writeBigUnsignedInt(revision, to);
processStderr();
PathSet references2 = readStorePaths(from);
references.insert(references2.begin(), references2.end());
}
void RemoteStore::queryStateReferences(const Path & path,
PathSet & stateReferences, const int revision)
PathSet & stateReferences, const unsigned int revision)
{
writeInt(wopQueryStateReferences, to);
writeString(path, to);
writeInt(revision, to);
writeBigUnsignedInt(revision, to);
processStderr();
PathSet stateReferences2 = readStorePaths(from);
stateReferences.insert(stateReferences2.begin(), stateReferences2.end());
@ -239,11 +239,11 @@ void RemoteStore::queryStateReferences(const Path & path,
void RemoteStore::queryReferrers(const Path & path,
PathSet & referrers, const int revision)
PathSet & referrers, const unsigned int revision)
{
writeInt(wopQueryReferrers, to);
writeString(path, to);
writeInt(revision, to);
writeBigUnsignedInt(revision, to);
processStderr();
PathSet referrers2 = readStorePaths(from);
referrers.insert(referrers2.begin(), referrers2.end());
@ -251,11 +251,11 @@ void RemoteStore::queryReferrers(const Path & path,
}
void RemoteStore::queryStateReferrers(const Path & path,
PathSet & stateReferrers, const int revision)
PathSet & stateReferrers, const unsigned int revision)
{
writeInt(wopQueryStateReferrers, to);
writeString(path, to);
writeInt(revision, to);
writeBigUnsignedInt(revision, to);
processStderr();
PathSet stateReferrers2 = readStorePaths(from);
stateReferrers.insert(stateReferrers2.begin(), stateReferrers2.end());
@ -439,7 +439,7 @@ bool RemoteStore::isStateComponent(const Path & path)
return reply != 0;
}
void RemoteStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision)
void RemoteStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const unsigned int revision)
{
writeInt(wopStorePathRequisites, to);
writeString(storeOrstatePath, to);
@ -447,7 +447,7 @@ void RemoteStore::storePathRequisites(const Path & storeOrstatePath, const bool
writeStringSet(paths, to);
writeInt(withComponents ? 1 : 0, to);
writeInt(withState ? 1 : 0, to);
writeInt(revision, to);
writeBigUnsignedInt(revision, to);
processStderr();
readInt(from);
}
@ -462,16 +462,16 @@ void RemoteStore::setStateRevisions(const RevisionClosure & revisions, const Pat
readInt(from);
}
bool RemoteStore::queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision)
bool RemoteStore::queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const unsigned int revision)
{
writeInt(wopQueryStateRevisions, to);
writeString(statePath, to);
writeInt(revision, to);
RevisionClosure revisions2 = readRevisionClosure(from);
RevisionClosureTS timestamps2 = readRevisionClosureTS(from);
writeBigUnsignedInt(revision, to);
processStderr();
RevisionClosure revisions2 = readRevisionClosure(from);
RevisionClosureTS timestamps2 = readRevisionClosureTS(from);
revisions = revisions2; //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
timestamps = timestamps2; //TODO !!!!!!!!!!!!!!!!!!!! COPY BY VALUE I THINK
processStderr();
unsigned int reply = readInt(from);
return reply != 0;
}
@ -480,9 +480,9 @@ bool RemoteStore::queryAvailableStateRevisions(const Path & statePath, RevisionI
{
writeInt(wopQueryAvailableStateRevisions, to);
writeString(statePath, to);
processStderr();
RevisionInfos revisions2 = readRevisionInfos(from);
revisions = revisions2; //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
processStderr();
unsigned int reply = readInt(from);
return reply != 0;
}
@ -513,18 +513,26 @@ PathSet RemoteStore::toNonSharedPathSet(const PathSet & statePaths)
return readStringSet(from); //TODO !!!!!!!!!!!!!!! create a readStatePaths just like readStorePaths
}
void RemoteStore::revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const int revision_arg, const bool recursive)
void RemoteStore::revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const unsigned int revision_arg, const bool recursive)
{
writeInt(wopRevertToRevision, to);
writeString(componentPath, to);
writeString(derivationPath, to);
writeString(statePath, to);
writeInt(revision_arg, to);
writeBigUnsignedInt(revision_arg, to);
writeInt(recursive ? 1 : 0, to);
processStderr();
readInt(from);
}
void RemoteStore::setSharedState(const Path & fromExisting, const Path & toNew)
{
writeString(fromExisting, to);
writeString(toNew, to);
processStderr();
readInt(from);
}
void RemoteStore::processStderr(Sink * sink, Source * source)
{
@ -556,5 +564,4 @@ void RemoteStore::processStderr(Sink * sink, Source * source)
}
}

View file

@ -39,13 +39,13 @@ public:
Path queryStatePathDrv(const Path & statePath);
void queryReferences(const Path & path, PathSet & references, const int revision);
void queryReferences(const Path & path, PathSet & references, const unsigned int revision);
void queryStateReferences(const Path & storePath, PathSet & stateReferences, const int revision);
void queryStateReferences(const Path & storePath, PathSet & stateReferences, const unsigned int revision);
void queryReferrers(const Path & path, PathSet & referrers, const int revision);
void queryReferrers(const Path & path, PathSet & referrers, const unsigned int revision);
void queryStateReferrers(const Path & path, PathSet & stateReferrers, const int revision);
void queryStateReferrers(const Path & path, PathSet & stateReferrers, const unsigned int revision);
Path addToStore(const Path & srcPath, bool fixed = false,
bool recursive = false, string hashAlgo = "",
@ -80,11 +80,11 @@ public:
bool isStateComponent(const Path & path);
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision);
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const unsigned int revision);
void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
bool queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision);
bool queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const unsigned int revision);
bool queryAvailableStateRevisions(const Path & statePath, RevisionInfos & revisions);
@ -98,7 +98,9 @@ public:
PathSet toNonSharedPathSet(const PathSet & statePaths);
void revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const int revision_arg, const bool recursive);
void revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const unsigned int revision_arg, const bool recursive);
void setSharedState(const Path & fromExisting, const Path & toNew);
private:
AutoCloseFD fdSocket;

View file

@ -81,20 +81,20 @@ public:
/* Queries the set of outgoing FS references for a store path.
The result is not cleared. */
virtual void queryReferences(const Path & path,
PathSet & references, const int revision) = 0;
PathSet & references, const unsigned int revision) = 0;
/* Queries the set of outgoing FS state-references for a store path.
The result is not cleared. */
virtual void queryStateReferences(const Path & storePath, PathSet & stateReferences, const int revision) = 0;
virtual void queryStateReferences(const Path & storePath, PathSet & stateReferences, const unsigned int revision) = 0;
/* Queries the set of incoming FS references for a store path.
The result is not cleared. */
virtual void queryReferrers(const Path & path,
PathSet & referrers, const int revision) = 0;
PathSet & referrers, const unsigned int revision) = 0;
/* Queries the set of incoming FS state-references for a store path.
The result is not cleared. */
virtual void queryStateReferrers(const Path & path, PathSet & stateReferrers, const int revision) = 0;
virtual void queryStateReferrers(const Path & path, PathSet & stateReferrers, const unsigned int revision) = 0;
/* Copy the contents of a path to the store and register the
validity the resulting path. The resulting path is returned.
@ -209,13 +209,13 @@ public:
virtual bool isStateComponent(const Path & path) = 0;
/* TODO */
virtual void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision) = 0;
virtual void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const unsigned int revision) = 0;
/* TODO */
virtual void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment) = 0;
/* TODO */
virtual bool queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision) = 0;
virtual bool queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const unsigned int revision) = 0;
/* TODO */
virtual bool queryAvailableStateRevisions(const Path & statePath, RevisionInfos & revisions) = 0;
@ -237,7 +237,10 @@ public:
virtual PathSet toNonSharedPathSet(const PathSet & statePaths) = 0;
/* TODO */
virtual void revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const int revision_arg, const bool recursive) = 0;
virtual void revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const unsigned int revision_arg, const bool recursive) = 0;
/* TODO */
virtual void setSharedState(const Path & fromExisting, const Path & toNew) = 0;
};

View file

@ -29,7 +29,7 @@ void updatedStateDerivation(Path storePath)
}
*/
void createStateDirsTxn(const Transaction & txn, const DerivationStateOutputDirs & stateOutputDirs, const DerivationStateOutputs & stateOutputs)
void createSubStateDirsTxn(const Transaction & txn, const DerivationStateOutputDirs & stateOutputDirs, const DerivationStateOutputs & stateOutputs)
{
Path statePath = stateOutputs.find("state")->second.statepath;
string stateDir = statePath;
@ -57,7 +57,7 @@ void createStateDirsTxn(const Transaction & txn, const DerivationStateOutputDirs
Path fullstatedir = stateDir + "/" + thisdir;
ensureDirExists(fullstatedir);
setStatePathRights(fullstatedir, queryCallingUsername(), "nixbld");
if(d.type == "interval"){
intervalPaths.insert(fullstatedir);
@ -100,7 +100,7 @@ void revertToRevisionTxn(const Transaction & txn, const Path & componentPath, co
statePaths.insert(derivationPath); //Insert direct state path
//get a new timestamp for the references update
int newTimestamp = getTimeStamp();
unsigned int newTimestamp = getTimeStamp();
//Get the revisions recursively to also roll them back
RevisionClosure getRivisions;
@ -111,7 +111,7 @@ void revertToRevisionTxn(const Transaction & txn, const Path & componentPath, co
for (RevisionClosure::iterator i = getRivisions.begin(); i != getRivisions.end(); ++i){
Path statePath = (*i).first;
Snapshots revisioned_paths = (*i).second;
int timestamp = getTimestamps[statePath];
unsigned int timestamp = getTimestamps[statePath];
//get its derivation-state-items
Derivation statePath_drv = derivationFromPathTxn(txn, queryStatePathDrvTxn(noTxn, statePath));
@ -183,13 +183,13 @@ void revertToRevisionTxn(const Transaction & txn, const Path & componentPath, co
//Query the references of the old revision (already converted to a timestamp)
PathSet state_references;
queryXReferencesTxn(txn, statePath, state_references, true, -1, timestamp);
queryXReferencesTxn(txn, statePath, state_references, true, 0, timestamp);
PathSet state_stateReferences;
queryXReferencesTxn(txn, statePath, state_stateReferences, false, -1, timestamp);
queryXReferencesTxn(txn, statePath, state_stateReferences, false, 0, timestamp);
//Now set these old references as the new references at the new (just created) Timestamp
setStateComponentReferencesTxn(txn, statePath, Strings(state_references.begin(), state_references.end()), -1, newTimestamp);
setStateStateReferencesTxn(txn, statePath, Strings(state_stateReferences.begin(), state_stateReferences.end()), -1, newTimestamp);
setStateComponentReferencesTxn(txn, statePath, Strings(state_references.begin(), state_references.end()), 0, newTimestamp);
setStateStateReferencesTxn(txn, statePath, Strings(state_stateReferences.begin(), state_stateReferences.end()), 0, newTimestamp);
printMsg(lvlError, format("Reverted state of '%1%' to revision '%2%'") % statePath % revision_arg);
}
@ -309,8 +309,8 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa
//Retrieve old references
PathSet old_references;
PathSet old_state_references;
queryXReferencesTxn(txn, statePath, old_references, true, -1); //get the latsest references
queryXReferencesTxn(txn, statePath, old_state_references, false, -1);
queryXReferencesTxn(txn, statePath, old_references, true, 0); //get the latsest references
queryXReferencesTxn(txn, statePath, old_state_references, false, 0);
//Check for added and removed paths
PathSet diff_references_removed;
@ -347,7 +347,7 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa
state_references,
state_stateReferences,
drvPath,
-1); //Set at a new timestamp
0); //Set at a new timestamp
}
void scanAndUpdateAllReferencesRecusivelyTxn(const Transaction & txn, const Path & statePath)
@ -357,7 +357,7 @@ void scanAndUpdateAllReferencesRecusivelyTxn(const Transaction & txn, const Path
//get all state current state references recursively
PathSet statePaths;
storePathRequisitesTxn(txn, statePath, false, statePaths, false, true, -1); //Get all current state dependencies
storePathRequisitesTxn(txn, statePath, false, statePaths, false, true, 0); //Get all current state dependencies
//Add own statePath (may already be in there, but its a set, so no doubles)
statePaths.insert(statePath);

View file

@ -8,7 +8,7 @@
namespace nix {
/* Create a state directory. */
void createStateDirsTxn(const Transaction & txn, const DerivationStateOutputDirs & stateOutputDirs, const DerivationStateOutputs & stateOutputs);
void createSubStateDirsTxn(const Transaction & txn, const DerivationStateOutputDirs & stateOutputDirs, const DerivationStateOutputs & stateOutputs);
/* TODO */
Snapshots commitStatePathTxn(const Transaction & txn, const Path & statePath);

View file

@ -10,8 +10,8 @@ namespace nix {
typedef enum {
wopQuit,
wopIsValidPath,
wopQuit, //0
wopIsValidPath,
wopIsValidStatePath,
wopIsValidComponentOrStatePath,
wopQuerySubstitutes,
@ -20,9 +20,9 @@ typedef enum {
wopQueryStatePathDrv,
wopQueryReferences,
wopQueryStateReferences,
wopQueryReferrers,
wopQueryStateReferrers,
wopAddToStore,
wopQueryReferrers, //10
wopQueryStateReferrers,
wopAddToStore,
wopAddTextToStore,
wopBuildDerivations, //TODO HANGS SOMETIMES !!!!!
wopEnsurePath,
@ -30,23 +30,23 @@ typedef enum {
wopAddIndirectRoot,
wopSyncWithGC,
wopFindRoots,
wopCollectGarbage,
wopExportPath,
wopCollectGarbage, //20
wopExportPath,
wopImportPath,
wopQueryDeriver,
wopQueryDerivers,
wopSetStatePathsInterval,
wopGetStatePathsInterval,
wopIsStateComponent,
wopStorePathRequisites,
wopSetStateRevisions,
wopQueryStateRevisions,
wopQueryAvailableStateRevisions,
wopQueryStateRevisions, //30
wopQueryAvailableStateRevisions,
wopCommitStatePath,
wopScanAndUpdateAllReferences,
wopToNonSharedPathSet,
wopRevertToRevision,
wopSetSharedState,
} WorkerOp;