mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
downscaled to 1 repos per statePath
This commit is contained in:
parent
cce4156232
commit
9f00b42f38
19 changed files with 218 additions and 399 deletions
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
debug=""; #set to "" for no debugging, set to "echo " to debug the commands
|
||||
|
||||
if [ "$#" != 5 ] && [ "$#" != 6 ] ; then
|
||||
if [ "$#" != 6 ] && [ "$#" != 7 ] ; then
|
||||
echo "Incorrect number of arguments"
|
||||
exit 1;
|
||||
fi
|
||||
|
|
@ -19,8 +19,9 @@ svnbin=$1
|
|||
subversionedpaths=( $2 ) #arrays
|
||||
subversionedpathsCommitBools=( $3 )
|
||||
nonversionedpaths=( $4 )
|
||||
checkouts=( $5 )
|
||||
deletesvn=$6 #this flag can be set to 1 to DELETE all .svn folders and NOT commit
|
||||
checkout=$5
|
||||
statepath=$6
|
||||
deletesvn=$7 #this flag can be set to 1 to DELETE all .svn folders and NOT commit
|
||||
|
||||
|
||||
if [ "$debug" != "" ] ; then
|
||||
|
|
@ -28,7 +29,8 @@ if [ "$debug" != "" ] ; then
|
|||
echo subversionedpaths: ${subversionedpaths[@]}
|
||||
echo subversionedpathsCommitBools: ${subversionedpathsCommitBools[@]}
|
||||
echo nonversionedpaths: ${nonversionedpaths[@]}
|
||||
echo checkouts: ${checkouts[@]}
|
||||
echo checkouts: $checkout
|
||||
echo statepath: $statepath
|
||||
echo deletesvn: $deletesvn
|
||||
fi
|
||||
|
||||
|
|
@ -46,9 +48,9 @@ function subversionSingleStateDir {
|
|||
empty=$(ls)
|
||||
|
||||
if [ "$empty" = "" ] ; then
|
||||
allsubitems=(); #no subfiles / dirs
|
||||
allsubitems=(); #no subfiles / dirs
|
||||
else
|
||||
allsubitems=( $(echo *) $(echo .*) ) #there are subfiles / dirs,also adds hidden items
|
||||
allsubitems=( $(echo *) $(echo .*) ) #there are subfiles / dirs,also adds hidden items
|
||||
fi
|
||||
|
||||
for subitem in ${allsubitems[@]}
|
||||
|
|
@ -128,39 +130,28 @@ function subversionSingleStateDir {
|
|||
#
|
||||
#
|
||||
|
||||
if ! test -d "${statepath}/.svn/"; then #if the dir exists but is not yet an svn dir: checkout repos, if it doenst exits (is removed or something) than we dont do anything
|
||||
if [ "$deletesvn" != "1" ]; then
|
||||
$debug $checkout;
|
||||
fi
|
||||
fi
|
||||
|
||||
i=0
|
||||
i_checkout=0
|
||||
for path in ${subversionedpaths[@]}
|
||||
do
|
||||
if test -d $path; then #if the dir doesnt exist, than we dont hav to do anything
|
||||
cd $path;
|
||||
|
||||
checkoutcommand=""; #HACK: I cant seem to find a way for bash to parse a 2 dimensional string array as argument, so we use a 1-d array with '|' as seperator
|
||||
while true; do
|
||||
if [ "${checkouts[$i_checkout]}" = "|" ]; then
|
||||
let "i_checkout+=1"
|
||||
break
|
||||
fi
|
||||
checkoutcommand="${checkoutcommand} ${checkouts[$i_checkout]}";
|
||||
let "i_checkout+=1"
|
||||
done
|
||||
|
||||
if ! test -d "${path}.svn/"; then #if the dir exists but is not yet an svn dir: checkout repos, if it doenst exits (is removed or something) than we dont do anything
|
||||
if [ "$deletesvn" != "1" ]; then
|
||||
$debug $checkoutcommand;
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${subversionedpathsCommitBools[$i]}" = "true" ]; then #Check if we need to commit this folder
|
||||
|
||||
echo "Entering $path"
|
||||
|
||||
subversionSingleStateDir $path;
|
||||
if ! test -d "${path}/.svn/"; then #Also add yourself if nessecary
|
||||
if [ "$deletesvn" != "1" ]; then
|
||||
$debug svn -N add $path
|
||||
fi
|
||||
fi
|
||||
|
||||
cd $path #now that everything is added we go back to the 'root' path and commit
|
||||
if [ "$deletesvn" != "1" ]; then
|
||||
$debug svn -m "" commit;
|
||||
fi
|
||||
subversionSingleStateDir $path;
|
||||
fi
|
||||
|
||||
cd - &> /dev/null;
|
||||
|
|
@ -168,7 +159,8 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
cd $statepath #now that everything is added we go back to the 'root' path and commit
|
||||
if [ "$deletesvn" != "1" ]; then
|
||||
$debug svn -m "" commit;
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
debug=""; #set to "" for no debugging, set to "echo " to debug the commands
|
||||
|
||||
if [ "$#" != 5 ] && [ "$#" != 6 ] ; then
|
||||
if [ "$#" != 6 ] && [ "$#" != 7 ] ; then
|
||||
echo "Incorrect number of arguments"
|
||||
exit 1;
|
||||
fi
|
||||
|
|
@ -19,8 +19,9 @@ svnbin=$1
|
|||
subversionedpaths=( $2 ) #arrays
|
||||
subversionedpathsCommitBools=( $3 )
|
||||
nonversionedpaths=( $4 )
|
||||
checkouts=( $5 )
|
||||
deletesvn=$6 #this flag can be set to 1 to DELETE all .svn folders and NOT commit
|
||||
checkout=$5
|
||||
statepath=$6
|
||||
deletesvn=$7 #this flag can be set to 1 to DELETE all .svn folders and NOT commit
|
||||
|
||||
|
||||
if [ "$debug" != "" ] ; then
|
||||
|
|
@ -28,7 +29,8 @@ if [ "$debug" != "" ] ; then
|
|||
echo subversionedpaths: ${subversionedpaths[@]}
|
||||
echo subversionedpathsCommitBools: ${subversionedpathsCommitBools[@]}
|
||||
echo nonversionedpaths: ${nonversionedpaths[@]}
|
||||
echo checkouts: ${checkouts[@]}
|
||||
echo checkouts: $checkout
|
||||
echo statepath: $statepath
|
||||
echo deletesvn: $deletesvn
|
||||
fi
|
||||
|
||||
|
|
@ -46,9 +48,9 @@ function subversionSingleStateDir {
|
|||
empty=$(ls)
|
||||
|
||||
if [ "$empty" = "" ] ; then
|
||||
allsubitems=(); #no subfiles / dirs
|
||||
allsubitems=(); #no subfiles / dirs
|
||||
else
|
||||
allsubitems=( $(echo *) $(echo .*) ) #there are subfiles / dirs,also adds hidden items
|
||||
allsubitems=( $(echo *) $(echo .*) ) #there are subfiles / dirs,also adds hidden items
|
||||
fi
|
||||
|
||||
for subitem in ${allsubitems[@]}
|
||||
|
|
@ -128,39 +130,28 @@ function subversionSingleStateDir {
|
|||
#
|
||||
#
|
||||
|
||||
if ! test -d "${statepath}/.svn/"; then #if the dir exists but is not yet an svn dir: checkout repos, if it doenst exits (is removed or something) than we dont do anything
|
||||
if [ "$deletesvn" != "1" ]; then
|
||||
$debug $checkout;
|
||||
fi
|
||||
fi
|
||||
|
||||
i=0
|
||||
i_checkout=0
|
||||
for path in ${subversionedpaths[@]}
|
||||
do
|
||||
if test -d $path; then #if the dir doesnt exist, than we dont hav to do anything
|
||||
cd $path;
|
||||
|
||||
checkoutcommand=""; #HACK: I cant seem to find a way for bash to parse a 2 dimensional string array as argument, so we use a 1-d array with '|' as seperator
|
||||
while true; do
|
||||
if [ "${checkouts[$i_checkout]}" = "|" ]; then
|
||||
let "i_checkout+=1"
|
||||
break
|
||||
fi
|
||||
checkoutcommand="${checkoutcommand} ${checkouts[$i_checkout]}";
|
||||
let "i_checkout+=1"
|
||||
done
|
||||
|
||||
if ! test -d "${path}.svn/"; then #if the dir exists but is not yet an svn dir: checkout repos, if it doenst exits (is removed or something) than we dont do anything
|
||||
if [ "$deletesvn" != "1" ]; then
|
||||
$debug $checkoutcommand;
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${subversionedpathsCommitBools[$i]}" = "true" ]; then #Check if we need to commit this folder
|
||||
|
||||
echo "Entering $path"
|
||||
|
||||
subversionSingleStateDir $path;
|
||||
if ! test -d "${path}/.svn/"; then #Also add yourself if nessecary
|
||||
if [ "$deletesvn" != "1" ]; then
|
||||
$debug svn -N add $path
|
||||
fi
|
||||
fi
|
||||
|
||||
cd $path #now that everything is added we go back to the 'root' path and commit
|
||||
if [ "$deletesvn" != "1" ]; then
|
||||
$debug svn -m "" commit;
|
||||
fi
|
||||
subversionSingleStateDir $path;
|
||||
fi
|
||||
|
||||
cd - &> /dev/null;
|
||||
|
|
@ -168,7 +159,8 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
cd $statepath #now that everything is added we go back to the 'root' path and commit
|
||||
if [ "$deletesvn" != "1" ]; then
|
||||
$debug svn -m "" commit;
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -485,6 +485,7 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
|
|||
|
||||
dir.path = s;
|
||||
}
|
||||
else if (statekey == "file") { dir.path = s; }
|
||||
else if (statekey == "type") { dir.type = s; }
|
||||
else if (statekey == "interval") {
|
||||
if(s == "")
|
||||
|
|
|
|||
|
|
@ -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); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
computeFSClosure(drvPath, allInputs, true, false, -1); //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 = derivationFromPath(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); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE (done?)
|
||||
computeFSClosure(inDrv.outputs[*j].path, inputStatePaths, false, true); //TODO!!!!!!!!!!!!! HOW CAN THESE PATHS ALREADY BE VALID ..... ?????????????????????
|
||||
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 ..... ?????????????????????
|
||||
}
|
||||
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); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE (done?)
|
||||
computeFSClosure(*i, inputStatePaths, false, true);
|
||||
computeFSClosure(*i, inputPaths, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE (done?)
|
||||
computeFSClosure(*i, inputStatePaths, false, true, -1);
|
||||
}
|
||||
|
||||
debug(format("added input paths %1%") % showPaths(inputPaths));
|
||||
|
|
@ -1463,7 +1463,7 @@ void DerivationGoal::startBuilder()
|
|||
|
||||
/* Write closure info to `fileName'. */
|
||||
PathSet refs;
|
||||
computeFSClosure(storePath, refs, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||
computeFSClosure(storePath, refs, true, false, -1); //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,
|
||||
|
|
|
|||
|
|
@ -555,40 +555,6 @@ bool Database::queryStateReferences(const Transaction & txn, TableId table,
|
|||
else
|
||||
key = makeStatePathRevision(statePath, revision);
|
||||
|
||||
/*
|
||||
///////////////?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! create function
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TODO
|
||||
string key = ""; //final key that matches revision + statePath
|
||||
int highestRev = -1;
|
||||
|
||||
//Lookup which key we need
|
||||
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i) {
|
||||
Path getStatePath_org = *i;
|
||||
Path getStatePath;
|
||||
int getRevision;
|
||||
splitStatePathRevision(*i, getStatePath, getRevision);
|
||||
|
||||
if(getStatePath == statePath){
|
||||
|
||||
if(revision == -1){ //the user wants the last revision
|
||||
if(getRevision > highestRev)
|
||||
highestRev = getRevision;
|
||||
}
|
||||
else if(revision == getRevision){
|
||||
key = getStatePath_org;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if(key == "" && highestRev == -1) //no records found (TODO throw error?)
|
||||
return false;
|
||||
|
||||
if(revision == -1)
|
||||
key = makeStatePathRevision(statePath, highestRev);
|
||||
*/
|
||||
|
||||
return queryStrings(txn, table, key, references); //now that we have the key, we can query the references
|
||||
}
|
||||
|
||||
|
|
@ -610,15 +576,15 @@ bool Database::queryStateReferrers(const Transaction & txn, TableId table,
|
|||
|
||||
|
||||
void Database::setStateRevisions(const Transaction & txn, TableId table,
|
||||
const Path & statePath, const RevisionNumbersSetClosure & revisions, int revision)
|
||||
const Path & statePath, const RevisionNumbersSet & revisions, int revision)
|
||||
{
|
||||
if(revision == -1)
|
||||
revision = getNewRevisionNumber(txn, table, statePath);
|
||||
|
||||
//Sort based on statePath to RevisionNumbersClosure
|
||||
RevisionNumbersClosure sorted_revisions;
|
||||
RevisionNumbers sorted_revisions;
|
||||
vector<Path> sortedStatePaths;
|
||||
for (RevisionNumbersSetClosure::const_iterator i = revisions.begin(); i != revisions.end(); ++i)
|
||||
for (RevisionNumbersSet::const_iterator i = revisions.begin(); i != revisions.end(); ++i)
|
||||
sortedStatePaths.push_back((*i).first);
|
||||
sort(sortedStatePaths.begin(), sortedStatePaths.end());
|
||||
for (vector<Path>::const_iterator i = sortedStatePaths.begin(); i != sortedStatePaths.end(); ++i)
|
||||
|
|
@ -626,22 +592,16 @@ void Database::setStateRevisions(const Transaction & txn, TableId table,
|
|||
|
||||
//////////////////
|
||||
for (vector<Path>::const_iterator i = sortedStatePaths.begin(); i != sortedStatePaths.end(); ++i){
|
||||
printMsg(lvlError, format("Insert: %1%") % *i);
|
||||
for (RevisionNumbers::const_iterator e = (revisions.at(*i)).begin(); e != (revisions.at(*i)).end(); ++e)
|
||||
printMsg(lvlError, format("Rev: %1%") % *e);
|
||||
printMsg(lvlError, format("Insert: %1% into %2%") % int2String(revisions.at(*i)) % *i);
|
||||
|
||||
}
|
||||
//////////////////
|
||||
|
||||
//Pack the data into Strings
|
||||
const string seperator = "|";
|
||||
//Convert the int's into Strings
|
||||
Strings data;
|
||||
for (RevisionNumbersClosure::const_iterator i = sorted_revisions.begin(); i != sorted_revisions.end(); ++i) {
|
||||
RevisionNumbers revisionNumbers = *i;
|
||||
string packedNumbers = "";
|
||||
for (RevisionNumbers::iterator j = revisionNumbers.begin(); j != revisionNumbers.end(); ++j)
|
||||
packedNumbers += int2String(*j) + seperator;
|
||||
packedNumbers = packedNumbers.substr(0, packedNumbers.length()-1); //remove the last |
|
||||
data.push_back(packedNumbers);
|
||||
for (RevisionNumbers::const_iterator i = sorted_revisions.begin(); i != sorted_revisions.end(); ++i) {
|
||||
int revisionnumber = *i;
|
||||
data.push_back(int2String(revisionnumber));
|
||||
}
|
||||
|
||||
//Create the key
|
||||
|
|
@ -652,10 +612,8 @@ void Database::setStateRevisions(const Transaction & txn, TableId table,
|
|||
}
|
||||
|
||||
bool Database::queryStateRevisions(const Transaction & txn, TableId table,
|
||||
const Path & statePath, RevisionNumbersClosure & revisions, int revision)
|
||||
const Path & statePath, RevisionNumbers & revisions, int revision)
|
||||
{
|
||||
const string seperator = "|";
|
||||
|
||||
Strings keys;
|
||||
enumTable(txn, table, keys); //get all revisions
|
||||
|
||||
|
|
@ -668,55 +626,17 @@ bool Database::queryStateRevisions(const Transaction & txn, TableId table,
|
|||
else
|
||||
key = makeStatePathRevision(statePath, revision);
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
string key = ""; //final key that matches revision + statePath
|
||||
int highestRev = -1;
|
||||
|
||||
//Lookup which key we need
|
||||
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i) {
|
||||
Path getStatePath_org = *i;
|
||||
Path getStatePath;
|
||||
int getRevision;
|
||||
splitStatePathRevision(*i, getStatePath, getRevision);
|
||||
|
||||
if(getStatePath == statePath){
|
||||
|
||||
if(revision == -1){ //the user wants the last revision
|
||||
if(getRevision > highestRev)
|
||||
highestRev = getRevision;
|
||||
}
|
||||
else if(revision == getRevision){
|
||||
key = getStatePath_org;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if(key == "" && highestRev == -1) //no records found (TODO throw error?)
|
||||
return false;
|
||||
|
||||
if(revision == -1)
|
||||
key = makeStatePathRevision(statePath, highestRev);
|
||||
*/
|
||||
|
||||
Strings data;
|
||||
bool succeed = queryStrings(txn, table, key, data); //now that we have the key, we can query the references
|
||||
|
||||
//Unpack Strings into RevisionNumbersClosure
|
||||
//Convert the Strings into int's
|
||||
for (Strings::iterator i = data.begin(); i != data.end(); ++i){
|
||||
RevisionNumbers revisionsGroup;
|
||||
string packedNumbers = *i;
|
||||
Strings tokens = tokenizeString(packedNumbers, seperator);
|
||||
for (Strings::iterator j = tokens.begin(); j != tokens.end(); ++j){
|
||||
int getRevision;
|
||||
bool succeed = string2Int(*j, getRevision);
|
||||
if(!succeed)
|
||||
throw Error(format("Cannot read revision number from db of path '%1%'") % statePath);
|
||||
revisionsGroup.push_back(getRevision);
|
||||
}
|
||||
revisions.push_back(revisionsGroup);
|
||||
string getRevisionS = *i;
|
||||
int getRevision;
|
||||
bool succeed = string2Int(getRevisionS, getRevision);
|
||||
if(!succeed)
|
||||
throw Error(format("Cannot read revision number from db of path '%1%'") % statePath);
|
||||
revisions.push_back(getRevision);
|
||||
}
|
||||
|
||||
return succeed;
|
||||
|
|
|
|||
|
|
@ -117,11 +117,11 @@ public:
|
|||
|
||||
/* 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 table,
|
||||
const Path & statePath, const RevisionNumbersSetClosure & revisions, int revision = -1);
|
||||
const Path & statePath, const RevisionNumbersSet & revisions, int revision = -1);
|
||||
|
||||
/* Returns all the revision numbers of the state references closure of the given state path */
|
||||
bool queryStateRevisions(const Transaction & txn, TableId table,
|
||||
const Path & statePath, RevisionNumbersClosure & revisions, int revision = -1);
|
||||
const Path & statePath, RevisionNumbers & revisions, int revision = -1);
|
||||
|
||||
/* Returns all available revision numbers of the given state path */
|
||||
bool queryAvailableStateRevisions(const Transaction & txn, TableId table,
|
||||
|
|
|
|||
|
|
@ -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); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO DELETE STATE??
|
||||
computeFSClosure(canonPath(*i), livePaths, true, false, -1); //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 = queryDeriver(noTxn, *i);
|
||||
if (deriver != "" && store->isValidPath(deriver))
|
||||
computeFSClosure(deriver, livePaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
||||
computeFSClosure(deriver, livePaths, true, false, -1); //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); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
||||
computeFSClosure(j->second.path, livePaths, true, false, -1); //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); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO .... STATE
|
||||
computeFSClosure(*i, tempRootsClosed, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO .... STATE
|
||||
else
|
||||
tempRootsClosed.insert(*i);
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ static TableId dbStateCounters = 0;
|
|||
*/
|
||||
static TableId dbStateInfo = 0;
|
||||
|
||||
/* dbStateRevisions :: StatePath -> RevisionNumbersClosure
|
||||
/* dbStateRevisions :: StatePath -> RevisionNumbers
|
||||
|
||||
This table lists the statepaths + recursive (indirect) references and the revision numbers of their repositorys
|
||||
|
||||
|
|
@ -1491,7 +1491,7 @@ void setStatePathsInterval(const PathSet & statePaths, const vector<int> & inter
|
|||
int n=0;
|
||||
for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i)
|
||||
{
|
||||
printMsg(lvlError, format("Set interval of PATH: %1%") % *i);
|
||||
//printMsg(lvlError, format("Set interval of PATH: %1%") % *i);
|
||||
|
||||
int interval=0;
|
||||
if(!allZero)
|
||||
|
|
@ -1597,9 +1597,11 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
|
|||
|
||||
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)
|
||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision)
|
||||
{
|
||||
computeFSClosure(storeOrstatePath, paths, withComponents, withState);
|
||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
computeFSClosure(storeOrstatePath, paths, withComponents, withState, revision);
|
||||
|
||||
if (includeOutputs) {
|
||||
for (PathSet::iterator i = paths.begin();
|
||||
|
|
@ -1609,14 +1611,14 @@ void storePathRequisites(const Path & storeOrstatePath, const bool includeOutput
|
|||
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
||||
j != drv.outputs.end(); ++j)
|
||||
if (store->isValidPath(j->second.path))
|
||||
computeFSClosure(j->second.path, paths, withComponents, withState);
|
||||
computeFSClosure(j->second.path, paths, withComponents, withState, revision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocalStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState)
|
||||
void LocalStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision)
|
||||
{
|
||||
return nix::storePathRequisites(storeOrstatePath, includeOutputs, paths, withComponents, withState);
|
||||
return nix::storePathRequisites(storeOrstatePath, includeOutputs, paths, withComponents, withState, revision);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1768,7 +1770,6 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa
|
|||
|
||||
|
||||
|
||||
|
||||
//update all revision numbers (transaction) NEW FUN THAT UPDATES THE REVISIONS
|
||||
//update all revision numbers + references (transaction)
|
||||
//update all references
|
||||
|
|
@ -1796,9 +1797,9 @@ void LocalStore::scanAndUpdateAllReferences(const Path & statePath)
|
|||
|
||||
void scanAndUpdateAllReferencesRecusively(const Transaction & txn, const Path & storeOrStatePath) //TODO Can also work for statePaths???
|
||||
{
|
||||
//get all state references recursively
|
||||
//get all state current state references recursively
|
||||
PathSet statePaths;
|
||||
storePathRequisites(storeOrStatePath, false, statePaths, false, true); //TODO CAN THIS ???
|
||||
storePathRequisites(storeOrStatePath, false, statePaths, false, true, -1); //TODO CAN THIS ???
|
||||
|
||||
//call scanForAllReferences again on all newly found statePaths
|
||||
for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i)
|
||||
|
|
@ -1820,22 +1821,22 @@ void LocalStore::scanAndUpdateAllReferencesRecusively(const Path & storeOrStateP
|
|||
return nix::scanAndUpdateAllReferencesRecusively(noTxn, storeOrStatePath);
|
||||
}
|
||||
|
||||
void setStateRevisions(const Transaction & txn, const Path & statePath, const RevisionNumbersSetClosure & revisions, const int revision)
|
||||
void setStateRevisions(const Transaction & txn, const Path & statePath, const RevisionNumbersSet & revisions, const int revision)
|
||||
{
|
||||
nixDB.setStateRevisions(txn, dbStateRevisions, statePath, revisions, revision);
|
||||
}
|
||||
|
||||
void LocalStore::setStateRevisions(const Path & statePath, const RevisionNumbersSetClosure & revisions, const int revision)
|
||||
void LocalStore::setStateRevisions(const Path & statePath, const RevisionNumbersSet & revisions, const int revision)
|
||||
{
|
||||
nix::setStateRevisions(noTxn, statePath, revisions, revision);
|
||||
}
|
||||
|
||||
bool queryStateRevisions(const Transaction & txn, const Path & statePath, RevisionNumbersClosure & revisions, const int revision)
|
||||
bool queryStateRevisions(const Transaction & txn, const Path & statePath, RevisionNumbers & revisions, const int revision)
|
||||
{
|
||||
return nixDB.queryStateRevisions(txn, dbStateRevisions, statePath, revisions, revision);
|
||||
}
|
||||
|
||||
bool LocalStore::queryStateRevisions(const Path & statePath, RevisionNumbersClosure & revisions, const int revision)
|
||||
bool LocalStore::queryStateRevisions(const Path & statePath, RevisionNumbers & revisions, const int revision)
|
||||
{
|
||||
return nix::queryStateRevisions(noTxn, statePath, revisions, revision);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,15 +96,15 @@ public:
|
|||
|
||||
bool isStateDrv(const Derivation & drv);
|
||||
|
||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState);
|
||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision);
|
||||
|
||||
void scanAndUpdateAllReferences(const Path & statePath);
|
||||
|
||||
void scanAndUpdateAllReferencesRecusively(const Path & storeOrstatePath);
|
||||
|
||||
void setStateRevisions(const Path & statePath, const RevisionNumbersSetClosure & revisions, const int revision);
|
||||
void setStateRevisions(const Path & statePath, const RevisionNumbersSet & revisions, const int revision);
|
||||
|
||||
bool queryStateRevisions(const Path & statePath, RevisionNumbersClosure & revisions, const int revision);
|
||||
bool queryStateRevisions(const Path & statePath, RevisionNumbers & revisions, const int revision);
|
||||
|
||||
bool queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,18 +11,18 @@ namespace nix {
|
|||
Derivation derivationFromPath(const Path & drvPath)
|
||||
{
|
||||
assertStorePath(drvPath);
|
||||
printMsg(lvlError, format("tttttttttttttttttt"));
|
||||
//printMsg(lvlError, format("tttttttttttttttttt"));
|
||||
store->ensurePath(drvPath);
|
||||
printMsg(lvlError, format("uuuuuuuuuuuuuuuuuu"));
|
||||
//printMsg(lvlError, format("uuuuuuuuuuuuuuuuuu"));
|
||||
ATerm t = ATreadFromNamedFile(drvPath.c_str());
|
||||
if (!t) throw Error(format("cannot read aterm from `%1%'") % drvPath);
|
||||
return parseDerivation(t);
|
||||
}
|
||||
|
||||
void computeFSClosure(const Path & path, PathSet & paths, const bool & withComponents, const bool & withState, bool flipDirection)
|
||||
void computeFSClosure(const Path & path, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection)
|
||||
{
|
||||
PathSet allPaths;
|
||||
computeFSClosureRec(path, allPaths, flipDirection);
|
||||
computeFSClosureRec(path, allPaths, revision, flipDirection);
|
||||
|
||||
if(!withComponents && !withState)
|
||||
throw Error(format("Useless call to computeFSClosure, at leat withComponents or withState must be true"));
|
||||
|
|
@ -50,7 +50,7 @@ void computeFSClosure(const Path & path, PathSet & paths, const bool & withCompo
|
|||
}
|
||||
}
|
||||
|
||||
void computeFSClosureRec(const Path & path, PathSet & paths, const bool & flipDirection)
|
||||
void computeFSClosureRec(const Path & path, PathSet & paths, const int revision, const bool & flipDirection)
|
||||
{
|
||||
if (paths.find(path) != paths.end()) return; //takes care of double entries
|
||||
|
||||
|
|
@ -60,19 +60,19 @@ void computeFSClosureRec(const Path & path, PathSet & paths, const bool & flipDi
|
|||
PathSet stateReferences;
|
||||
|
||||
if (flipDirection){
|
||||
store->queryReferrers(path, references, -1);
|
||||
store->queryStateReferrers(path, stateReferences, -1);
|
||||
store->queryReferrers(path, references, revision);
|
||||
store->queryStateReferrers(path, stateReferences, revision);
|
||||
}
|
||||
else{
|
||||
store->queryReferences(path, references, -1);
|
||||
store->queryStateReferences(path, stateReferences, -1);
|
||||
store->queryReferences(path, references, revision);
|
||||
store->queryStateReferences(path, stateReferences, revision);
|
||||
}
|
||||
|
||||
PathSet allReferences;
|
||||
allReferences = pathSets_union(references, stateReferences);
|
||||
|
||||
for (PathSet::iterator i = allReferences.begin(); i != allReferences.end(); ++i)
|
||||
computeFSClosureRec(*i, paths, flipDirection);
|
||||
computeFSClosureRec(*i, paths, revision, flipDirection);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ Derivation derivationFromPath(const Path & drvPath);
|
|||
We can currentky only compute the closure of the latsest revision!
|
||||
|
||||
returned. */
|
||||
void computeFSClosure(const Path & storePath, PathSet & paths, const bool & withComponents, const bool & withState, bool flipDirection = false);
|
||||
void computeFSClosure(const Path & storePath, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection = false);
|
||||
|
||||
void computeFSClosureRec(const Path & path, PathSet & paths, const bool & flipDirection); //private
|
||||
void computeFSClosureRec(const Path & path, PathSet & paths, const int revision, const bool & flipDirection); //TODO private
|
||||
|
||||
/* Return the path corresponding to the output identifier `id' in the
|
||||
given derivation. */
|
||||
|
|
|
|||
|
|
@ -457,7 +457,7 @@ bool RemoteStore::isStateDrv(const Derivation & drv)
|
|||
}
|
||||
|
||||
//TODO
|
||||
void RemoteStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState)
|
||||
void RemoteStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -475,13 +475,13 @@ void RemoteStore::scanAndUpdateAllReferencesRecusively(const Path & storeOrstate
|
|||
}
|
||||
|
||||
//TODO
|
||||
void RemoteStore::setStateRevisions(const Path & statePath, const RevisionNumbersSetClosure & revisions, const int revision)
|
||||
void RemoteStore::setStateRevisions(const Path & statePath, const RevisionNumbersSet & revisions, const int revision)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//TODO
|
||||
bool RemoteStore::queryStateRevisions(const Path & statePath, RevisionNumbersClosure & revisions, const int revision)
|
||||
bool RemoteStore::queryStateRevisions(const Path & statePath, RevisionNumbers & revisions, const int revision)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,15 +84,15 @@ public:
|
|||
|
||||
bool isStateDrv(const Derivation & drv);
|
||||
|
||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState);
|
||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision);
|
||||
|
||||
void scanAndUpdateAllReferences(const Path & statePath);
|
||||
|
||||
void scanAndUpdateAllReferencesRecusively(const Path & storeOrstatePath);
|
||||
|
||||
void setStateRevisions(const Path & statePath, const RevisionNumbersSetClosure & revisions, const int revision);
|
||||
void setStateRevisions(const Path & statePath, const RevisionNumbersSet & revisions, const int revision);
|
||||
|
||||
bool queryStateRevisions(const Path & statePath, RevisionNumbersClosure & revisions, const int revision);
|
||||
bool queryStateRevisions(const Path & statePath, RevisionNumbers & revisions, const int revision);
|
||||
|
||||
bool queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions);
|
||||
|
||||
|
|
|
|||
|
|
@ -153,18 +153,11 @@ void checkStatePath(const Derivation & drv)
|
|||
Error(format("The statepath from the Derivation does not match the recalculated statepath, are u trying to spoof the statepath?"));
|
||||
}
|
||||
|
||||
void calculateStateReposPath(const string & type, const Path statePath, const string subfolder, const string & suffix, const string & stateIdentifier, Path & rootPath, Path & fullPath)
|
||||
void calculateStateReposPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier, Path & path)
|
||||
{
|
||||
//This is a little trick: we could use the same hash as the statepath, but we change it so the repository also gets a unique scannable hash
|
||||
Hash hash = hashString(htSHA256, statePath);
|
||||
|
||||
//We also hash repository subfolders the prevent collisions
|
||||
if(subfolder.length() == 0)
|
||||
throw Error(format("Cannot create a repository for a subfolder without a name"));
|
||||
|
||||
string hash_subfolder = type + ":sha256:" + printHash(hash) + ":" + subfolder;
|
||||
string subfolder2 = printHash32(compressHash(hashString(htSHA256, hash_subfolder), 20)) + "-" + subfolder;
|
||||
|
||||
string suffix_stateIdentifier = stateIdentifier;
|
||||
if(suffix_stateIdentifier != "")
|
||||
suffix_stateIdentifier = "-" + suffix_stateIdentifier;
|
||||
|
|
@ -176,28 +169,18 @@ void calculateStateReposPath(const string & type, const Path statePath, const st
|
|||
checkStoreName(suffix);
|
||||
checkStoreName(stateIdentifier);
|
||||
|
||||
rootPath = nixStoreStateRepos + "/"
|
||||
path = nixStoreStateRepos + "/"
|
||||
+ printHash32(compressHash(hashString(htSHA256, s), 20))
|
||||
+ "-" + suffix + suffix_stateIdentifier;
|
||||
|
||||
fullPath = rootPath + "/" + subfolder2;
|
||||
+ "-" + suffix + suffix_stateIdentifier + "/";
|
||||
}
|
||||
|
||||
Path getStateReposPath(const string & type, const Path statePath, const string subfolder, const string & suffix, const string & stateIdentifier)
|
||||
Path getStateReposPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier)
|
||||
{
|
||||
Path fullPath;
|
||||
Path rootPath;
|
||||
calculateStateReposPath(type, statePath, subfolder, suffix, stateIdentifier, rootPath, fullPath);
|
||||
return fullPath;
|
||||
Path path;
|
||||
calculateStateReposPath(type, statePath, suffix, stateIdentifier, path);
|
||||
return path;
|
||||
}
|
||||
|
||||
Path getStateReposRootPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier)
|
||||
{
|
||||
Path fullPath;
|
||||
Path rootPath;
|
||||
calculateStateReposPath(type, statePath, "/", suffix, stateIdentifier, rootPath, fullPath);
|
||||
return rootPath;
|
||||
}
|
||||
|
||||
Path makeFixedOutputPath(bool recursive,
|
||||
string hashAlgo, Hash hash, string name)
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ public:
|
|||
virtual bool isStateDrv(const Derivation & drv) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState) = 0;
|
||||
virtual void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual void scanAndUpdateAllReferences(const Path & statePath) = 0;
|
||||
|
|
@ -224,10 +224,10 @@ public:
|
|||
virtual void scanAndUpdateAllReferencesRecusively(const Path & storeOrstatePath) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual void setStateRevisions(const Path & statePath, const RevisionNumbersSetClosure & revisions, const int revision) = 0;
|
||||
virtual void setStateRevisions(const Path & statePath, const RevisionNumbersSet & revisions, const int revision) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual bool queryStateRevisions(const Path & statePath, RevisionNumbersClosure & revisions, const int revision) = 0;
|
||||
virtual bool queryStateRevisions(const Path & statePath, RevisionNumbers & revisions, const int revision) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual bool queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions) = 0;
|
||||
|
|
@ -268,13 +268,11 @@ Path makeStatePath(const string & componentHash, const string & suffix, const st
|
|||
void checkStatePath(const Derivation & drv);
|
||||
|
||||
/* Calculates a unique store state repos path and also the root path */
|
||||
void calculateStateReposPath(const string & type, const Path statePath, const string subfolder, const string & suffix, const string & stateIdentifier, Path & rootPath, Path & fullPath);
|
||||
void calculateStateReposPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier, Path & path);
|
||||
|
||||
|
||||
/* Returns the full repository path */
|
||||
Path getStateReposPath(const string & type, const Path statePath, const string subfolder, const string & suffix, const string & stateIdentifier);
|
||||
|
||||
/* Returns the root path containing the repository's */
|
||||
Path getStateReposRootPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier);
|
||||
Path getStateReposPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier);
|
||||
|
||||
/* This is the preparatory part of addToStore() and addToStoreFixed();
|
||||
it computes the store path to which srcPath is to be copied.
|
||||
|
|
|
|||
|
|
@ -37,72 +37,54 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
|
|||
|
||||
PathSet intervalPaths;
|
||||
|
||||
//Make sure the 'root' path which holds the repositorys exists, so svn doenst complain.
|
||||
string repos_root_path = getStateReposRootPath("stateOutput:staterepospath", stateDir, drvName, stateIdentifier);
|
||||
//check if we can create state and staterepos dirs
|
||||
//TODO
|
||||
|
||||
Strings p_args;
|
||||
p_args.push_back("-p");
|
||||
p_args.push_back(repos_root_path);
|
||||
runProgram_AndPrintOutput("mkdir", true, p_args, "mkdir");
|
||||
//Create a repository for this state location
|
||||
string repos = getStateReposPath("stateOutput:staterepospath", stateDir, drvName, stateIdentifier);
|
||||
|
||||
printMsg(lvlTalkative, format("Adding statedir '%1%' from repository '%2%'") % stateDir % repos);
|
||||
|
||||
//TODO check if we can create state and staterepos dirs
|
||||
if(IsDirectory(repos))
|
||||
printMsg(lvlTalkative, format("Repos %1% already exists, so we use that repository") % repos);
|
||||
else{
|
||||
Strings p_args;
|
||||
p_args.push_back("create");
|
||||
p_args.push_back(repos);
|
||||
runProgram_AndPrintOutput(svnadminbin, true, p_args, "svnadmin"); //TODO create as nixbld.nixbld chmod 700... can you still commit then ??
|
||||
}
|
||||
|
||||
string statedir_svn = stateDir + "/.svn/";
|
||||
if( ! IsDirectory(statedir_svn) ){
|
||||
Strings p_args;
|
||||
p_args.push_back("checkout");
|
||||
p_args.push_back("file://" + repos);
|
||||
p_args.push_back(stateDir);
|
||||
runProgram_AndPrintOutput(svnbin, true, p_args, "svn"); //TODO checkout as user
|
||||
}
|
||||
else
|
||||
printMsg(lvlTalkative, format("Statedir %1% already exists, so dont check out its repository again") % statedir_svn);
|
||||
|
||||
for (DerivationStateOutputDirs::const_reverse_iterator i = stateOutputDirs.rbegin(); i != stateOutputDirs.rend(); ++i){
|
||||
DerivationStateOutputDir d = i->second;
|
||||
|
||||
string thisdir = d.path;
|
||||
string fullstatedir = stateDir + "/" + thisdir;
|
||||
Path statePath = fullstatedir; //TODO call coerce function
|
||||
Path fullstatedir = stateDir + "/" + thisdir;
|
||||
|
||||
//Check if and how this dir needs to be versioned
|
||||
if(d.type == "none"){
|
||||
Strings p_args;
|
||||
p_args.push_back("-p");
|
||||
p_args.push_back(fullstatedir);
|
||||
runProgram_AndPrintOutput("mkdir", true, p_args, "mkdir");
|
||||
continue;
|
||||
}
|
||||
|
||||
//Create a repository for this state location
|
||||
string repos = getStateReposPath("stateOutput:staterepospath", stateDir, thisdir, drvName, stateIdentifier);
|
||||
|
||||
|
||||
if(IsDirectory(repos))
|
||||
printMsg(lvlTalkative, format("Repos %1% already exists, so we use that repository") % repos);
|
||||
else{
|
||||
Strings p_args;
|
||||
p_args.push_back("create");
|
||||
p_args.push_back(repos);
|
||||
runProgram_AndPrintOutput(svnadminbin, true, p_args, "svnadmin"); //TODO create as nixbld.nixbld chmod 700... can you still commit then ??
|
||||
}
|
||||
Strings p_args;
|
||||
p_args.push_back("-p");
|
||||
p_args.push_back(fullstatedir);
|
||||
runProgram_AndPrintOutput("mkdir", true, p_args, "mkdir");
|
||||
|
||||
if(d.type == "interval"){
|
||||
intervalPaths.insert(statePath);
|
||||
intervalPaths.insert(fullstatedir);
|
||||
}
|
||||
|
||||
printMsg(lvlTalkative, format("Adding state subdir: %1% to %2% from repository %3%") % thisdir % fullstatedir % repos);
|
||||
|
||||
string fullstatedir_svn = fullstatedir + "/.svn/";
|
||||
if( ! IsDirectory(fullstatedir_svn) ){
|
||||
Strings p_args;
|
||||
p_args.push_back("checkout");
|
||||
p_args.push_back("file://" + repos);
|
||||
p_args.push_back(fullstatedir);
|
||||
runProgram_AndPrintOutput(svnbin, true, p_args, "svn"); //TODO checkout as user
|
||||
}
|
||||
else
|
||||
printMsg(lvlTalkative, format("Statedir %1% already exists, so dont check out its repository again") % fullstatedir_svn);
|
||||
}
|
||||
|
||||
//Initialize the counters for the statePaths that have an interval to 0
|
||||
vector<int> empty;
|
||||
store->setStatePathsInterval(intervalPaths, empty, true);
|
||||
|
||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
|
||||
//Initialize the revisions recursively
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,14 +60,9 @@ typedef set<Path> PathSet;
|
|||
|
||||
//state types
|
||||
typedef list<int> RevisionNumbers; //the Strings (list) of StateReferences and this list are connected by position
|
||||
typedef map<Path, RevisionNumbers> RevisionNumbersSetClosure; //We include to the paths to sort on
|
||||
typedef list<RevisionNumbers> RevisionNumbersClosure;
|
||||
typedef map<Path, int> RevisionNumbersSet; //We include to the paths to sort on
|
||||
typedef map<int, Strings> StateReferences;
|
||||
|
||||
//typedef std::map<int, Strings> StateReferencesKey;
|
||||
//typedef std::map<int, Strings> StateReferencesKey2;
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
lvlError,
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ static void opShowStatePath(Strings opFlags, Strings opArgs)
|
|||
}
|
||||
|
||||
//Prints the root path that contains the repoisitorys of the state of a component - indetiefier combination
|
||||
static void opShowStateReposRootPath(Strings opFlags, Strings opArgs)
|
||||
static void opShowStateReposPath(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
Path componentPath;
|
||||
Path statePath;
|
||||
|
|
@ -166,12 +166,12 @@ static void opShowStateReposRootPath(Strings opFlags, Strings opArgs)
|
|||
|
||||
//Get the a repository for this state location
|
||||
string drvName = drv.env.find("name")->second;
|
||||
string repos = getStateReposPath("stateOutput:staterepospath", statePath, "/", drvName, stateIdentifier); //this is a copy from store-state.cc
|
||||
string repos = getStateReposPath("stateOutput:staterepospath", statePath, drvName, stateIdentifier); //this is a copy from store-state.cc
|
||||
|
||||
printMsg(lvlError, format("%1%") % repos);
|
||||
}
|
||||
|
||||
RevisionNumbers readRevisionNumbers(const Derivation & drv)
|
||||
int readRevisionNumber(const Derivation & drv)
|
||||
{
|
||||
string svnbin = nixSVNPath + "/svn";
|
||||
RevisionNumbers revisions;
|
||||
|
|
@ -182,42 +182,22 @@ RevisionNumbers readRevisionNumbers(const Derivation & drv)
|
|||
Path statePath = stateOutputs.find("state")->second.statepath;
|
||||
string getStateIdentifier = stateOutputs.find("state")->second.stateIdentifier;
|
||||
|
||||
//TODO sort based on the repository
|
||||
vector<Path> sorted_repositorys;
|
||||
for (DerivationStateOutputDirs::const_reverse_iterator i = stateOutputDirs.rbegin(); i != stateOutputDirs.rend(); ++i){
|
||||
DerivationStateOutputDir d = i->second;
|
||||
string thisdir = d.path;
|
||||
//Get the a repository for this state location
|
||||
string repos = getStateReposPath("stateOutput:staterepospath", statePath, thisdir, drvName, getStateIdentifier); //this is a copy from store-state.cc
|
||||
sorted_repositorys.push_back(repos);
|
||||
}
|
||||
sort(sorted_repositorys.begin(), sorted_repositorys.end());
|
||||
string repos = getStateReposPath("stateOutput:staterepospath", statePath, drvName, getStateIdentifier); //this is a copy from store-state.cc
|
||||
|
||||
//After the sort read the paths
|
||||
for (vector<Path>::const_iterator i = sorted_repositorys.begin(); i != sorted_repositorys.end(); ++i){
|
||||
string repos = *i;
|
||||
Strings p_args;
|
||||
p_args.push_back(svnbin);
|
||||
p_args.push_back("file://" + repos);
|
||||
string output = runProgram(nixLibexecDir + "/nix/nix-readrevisions.sh", true, p_args); //run
|
||||
|
||||
//printMsg(lvlError, format("%1%") % repos);
|
||||
int pos = output.find("\n",0); //remove trailing \n
|
||||
output.erase(pos,1);
|
||||
|
||||
if(IsDirectory(repos)){
|
||||
Strings p_args;
|
||||
p_args.push_back(svnbin);
|
||||
p_args.push_back("file://" + repos);
|
||||
string output = runProgram(nixLibexecDir + "/nix/nix-readrevisions.sh", true, p_args); //run
|
||||
int revision;
|
||||
bool succeed = string2Int(output, revision);
|
||||
if(!succeed)
|
||||
throw Error(format("Cannot read revision number of path '%1%'") % repos);
|
||||
|
||||
int pos = output.find("\n",0); //remove trailing \n
|
||||
output.erase(pos,1);
|
||||
|
||||
int revision;
|
||||
bool succeed = string2Int(output, revision);
|
||||
if(!succeed)
|
||||
throw Error(format("Cannot read revision number of path '%1%'") % repos);
|
||||
revisions.push_back(revision); //insert into array
|
||||
}
|
||||
else
|
||||
revisions.push_back(-1);
|
||||
}
|
||||
return revisions;
|
||||
return revision;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -228,9 +208,7 @@ PathSet getAllStateDerivationsRecursively(const Path & storePath, const int revi
|
|||
{
|
||||
//Get recursively all state paths
|
||||
PathSet statePaths;
|
||||
store->storePathRequisites(storePath, false, statePaths, false, true);
|
||||
|
||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! include revision
|
||||
store->storePathRequisites(storePath, false, statePaths, false, true, revision);
|
||||
|
||||
//Find the matching drv with the statePath
|
||||
PathSet derivations;
|
||||
|
|
@ -259,10 +237,12 @@ static void queryAvailableStateRevisions(Strings opFlags, Strings opArgs)
|
|||
return;
|
||||
}
|
||||
|
||||
string revisions_txt="";
|
||||
for (RevisionNumbers::iterator i = revisions.begin(); i != revisions.end(); ++i)
|
||||
{
|
||||
printMsg(lvlError, format("Available Revision: %1%") % int2String(*i));
|
||||
revisions_txt += int2String(*i) + " ";
|
||||
}
|
||||
printMsg(lvlError, format("Available Revisions: %1%") % revisions_txt);
|
||||
}
|
||||
|
||||
static void revertToRevision(Strings opFlags, Strings opArgs)
|
||||
|
|
@ -275,51 +255,35 @@ static void revertToRevision(Strings opFlags, Strings opArgs)
|
|||
string program_args;
|
||||
Derivation drv = getDerivation_andCheckArgs(opFlags, opArgs, componentPath, statePath, binary, derivationPath, isStatePath, program_args);
|
||||
|
||||
bool recursive = true; //TODO !!!!!!!!!
|
||||
bool recursive = true; //TODO !!!!!!!!!!!!!!!!!
|
||||
|
||||
//First, revert own statepath
|
||||
|
||||
//Then, do the rest (if nessecary)
|
||||
//Insert the direct statePath or all recursive statePaths into the list
|
||||
PathSet drvs;
|
||||
if(recursive)
|
||||
drvs = getAllStateDerivationsRecursively(componentPath, revision_arg); //get dependecies (if neccecary | recusively) of all state components that need to be updated
|
||||
else
|
||||
drvs.insert(derivationPath);
|
||||
/*
|
||||
|
||||
//Revert each statePath in the list
|
||||
for (PathSet::iterator d = drvs.begin(); d != drvs.end(); ++d)
|
||||
{
|
||||
Path drvPath = *d;
|
||||
Derivation drv = derivationFromPath(drvPath);
|
||||
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
||||
Path statePath = stateOutputs.find("state")->second.statepath;
|
||||
DerivationStateOutputDirs stateOutputDirs = drv.stateOutputDirs;
|
||||
string drvName = drv.env.find("name")->second;
|
||||
|
||||
RevisionNumbersClosure getRivisionsClosure;
|
||||
bool b = store->queryStateRevisions(statePath, getRivisionsClosure, revision_arg);
|
||||
RevisionNumbers getRivisions;
|
||||
bool b = store->queryStateRevisions(statePath, getRivisions, revision_arg);
|
||||
|
||||
//sort
|
||||
for (DerivationStateOutputDirs::const_reverse_iterator i = stateOutputDirs.rbegin(); i != stateOutputDirs.rend(); ++i){
|
||||
string repos = getStateReposPath("stateOutput:staterepospath", statePath, drvName, stateIdentifier); //this is a copy from store-state.cc
|
||||
|
||||
DerivationStateOutputDir d = i->second;
|
||||
string thisdir = d.path;
|
||||
//Get the a repository for this state location
|
||||
string repos = getStateReposPath("stateOutput:staterepospath", statePath, thisdir, drvName, stateIdentifier); //this is a copy from store-state.cc
|
||||
|
||||
|
||||
|
||||
Strings p_args;
|
||||
p_args.push_back(nixSVNPath + "/svn");
|
||||
p_args.push_back(int2String(revision_arg));
|
||||
p_args.push_back("file://" + repos);
|
||||
string output = runProgram(nixLibexecDir + "/nix/nix-restorerevision.sh", true, p_args); //run
|
||||
|
||||
|
||||
}
|
||||
Strings p_args;
|
||||
p_args.push_back(nixSVNPath + "/svn");
|
||||
p_args.push_back(int2String(revision_arg));
|
||||
p_args.push_back("file://" + repos);
|
||||
string output = runProgram(nixLibexecDir + "/nix/nix-restorerevision.sh", true, p_args); //run
|
||||
}
|
||||
*/
|
||||
|
||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
}
|
||||
|
||||
static void opRunComponent(Strings opFlags, Strings opArgs)
|
||||
|
|
@ -343,7 +307,7 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
|||
//add locks ... ?
|
||||
//svn lock ... ?
|
||||
|
||||
//get dependecies (if neccecary | recusively) of all state components that need to be updated
|
||||
//get all current dependecies (if neccecary | recusively) of all state components that need to be updated
|
||||
PathSet root_drvs = getAllStateDerivationsRecursively(root_componentPath, -1);
|
||||
|
||||
//TODO maybe also scan the parameters for state or component hashes?
|
||||
|
|
@ -360,7 +324,7 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
|||
|
||||
//******************* With everything in place, we call the commit script on all statePaths **********************
|
||||
|
||||
map<Path, RevisionNumbers> rivisionsClosureMapping;
|
||||
RevisionNumbersSet rivisionMapping;
|
||||
|
||||
for (PathSet::iterator d = root_drvs.begin(); d != root_drvs.end(); ++d) //TODO first commit own state path?
|
||||
{
|
||||
|
|
@ -379,7 +343,6 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
|||
vector<string> subversionedpaths;
|
||||
vector<bool> subversionedpathsCommitBoolean;
|
||||
vector<string> nonversionedpaths; //of type none, no versioning needed
|
||||
vector<string> checkoutcommands;
|
||||
|
||||
//Get all the inverals from the database at once
|
||||
PathSet intervalPaths;
|
||||
|
|
@ -409,11 +372,6 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
|||
continue;
|
||||
}
|
||||
|
||||
//Get the a repository for this state location
|
||||
string repos = getStateReposPath("stateOutput:staterepospath", statePath, thisdir, drvName, stateIdentifier); //this is a copy from store-state.cc
|
||||
|
||||
//Add the checkout command in case its needed
|
||||
checkoutcommands.push_back(svnbin + " --ignore-externals checkout file://" + repos + " " + fullstatedir);
|
||||
subversionedpaths.push_back(fullstatedir);
|
||||
|
||||
if(d.type == "interval"){
|
||||
|
|
@ -434,8 +392,9 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
|||
throw Error(format("interval '%1%' is not handled in nix-state") % d.type);
|
||||
}
|
||||
|
||||
//Update the intervals again
|
||||
store->setStatePathsInterval(intervalPaths, intervals);
|
||||
//Get the a repository for this state location
|
||||
string repos = getStateReposPath("stateOutput:staterepospath", statePath, drvName, stateIdentifier); //this is a copy from store-state.cc
|
||||
string checkoutcommand = svnbin + " --ignore-externals checkout file://" + repos + " " + statePath;
|
||||
|
||||
//Call the commit script with the appropiate paramenters
|
||||
string subversionedstatepathsarray;
|
||||
|
|
@ -453,12 +412,6 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
|||
{
|
||||
nonversionedstatepathsarray += *(i) + " ";
|
||||
}
|
||||
string commandsarray;
|
||||
for (vector<string>::iterator i = checkoutcommands.begin(); i != checkoutcommands.end(); ++i)
|
||||
{
|
||||
//#HACK: I cant seem to find a way for bash to parse a 2 dimensional string array as argument, so we use a 1-d array with '|' as seperator
|
||||
commandsarray += "" + *(i) + " | ";
|
||||
}
|
||||
|
||||
//make the call to the commit script
|
||||
Strings p_args;
|
||||
|
|
@ -466,27 +419,29 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
|||
p_args.push_back(subversionedstatepathsarray);
|
||||
p_args.push_back(subversionedpathsCommitBooleansarray);
|
||||
p_args.push_back(nonversionedstatepathsarray);
|
||||
p_args.push_back(commandsarray);
|
||||
p_args.push_back(checkoutcommand);
|
||||
p_args.push_back(statePath);
|
||||
runProgram_AndPrintOutput(nixLibexecDir + "/nix/nix-statecommit.sh", true, p_args, "svn");
|
||||
|
||||
//Update the intervals again
|
||||
//store->setStatePathsInterval(intervalPaths, intervals); //TODO!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
//TODO
|
||||
//Scan if needed
|
||||
if(false)
|
||||
store->scanAndUpdateAllReferencesRecusively(statePath);
|
||||
|
||||
rivisionsClosureMapping[statePath] = readRevisionNumbers(drv); //Get current numbers
|
||||
rivisionMapping[statePath] = readRevisionNumber(drv); //Get current numbers
|
||||
}
|
||||
|
||||
//Store the revision numbers in the database for this statePath to a new revision
|
||||
store->setStateRevisions(root_statePath, rivisionsClosureMapping, -1);
|
||||
store->setStateRevisions(root_statePath, rivisionMapping, -1);
|
||||
|
||||
RevisionNumbersClosure getRivisionsClosure;
|
||||
bool b = store->queryStateRevisions(root_statePath, getRivisionsClosure, -1);
|
||||
RevisionNumbers getRivisions;
|
||||
bool b = store->queryStateRevisions(root_statePath, getRivisions, -1);
|
||||
|
||||
for (RevisionNumbersClosure::iterator d = getRivisionsClosure.begin(); d != getRivisionsClosure.end(); ++d){
|
||||
printMsg(lvlError, format("REVVV"));
|
||||
for (RevisionNumbers::iterator e = (*d).begin(); e != (*d).end(); ++e)
|
||||
printMsg(lvlError, format("REV %1%") % *e);
|
||||
for (RevisionNumbers::iterator i = getRivisions.begin(); i != getRivisions.end(); ++i){
|
||||
printMsg(lvlError, format("REV %1%") % int2String(*i));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -610,7 +565,7 @@ void run(Strings args)
|
|||
else if (arg == "--showstatepath")
|
||||
op = opShowStatePath;
|
||||
else if (arg == "--showstatereposrootpath")
|
||||
op = opShowStateReposRootPath;
|
||||
op = opShowStateReposPath;
|
||||
else if (arg == "--showderivations")
|
||||
op = opShowDerivations;
|
||||
else if (arg == "--showrevisions")
|
||||
|
|
|
|||
|
|
@ -304,15 +304,15 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
|||
i != opArgs.end(); ++i)
|
||||
{
|
||||
Path path = maybeUseOutput(fixStoreOrStatePath(*i), useOutput, forceRealise);
|
||||
if (query == qRequisites) store->storePathRequisites(path, includeOutputs, paths, true, false);
|
||||
else if (query == qRequisitesState) store->storePathRequisites(path, includeOutputs, paths, false, true);
|
||||
else if (query == qRequisitesFull) store->storePathRequisites(path, includeOutputs, paths, true, true);
|
||||
if (query == qRequisites) store->storePathRequisites(path, includeOutputs, paths, true, false, -1);
|
||||
else if (query == qRequisitesState) store->storePathRequisites(path, includeOutputs, paths, false, true, -1);
|
||||
else if (query == qRequisitesFull) store->storePathRequisites(path, includeOutputs, paths, true, true, -1);
|
||||
else if (query == qReferences) store->queryReferences(path, paths, -1);
|
||||
else if (query == qStateReferences) store->queryStateReferences(path, paths, -1); //latest revision
|
||||
else if (query == qReferrers) store->queryReferrers(path, paths, -1);
|
||||
else if (query == qStateReferrers) store->queryStateReferrers(path, paths, -1); //latest revision
|
||||
else if (query == qReferrersClosure) computeFSClosure(path, paths, true, false, true);
|
||||
else if (query == qReferrersClosureWithState) computeFSClosure(path, paths, true, true, true);
|
||||
else if (query == qReferrersClosure) computeFSClosure(path, paths, true, false, -1, true);
|
||||
else if (query == qReferrersClosureWithState) computeFSClosure(path, paths, true, true, -1, true);
|
||||
}
|
||||
Paths sorted = topoSortPaths(paths);
|
||||
for (Paths::reverse_iterator i = sorted.rbegin();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue