mirror of
https://github.com/NixOS/nix.git
synced 2025-11-27 04:30:59 +01:00
This commit is contained in:
parent
588356c30a
commit
c0dceea9f0
12 changed files with 95 additions and 64 deletions
|
|
@ -1415,7 +1415,7 @@ DerivationGoal::PrepareBuildReply DerivationGoal::prepareBuild()
|
|||
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, 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 ..... ?????????????????????
|
||||
computeFSClosure(inDrv.outputs[*j].path, inputStatePaths, false, true, 0);
|
||||
}
|
||||
else
|
||||
throw BuildError(
|
||||
|
|
|
|||
|
|
@ -94,13 +94,12 @@ static TableId dbDerivers = 0;
|
|||
*/
|
||||
static TableId dbStateCounters = 0;
|
||||
|
||||
/* dbStateInfo :: Path ->
|
||||
/* dbStateInfo :: StorePath -> [(StatePath, identifier, username)]
|
||||
*
|
||||
* This table lists all the store components, that are state-store components
|
||||
* meaning that this component has a /nix/state/ entry to store its state
|
||||
* and thus this component (should) have a reference to that state path
|
||||
*
|
||||
* TODO the value is now empty but we could store the entire DRV in here in the future
|
||||
*/
|
||||
static TableId dbStateInfo = 0;
|
||||
|
||||
|
|
@ -133,17 +132,8 @@ static TableId dbStateRevisionsComments = 0;
|
|||
*
|
||||
* /nix/state/HASH-A-1.0-test-KEY-1185473750
|
||||
* -->
|
||||
* [ 1185473750, 00118547375 ] // TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PATH-SS
|
||||
* [ (statePath/log, 1185473750), (statePath/output.dat, 1185473751) ]
|
||||
*
|
||||
* The timestamps are ordered based on the path of the subfolder !!
|
||||
*
|
||||
* So if a has:
|
||||
*
|
||||
* /nix/state/....A../log
|
||||
* /nix/state/....A../cache
|
||||
*
|
||||
* then ./cache has TS 1185473750
|
||||
* and ./log has TS 00118547375
|
||||
*
|
||||
*/
|
||||
static TableId dbStateSnapshots = 0;
|
||||
|
|
|
|||
|
|
@ -132,16 +132,10 @@ void revertToRevisionTxn(const Transaction & txn, const Path & statePath, const
|
|||
//Dir: Remove a slash at the end, we create /nix/state/...../cachedir@1234/
|
||||
//File: Or create /nix/state/..../logfile.txt@1234
|
||||
string revertPathOrFile_e;
|
||||
if(revertPathOrFile.substr(revertPathOrFile.length() -1 , revertPathOrFile.length()) == "/"){
|
||||
if(revertPathOrFile.substr(revertPathOrFile.length() -1 , revertPathOrFile.length()) == "/")
|
||||
revertPathOrFile_e = revertPathOrFile.substr(0 , revertPathOrFile.length() -1) + "@" + unsignedInt2String(epoch) + "/";
|
||||
|
||||
//TODO IF IS FILE: REMOVE THE FILE todo MOVE THIS INTO RSYNCPATHS???
|
||||
}
|
||||
else{
|
||||
else
|
||||
revertPathOrFile_e = revertPathOrFile + "@" + unsignedInt2String(epoch);
|
||||
|
||||
//TODO IF IS DIR: REMOVE THE DIR
|
||||
}
|
||||
|
||||
rsyncPaths(revertPathOrFile_e, revertPathOrFile, false);
|
||||
}
|
||||
|
|
@ -235,7 +229,6 @@ Snapshots commitStatePathTxn(const Transaction & txn, const Path & statePath)
|
|||
}
|
||||
|
||||
//TODO include this call in the validate function
|
||||
//TODO ONLY CALL THIS FUNCTION ON A NON-SHARED STATE PATH!!!!!!!!!!!
|
||||
void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePath
|
||||
, PathSet & newFoundComponentReferences, PathSet & newFoundStateReferences) //only for recursion
|
||||
{
|
||||
|
|
@ -245,10 +238,8 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa
|
|||
|
||||
//printMsg(lvlError, format("scanAndUpdateAllReferencesTxn: '%1%' - %2%") % statePath % revision);
|
||||
|
||||
//TODO check if path is not a shared path !
|
||||
//TODO
|
||||
//TODO Unshare the path:
|
||||
//TODO Path statePath_ns = toNonSharedPathTxn(txn, statePath);
|
||||
//Check if path is not a shared path
|
||||
Path statePath_ns = toNonSharedPathTxn(txn, statePath);
|
||||
|
||||
//get all possible state and component references
|
||||
PathSet allComponentPaths;
|
||||
|
|
@ -266,14 +257,14 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa
|
|||
//TODO maybe only scan in the changeset (patch) for new references? (this will be difficult and depending on the underlying versioning system)
|
||||
|
||||
//Scan in for (new) component and state references
|
||||
PathSet state_references = scanForReferences(statePath, allComponentPaths2);
|
||||
PathSet state_stateReferences = scanForStateReferences(statePath, allStatePaths);
|
||||
PathSet state_references = scanForReferences(statePath_ns, allComponentPaths2);
|
||||
PathSet state_stateReferences = scanForStateReferences(statePath_ns, allStatePaths);
|
||||
|
||||
//Retrieve old references
|
||||
PathSet old_references;
|
||||
PathSet old_state_references;
|
||||
queryXReferencesTxn(txn, statePath, old_references, true, 0); //get the latsest references
|
||||
queryXReferencesTxn(txn, statePath, old_state_references, false, 0);
|
||||
queryXReferencesTxn(txn, statePath_ns, old_references, true, 0); //get the latsest references
|
||||
queryXReferencesTxn(txn, statePath_ns, old_state_references, false, 0);
|
||||
|
||||
//Check for added and removed paths
|
||||
PathSet diff_references_removed;
|
||||
|
|
@ -290,22 +281,22 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa
|
|||
//Print error, but we could also throw an error.
|
||||
if(diff_references_added.size() != 0)
|
||||
for (PathSet::iterator i = diff_references_added.begin(); i != diff_references_added.end(); ++i)
|
||||
printMsg(lvlError, format("Added component reference found!: '%1%' in state path '%2%'") % (*i) % statePath);
|
||||
printMsg(lvlError, format("Added component reference found!: '%1%' in state path '%2%'") % (*i) % statePath_ns);
|
||||
if(diff_references_removed.size() != 0)
|
||||
for (PathSet::iterator i = diff_references_removed.begin(); i != diff_references_removed.end(); ++i)
|
||||
printMsg(lvlError, format("Removed component reference found!: '%1%' in state path '%2%'") % (*i) % statePath);
|
||||
printMsg(lvlError, format("Removed component reference found!: '%1%' in state path '%2%'") % (*i) % statePath_ns);
|
||||
if(diff_state_references_added.size() != 0)
|
||||
for (PathSet::iterator i = diff_state_references_added.begin(); i != diff_state_references_added.end(); ++i)
|
||||
printMsg(lvlError, format("Added state reference found!: '%1%' in state path '%2%'") % (*i) % statePath);
|
||||
printMsg(lvlError, format("Added state reference found!: '%1%' in state path '%2%'") % (*i) % statePath_ns);
|
||||
if(diff_state_references_removed.size() != 0)
|
||||
for (PathSet::iterator i = diff_state_references_removed.begin(); i != diff_state_references_removed.end(); ++i)
|
||||
printMsg(lvlError, format("Removed state reference found!: '%1%' in state path '%2%'") % (*i) % statePath);
|
||||
printMsg(lvlError, format("Removed state reference found!: '%1%' in state path '%2%'") % (*i) % statePath_ns);
|
||||
|
||||
//We always set the referernces so we know they were scanned (maybe the same) at a certain time
|
||||
printMsg(lvlError, format("Updating new references for statepath: '%1%'") % statePath);
|
||||
Path drvPath = queryStatePathDrvTxn(txn, statePath);
|
||||
printMsg(lvlError, format("Updating new references for statepath: '%1%'") % statePath_ns);
|
||||
Path drvPath = queryStatePathDrvTxn(txn, statePath_ns);
|
||||
registerValidPath(txn,
|
||||
statePath,
|
||||
statePath_ns,
|
||||
Hash(), //emtpy hash
|
||||
state_references,
|
||||
state_stateReferences,
|
||||
|
|
@ -350,6 +341,10 @@ void rsyncPaths(const Path & from, const Path & to, const bool addSlashes) //TO
|
|||
if(!DirectoryExist(to))
|
||||
throw Error(format("Path `%1%' doenst exist ...") % to);
|
||||
*/
|
||||
|
||||
//TODO IF IS FILE: REMOVE THE FILE todo MOVE THIS INTO RSYNCPATHS???
|
||||
//TODO IF IS DIR: REMOVE THE DIR
|
||||
|
||||
|
||||
Path from2 = from;
|
||||
Path to2 = to;
|
||||
|
|
@ -684,23 +679,6 @@ bool queryStateRevisions(Database & nixDB, const Transaction & txn, TableId revi
|
|||
unsigned int getTimestamp;
|
||||
splitDBRevKey(*i, getStatePath, getTimestamp);
|
||||
|
||||
//query state versioined directorys/files
|
||||
//TODO REMOVE
|
||||
/*
|
||||
vector<Path> sortedPaths;
|
||||
Derivation drv = derivationFromPathTxn(txn, queryStatePathDrvTxn(txn, getStatePath));
|
||||
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
||||
DerivationStateOutputDirs stateOutputDirs = drv.stateOutputDirs;
|
||||
for (DerivationStateOutputDirs::const_iterator j = stateOutputDirs.begin(); j != stateOutputDirs.end(); ++j){
|
||||
string thisdir = (j->second).path;
|
||||
string fullstatedir = getStatePath + "/" + thisdir;
|
||||
if(thisdir == "/") //exception for the root dir
|
||||
fullstatedir = statePath + "/";
|
||||
sortedPaths.push_back(fullstatedir);
|
||||
}
|
||||
sort(sortedPaths.begin(), sortedPaths.end()); //sort
|
||||
*/
|
||||
|
||||
Strings snapshots_s;
|
||||
Snapshots snapshots;
|
||||
nixDB.queryStrings(txn, snapshots_table, *i, snapshots_s);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ Query flags:
|
|||
--xml: show output in XML format
|
||||
--status / -s: print installed/present status
|
||||
--no-name: hide derivation names
|
||||
--attr / -A: shows the unambiguous attribute name of the
|
||||
--attr-path / -P: shows the unambiguous attribute name of the
|
||||
derivation which can be used when installing with -A
|
||||
--system: print the platform type of the derivation
|
||||
--compare-versions / -c: compare version to available or installed
|
||||
|
|
|
|||
|
|
@ -333,10 +333,11 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
|||
r_commit = false;
|
||||
}
|
||||
else if(*i == "--statehelp"){
|
||||
printMsg(lvlError, format("%1%") % padd("", '-', 100));
|
||||
//printMsg(lvlError, format("%1%") % padd("", '-', 100));
|
||||
printHelp();
|
||||
r_scanforReferences = false;
|
||||
r_commit = false;
|
||||
return;
|
||||
}
|
||||
|
||||
//printMsg(lvlError, format("ARG %1%") % *i);
|
||||
|
|
@ -357,7 +358,7 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
|||
|
||||
//******************* Scan for new references if neccecary
|
||||
if(r_scanforReferences)
|
||||
store->scanAndUpdateAllReferences(root_statePath, true); //TODO make recursive a paramter?
|
||||
store->scanAndUpdateAllReferences(root_statePath, true); //TODO make recursive a paramter? TXN???
|
||||
|
||||
|
||||
//******************* With everything in place, we call the commit script on all statePaths (in)directly referenced **********************
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue