mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 20:20:58 +01:00
Before modifying commit shell script
This commit is contained in:
parent
cbd0d39583
commit
653e557e81
10 changed files with 140 additions and 91 deletions
|
|
@ -1612,6 +1612,7 @@ void DerivationGoal::computeClosure()
|
|||
map<Path, PathSet> allReferences;
|
||||
map<Path, Hash> contentHashes;
|
||||
|
||||
//TODO MOVE THIS TO A PLACE THAT ALSO GETS CALLED WHEN WE DONT NEED TO BUILD ANYTHING
|
||||
//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())
|
||||
|
|
|
|||
|
|
@ -90,7 +90,13 @@ struct DerivationStateOutputDir
|
|||
}
|
||||
|
||||
int getInterval(){
|
||||
return 0; //TODO
|
||||
if(interval == "")
|
||||
return 0;
|
||||
else{
|
||||
int i;
|
||||
if (!string2Int(interval, i)) throw Error("interval is not a number");
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
//sort function
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ string nixSVNPath = "/UNINIT";
|
|||
string nixConfDir = "/UNINIT";
|
||||
string nixLibexecDir = "/UNINIT";
|
||||
string nixBinDir = "/UNINIT";
|
||||
string stateRootRepos = "root_repos/";
|
||||
|
||||
bool keepFailed = false;
|
||||
bool keepGoing = false;
|
||||
|
|
|
|||
|
|
@ -75,6 +75,9 @@ extern string thisSystem;
|
|||
infinity. */
|
||||
extern unsigned int maxSilentTime;
|
||||
|
||||
//TODO
|
||||
extern string stateRootRepos;
|
||||
|
||||
Strings querySetting(const string & name, const Strings & def);
|
||||
|
||||
string querySetting(const string & name, const string & def);
|
||||
|
|
|
|||
|
|
@ -1162,7 +1162,7 @@ Derivation getStateDerivation(const Path & path)
|
|||
|
||||
//Get derivations of references
|
||||
nixDB.queryString(txn, dbDerivers, path, data);
|
||||
printMsg(lvlError, format("DERIVERS %1%") % data);
|
||||
//printMsg(lvlError, format("DERIVERS %1%") % data);
|
||||
|
||||
txn.commit();
|
||||
|
||||
|
|
|
|||
|
|
@ -97,8 +97,16 @@ Path makeStatePath(const string & type, const Hash & hash, const string & suffix
|
|||
+ "-" + suffix + suffix_stateIdentifier;
|
||||
}
|
||||
|
||||
Path makeStateReposPath(const string & type, const Hash & hash, const string & suffix, const string & stateIdentifier)
|
||||
Path makeStateReposPath(const string & type, const Path statePath, const string subfolder, const string & suffix, const string & stateIdentifier)
|
||||
{
|
||||
//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);
|
||||
|
||||
//A little tick again, we dont want to add other repositorys in the root repository, so we rename it.
|
||||
string subfolder_ = subfolder;
|
||||
if(subfolder == "")
|
||||
subfolder_ = stateRootRepos;
|
||||
|
||||
string suffix_stateIdentifier = stateIdentifier;
|
||||
if(suffix_stateIdentifier != "")
|
||||
suffix_stateIdentifier = "-" + suffix_stateIdentifier;
|
||||
|
|
@ -112,7 +120,7 @@ Path makeStateReposPath(const string & type, const Hash & hash, const string & s
|
|||
|
||||
return nixStoreStateRepos + "/"
|
||||
+ printHash32(compressHash(hashString(htSHA256, s), 20))
|
||||
+ "-" + suffix + suffix_stateIdentifier;
|
||||
+ "-" + suffix + suffix_stateIdentifier + "/" + subfolder_;
|
||||
}
|
||||
|
||||
Path makeFixedOutputPath(bool recursive,
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ Path makeFixedOutputPath(bool recursive,
|
|||
Path makeStatePath(const string & type, const Hash & hash, const string & suffix, const string & stateIdentifier);
|
||||
|
||||
/* Constructs a unique store state repos path name. */
|
||||
Path makeStateReposPath(const string & type, const Hash & hash, const string & suffix, const string & stateIdentifier);
|
||||
Path makeStateReposPath(const string & type, const Path statePath, const string subfolder, const string & suffix, const string & stateIdentifier);
|
||||
|
||||
|
||||
/* This is the preparatory part of addToStore() and addToStoreFixed();
|
||||
|
|
|
|||
|
|
@ -22,29 +22,15 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
|
|||
string drvName = env.find("name")->second;
|
||||
string stateIdentifier = stateOutputs.find("state")->second.stateIdentifier;
|
||||
|
||||
//Convert the map into a sortable vector
|
||||
vector<DerivationStateOutputDir> stateDirsVector;
|
||||
for (DerivationStateOutputDirs::const_reverse_iterator i = stateOutputDirs.rbegin(); i != stateOutputDirs.rend(); ++i){
|
||||
stateDirsVector.push_back(i->second);
|
||||
}
|
||||
sort(stateDirsVector.begin(), stateDirsVector.end());
|
||||
|
||||
printMsg(lvlError, format("stateDir `%1%'") % stateDir);
|
||||
|
||||
string svnbin = nixSVNPath + "/svn";
|
||||
string svnadminbin = nixSVNPath + "/svnadmin";
|
||||
|
||||
//Vector includeing all commit scripts:
|
||||
vector<string> commitscript;
|
||||
vector<string> subversionedpaths;
|
||||
vector<int> subversionedpathsInterval;
|
||||
vector<string> nonversionedpaths; //of type none, no versioning needed
|
||||
vector<string> checkoutcommands;
|
||||
PathSet statePaths;
|
||||
|
||||
for (vector<DerivationStateOutputDir>::iterator i = stateDirsVector.begin(); i != stateDirsVector.end(); ++i)
|
||||
{
|
||||
DerivationStateOutputDir d = *(i);
|
||||
PathSet intervalPaths;
|
||||
|
||||
//TODO check if we can create stata and staterepos dirs
|
||||
|
||||
for (DerivationStateOutputDirs::const_reverse_iterator i = stateOutputDirs.rbegin(); i != stateOutputDirs.rend(); ++i){
|
||||
DerivationStateOutputDir d = i->second;
|
||||
|
||||
string thisdir = d.path;
|
||||
string fullstatedir = stateDir + "/" + thisdir;
|
||||
|
|
@ -56,69 +42,29 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
|
|||
if(true){
|
||||
executeAndPrintShellCommand("mkdir -p " + fullstatedir, "mkdir");
|
||||
}
|
||||
nonversionedpaths.push_back(fullstatedir);
|
||||
continue;
|
||||
}
|
||||
|
||||
//Create a repository for this state location
|
||||
Hash hash = hashString(htSHA256, stateDir + thisdir);
|
||||
string repos = makeStateReposPath("stateOutput:staterepospath", hash, drvName, stateIdentifier);
|
||||
executeAndPrintShellCommand(svnadminbin + " create " + repos, "svnadmin"); //TODO create as nixbld.nixbld chmod 700
|
||||
string repos = makeStateReposPath("stateOutput:staterepospath", stateDir, thisdir, drvName, stateIdentifier);
|
||||
executeAndPrintShellCommand("mkdir -p " + repos, "mkdir");
|
||||
executeAndPrintShellCommand(svnadminbin + " create " + repos, "svnadmin"); //TODO create as nixbld.nixbld chmod 700... can you still commit than ??
|
||||
|
||||
//
|
||||
string checkoutcommand = svnbin + " checkout file://" + repos + " " + fullstatedir;
|
||||
checkoutcommands.push_back(checkoutcommand);
|
||||
subversionedpaths.push_back(fullstatedir);
|
||||
|
||||
if(d.type == "interval"){
|
||||
statePaths.insert(statePath);
|
||||
subversionedpathsInterval.push_back(d.getInterval());
|
||||
intervalPaths.insert(statePath);
|
||||
}
|
||||
else
|
||||
subversionedpathsInterval.push_back(0);
|
||||
|
||||
//TODO REPLACE TRUE INTO VAR OF CREATEING DIRS BEFORE OR AFTER INSTALL
|
||||
if(true){
|
||||
printMsg(lvlError, format("Adding state subdir: %1% to %2% from repository %3%") % thisdir % fullstatedir % repos);
|
||||
string checkoutcommand = svnbin + " checkout file://" + repos + " " + fullstatedir;
|
||||
executeAndPrintShellCommand(checkoutcommand, "svn"); //TODO checkout as user
|
||||
}
|
||||
}
|
||||
|
||||
//Add the statePaths that have an interval
|
||||
//Initialize the counters for the statePaths that have an interval to 0
|
||||
vector<int> empty;
|
||||
store->setStatePathsInterval(statePaths, empty, true);
|
||||
|
||||
//create super commit script
|
||||
printMsg(lvlError, format("svnbin=%1%") % svnbin);
|
||||
string subversionedstatepathsarray = "subversionedpaths=( ";
|
||||
for (vector<string>::iterator i = subversionedpaths.begin(); i != subversionedpaths.end(); ++i)
|
||||
{
|
||||
subversionedstatepathsarray += *(i) + " ";
|
||||
}
|
||||
printMsg(lvlError, format("%1%)") % subversionedstatepathsarray);
|
||||
string subversionedpathsIntervalsarray = "subversionedpathsInterval=( ";
|
||||
for (vector<int>::iterator i = subversionedpathsInterval.begin(); i != subversionedpathsInterval.end(); ++i)
|
||||
{
|
||||
subversionedpathsIntervalsarray += int2String(*i) + " ";
|
||||
}
|
||||
printMsg(lvlError, format("%1%)") % subversionedpathsIntervalsarray);
|
||||
string nonversionedstatepathsarray = "nonversionedpaths=( ";
|
||||
for (vector<string>::iterator i = nonversionedpaths.begin(); i != nonversionedpaths.end(); ++i)
|
||||
{
|
||||
nonversionedstatepathsarray += *(i) + " ";
|
||||
}
|
||||
printMsg(lvlError, format("%1%)") % nonversionedstatepathsarray);
|
||||
string commandsarray = "checkouts=( ";
|
||||
for (vector<string>::iterator i = checkoutcommands.begin(); i != checkoutcommands.end(); ++i)
|
||||
{
|
||||
commandsarray += "\"" + *(i) + "\" ";
|
||||
}
|
||||
printMsg(lvlError, format("%1%)") % commandsarray);
|
||||
for (vector<string>::iterator i = commitscript.begin(); i != commitscript.end(); ++i)
|
||||
{
|
||||
string s = *(i);
|
||||
printMsg(lvlError, format("%1%") % s);
|
||||
}
|
||||
store->setStatePathsInterval(intervalPaths, empty, true);
|
||||
}
|
||||
|
||||
//executes a shell command and captures and prints the output.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue