mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
Before creating multiple derivation - component instances
This commit is contained in:
parent
986a50ac78
commit
9c46444641
9 changed files with 120 additions and 97 deletions
|
|
@ -22,10 +22,21 @@ checkouts=( $5 )
|
|||
#echo nonversionedpaths: $nonversionedpaths
|
||||
#echo checkouts: $checkouts
|
||||
|
||||
|
||||
|
||||
#TODO
|
||||
#
|
||||
# silence "is already under version control" messages
|
||||
# after a "revert $x" you can silence the "skipped '$x'"
|
||||
#
|
||||
#TODO
|
||||
|
||||
|
||||
|
||||
i=0
|
||||
for path in ${subversionedpaths[@]}
|
||||
do
|
||||
if test -d $path; then
|
||||
if test -d $path; then #if the dir doesnt exist, than we dont hav to do anything
|
||||
cd $path;
|
||||
|
||||
output=$($svnbin stat 2>&1 | grep "is not a working copy");
|
||||
|
|
@ -37,38 +48,43 @@ do
|
|||
|
||||
echo "Entering $path"
|
||||
|
||||
allsubdirs=( $(echo *) ) #TODO, maybe also add hidden files starting with a '.' , but we dont want to add .svn dirs
|
||||
|
||||
subdirs=();
|
||||
for subdir in ${allsubdirs[@]} #add all, exlucding explicity stated direct versioned-subdirs or explicity stated nonversioned-subdirs
|
||||
allsubitems=( $(echo *) ) #TODO, maybe also add hidden files starting with a '.' , but we dont want to add .svn dirs
|
||||
#TODO2 maybe do something with svn stat to speed up ?
|
||||
subitems=();
|
||||
for subitem in ${allsubitems[@]} #add all, were going to exlucde explicity stated direct versioned-subdirs or explicity stated nonversioned-subdirs
|
||||
do #this is only to prevent some warnings, ultimately we would like svn add to have a option 'exclude dirs'
|
||||
subdir="$(pwd)/$subdir/";
|
||||
subitem="$(pwd)/$subitem";
|
||||
|
||||
if test -d $subitem; then #the subitem (file or a dir) may be a dir, so we add a / to the end
|
||||
subitem="$subitem/";
|
||||
fi
|
||||
|
||||
exclude=0;
|
||||
|
||||
for svnp in ${subversionedpaths[@]} #check if the subdir is in the list of subverioned paths
|
||||
for svnp in ${subversionedpaths[@]} #check if the subitem is in the list of subverioned paths
|
||||
do
|
||||
if [ "$svnp" = "$subdir" ]; then
|
||||
if [ "$svnp" = "$subitem" ]; then
|
||||
exclude=1;
|
||||
#echo "exclude versioned $svnp"
|
||||
fi
|
||||
done
|
||||
|
||||
for nonvp in ${nonversionedpaths[@]} #check if the subdir is in the list of dirs that aren't supposed to be versioned
|
||||
for nonvp in ${nonversionedpaths[@]} #check if the subitem is in the list of dirs that aren't supposed to be versioned
|
||||
do
|
||||
if [ "$nonvp" = "$subdir" ]; then
|
||||
if [ "$nonvp" = "$subitem" ]; then
|
||||
exclude=1;
|
||||
#echo "exclude nonversioned $svnp"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $exclude = 0 ]; then #Exclude the subdir if nessecary
|
||||
subdirs[${#subdirs[*]}]=$subdir
|
||||
if [ $exclude = 0 ]; then #Exclude the subitem if nessecary
|
||||
subitems[${#subitems[*]}]=$subitem
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$subdirs" != "" ]; then
|
||||
echo "adding ${subdirs[@]}"
|
||||
$debug svn add ${subdirs[@]} #add all subdirs
|
||||
if [ "$subitems" != "" ]; then
|
||||
echo "adding ${subitems[@]}"
|
||||
$debug svn add ${subitems[@]} #add all subitems
|
||||
|
||||
for revpath in ${nonversionedpaths[@]} #We need to revert sub-sub* dirs, since these havent been excluded
|
||||
do
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
|
|||
bool enableState = false; //We dont do state by default, but if a user defines stateDirs for example, than this becomes true.
|
||||
bool disableState = false; //Becomes true if the user explicitly says: no state
|
||||
string shareState = "none";
|
||||
string syncState = "all";
|
||||
string syncState = "none";
|
||||
string stateIdentifier = "";
|
||||
bool createDirsBeforeInstall = false;
|
||||
string runtimeStateParamters = "";
|
||||
|
|
|
|||
|
|
@ -764,7 +764,7 @@ void DerivationGoal::haveDerivation()
|
|||
assert(store->isValidPath(drvPath));
|
||||
|
||||
/* Get the derivation. */
|
||||
drv = derivationFromPath(drvPath); //wouter look here
|
||||
drv = derivationFromPath(drvPath);
|
||||
|
||||
for (DerivationOutputs::iterator i = drv.outputs.begin();
|
||||
i != drv.outputs.end(); ++i)
|
||||
|
|
@ -773,6 +773,8 @@ void DerivationGoal::haveDerivation()
|
|||
/* Check what outputs paths are not already valid. */
|
||||
PathSet invalidOutputs = checkPathValidity(false);
|
||||
|
||||
|
||||
|
||||
/* If they are all valid, then we're done. */
|
||||
if (invalidOutputs.size() == 0) {
|
||||
amDone(ecSuccess);
|
||||
|
|
@ -1377,6 +1379,7 @@ void DerivationGoal::startBuilder()
|
|||
tmpDir = createTempDir();
|
||||
|
||||
/* Create the state directory where the component can store it's state files place */
|
||||
//TODO MOVEEEEEEEEEEE
|
||||
//We only create state dirs when state is enabled and when the dirs need to be created before the installation
|
||||
if(drv.stateOutputs.size() != 0)
|
||||
if(drv.stateOutputs.find("state")->second.getCreateDirsBeforeInstall())
|
||||
|
|
@ -2476,9 +2479,10 @@ void LocalStore::buildDerivations(const PathSet & drvPaths)
|
|||
Worker worker;
|
||||
|
||||
Goals goals;
|
||||
for (PathSet::const_iterator i = drvPaths.begin();
|
||||
i != drvPaths.end(); ++i)
|
||||
for (PathSet::const_iterator i = drvPaths.begin(); i != drvPaths.end(); ++i){
|
||||
goals.insert(worker.makeDerivationGoal(*i));
|
||||
printMsg(lvlError, format("No component build, but state check: %1%") % *i);
|
||||
}
|
||||
|
||||
worker.run(goals);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,9 +54,9 @@ struct DerivationStateOutput
|
|||
}
|
||||
DerivationStateOutput(Path statepath, string hashAlgo, string hash, string stateIdentifier, string enabled, string shared, string synchronization, string createDirsBeforeInstall, string runtimeStateParamters)
|
||||
{
|
||||
if(shared != "none" || shared != "full" || shared != "group")
|
||||
if(shared != "none" && shared != "full" && shared != "group")
|
||||
throw Error(format("shared '%1%' is not a correct type") % shared);
|
||||
if(synchronization != "none" || synchronization != "exclusive-lock" || synchronization != "recursive-exclusive-lock")
|
||||
if(synchronization != "none" && synchronization != "exclusive-lock" && synchronization != "recursive-exclusive-lock")
|
||||
throw Error(format("synchronization '%1%' is not a correct type") % synchronization);
|
||||
|
||||
//TODO
|
||||
|
|
@ -93,7 +93,7 @@ struct DerivationStateOutputDir
|
|||
}
|
||||
DerivationStateOutputDir(string path, string type, string interval)
|
||||
{
|
||||
if(type != "none" || type != "manual" || type != "interval" || type != "full")
|
||||
if(type != "none" && type != "manual" && type != "interval" && type != "full")
|
||||
throw Error(format("interval '%1%' is not a correct type") % type);
|
||||
|
||||
this->path = path;
|
||||
|
|
|
|||
|
|
@ -1094,6 +1094,8 @@ void verifyStore(bool checkContents)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO Check statecounters table....
|
||||
|
||||
|
||||
txn.commit();
|
||||
|
|
@ -1142,6 +1144,9 @@ vector<int> getStatePathsInterval(const PathSet & statePaths)
|
|||
nixDB.queryString(txn, dbStateCounters, *i, data);
|
||||
|
||||
//TODO check if every key returns a value from the db
|
||||
if(data == ""){
|
||||
throw Error(format("Statepath `%1%' has returned no interval from the database") % *i);
|
||||
}
|
||||
|
||||
int n;
|
||||
if (!string2Int(data, n)) throw Error("number expected");
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ bool isStorePath(const Path & path)
|
|||
void assertStorePath(const Path & path)
|
||||
{
|
||||
if (!isStorePath(path))
|
||||
throw Error(format("path `%1%' is not in the Nix store") % path);
|
||||
throw Error(format("path `%1%' is not in the Nix store") % path); //TODO bug: this prints an empty path ...
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,14 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
|
||||
void dsfsdfas()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const DerivationStateOutputs & stateOutputs, const StringPairs & env)
|
||||
{
|
||||
Path statePath = stateOutputs.find("state")->second.statepath;
|
||||
|
|
|
|||
|
|
@ -491,8 +491,7 @@ static void installDerivations(Globals & globals,
|
|||
}
|
||||
|
||||
for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i)
|
||||
printMsg(lvlInfo,
|
||||
format("installing `%1%'") % i->name);
|
||||
printMsg(lvlInfo, format("installing `%1%'") % i->name);
|
||||
|
||||
if (globals.dryRun) {
|
||||
printMissing(globals.state, newElems);
|
||||
|
|
|
|||
|
|
@ -26,95 +26,91 @@ void printHelp()
|
|||
|
||||
//
|
||||
|
||||
static Derivation getDerivation_oneArgumentNoFlags(const Strings opFlags, const Strings opArgs)
|
||||
//
|
||||
Derivation getDerivation_andCheckArgs(Strings opFlags, Strings opArgs, Path & componentPath, Path & statePath, string & stateIdentifier, string & binary)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (opArgs.size() != 1) throw UsageError("only one argument allowed");
|
||||
string path = *opArgs.begin();
|
||||
string component = path; //TODO Parse
|
||||
Path componentPath = component; //TODO call coerce function
|
||||
return store->getStateDerivation(componentPath);
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (opArgs.size() != 1 && opArgs.size() != 2) throw UsageError("only one or two arguments allowed (the component path & the identiefier which can be empty)");
|
||||
|
||||
//Parse the full path like /nix/store/...../bin/hello
|
||||
string fullPath = opArgs.front();
|
||||
componentPath = fullPath.substr(nixStore.size() + 1, fullPath.size()); //+1 to strip off the /
|
||||
int pos = componentPath.find("/",0);
|
||||
componentPath = fullPath.substr(0, pos + nixStore.size() + 1);
|
||||
binary = fullPath.substr(pos + nixStore.size() + 1, fullPath.size());
|
||||
|
||||
//TODO CHECK for validity of componentPath ... ?
|
||||
|
||||
stateIdentifier = "";
|
||||
if(opArgs.size() == 2){
|
||||
opArgs.pop_front();
|
||||
stateIdentifier = opArgs.front();
|
||||
}
|
||||
//TODO check if this identifier exists !!!!!!!!!!!
|
||||
|
||||
//printMsg(lvlError, format("%1% - %2% - %3% - %4%") % componentPath % statePath % stateIdentifier % binary);
|
||||
|
||||
Derivation drv = store->getStateDerivation(componentPath);
|
||||
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
||||
statePath = stateOutputs.find("state")->second.statepath;
|
||||
return drv;
|
||||
}
|
||||
|
||||
|
||||
//********
|
||||
|
||||
|
||||
//Prints the statepath of a component - indetiefier combination
|
||||
static void opShowStatePath(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
Derivation drv = getDerivation_oneArgumentNoFlags(opFlags, opArgs);
|
||||
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
||||
Path statePath = stateOutputs.find("state")->second.statepath;
|
||||
Path componentPath;
|
||||
Path statePath;
|
||||
string stateIdentifier;
|
||||
string binary;
|
||||
Derivation drv = getDerivation_andCheckArgs(opFlags, opArgs, componentPath, statePath, stateIdentifier, binary);
|
||||
printMsg(lvlError, format("%1%") % statePath);
|
||||
}
|
||||
|
||||
|
||||
//Prints the root path that contains the repoisitorys of the state of a component - indetiefier combination
|
||||
static void opShowStateReposRootPath(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
Derivation drv = getDerivation_oneArgumentNoFlags(opFlags, opArgs);
|
||||
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
||||
Path statePath = stateOutputs.find("state")->second.statepath;
|
||||
|
||||
Path componentPath;
|
||||
Path statePath;
|
||||
string stateIdentifier;
|
||||
string binary;
|
||||
Derivation drv = getDerivation_andCheckArgs(opFlags, opArgs, componentPath, statePath, stateIdentifier, binary);
|
||||
string drvName = drv.env.find("name")->second;
|
||||
string stateIdentifier = stateOutputs.find("state")->second.stateIdentifier;
|
||||
|
||||
//Get the a repository for this state location
|
||||
string repos = makeStateReposPath("stateOutput:staterepospath", statePath, "", drvName, stateIdentifier); //this is a copy from store-state.cc
|
||||
repos = repos.substr(0, repos.length() - stateRootRepos.length());
|
||||
|
||||
repos = repos.substr(0, repos.length() - (stateRootRepos.length() + 1) );
|
||||
|
||||
printMsg(lvlError, format("%1%") % repos);
|
||||
}
|
||||
|
||||
|
||||
static void opCommitReferencesClosure(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
/*
|
||||
Paths referencesKeys;
|
||||
Transaction txn(nixDB);
|
||||
TableId dbReferences = nixDB.openTable("statecounters");
|
||||
|
||||
nixDB.enumTable(txn, dbReferences, referencesKeys);
|
||||
for (Paths::iterator i = referencesKeys.begin(); i != referencesKeys.end(); ++i)
|
||||
{
|
||||
printMsg(lvlError, format("NIX-STATE: `%1%'") % *i);
|
||||
}*/
|
||||
|
||||
//get the derivation of the current component
|
||||
Derivation drv = getDerivation_oneArgumentNoFlags(opFlags, opArgs);
|
||||
|
||||
Path componentPath;
|
||||
Path statePath;
|
||||
string stateIdentifier;
|
||||
string binary;
|
||||
|
||||
Derivation drv = getDerivation_andCheckArgs(opFlags, opArgs, componentPath, statePath, stateIdentifier, binary);
|
||||
DerivationStateOutputDirs stateOutputDirs = drv.stateOutputDirs;
|
||||
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
||||
DerivationOutputs outputs = drv.outputs;
|
||||
string drvName = drv.env.find("name")->second;
|
||||
string stateIdentifier = stateOutputs.find("state")->second.stateIdentifier;
|
||||
|
||||
|
||||
string path = *opArgs.begin();
|
||||
|
||||
//Data from user / profile
|
||||
string component = path; //TODO Parse
|
||||
Path componentPath = component; //TODO call coerce function
|
||||
|
||||
string identifier = "test";
|
||||
string binary = "hello";
|
||||
|
||||
//Wait for locks?
|
||||
|
||||
|
||||
//******************* Run the component
|
||||
//TODO
|
||||
|
||||
|
||||
//Run the component
|
||||
|
||||
|
||||
//********************* Commit state *********************
|
||||
|
||||
//get dependecies (if neccecary) of all state components that need to be updated
|
||||
//******************* Afterwards, call the commit script (recursively)
|
||||
|
||||
//get dependecies (if neccecary | recusively) of all state components that need to be updated
|
||||
PathSet paths = store->getStateReferencesClosure(componentPath);
|
||||
|
||||
//get their derivations
|
||||
//...
|
||||
|
||||
//call the bash script on all the the store-state components
|
||||
|
||||
|
||||
|
||||
//******************* Call the commit script (recursively)
|
||||
|
||||
//for(...){
|
||||
//
|
||||
|
|
@ -122,7 +118,6 @@ static void opCommitReferencesClosure(Strings opFlags, Strings opArgs)
|
|||
|
||||
string svnbin = nixSVNPath + "/svn";
|
||||
string svnadminbin = nixSVNPath + "/svnadmin";
|
||||
Path statePath = stateOutputs.find("state")->second.statepath;
|
||||
|
||||
//Vector includeing all commit scripts:
|
||||
vector<string> subversionedpaths;
|
||||
|
|
@ -137,10 +132,9 @@ static void opCommitReferencesClosure(Strings opFlags, Strings opArgs)
|
|||
|
||||
string thisdir = d.path;
|
||||
string fullstatedir = statePath + "/" + thisdir;
|
||||
Path statePath = fullstatedir; //TODO call coerce function
|
||||
|
||||
if(d.type == "interval"){
|
||||
intervalPaths.insert(statePath);
|
||||
intervalPaths.insert(fullstatedir);
|
||||
}
|
||||
}
|
||||
vector<int> intervals = store->getStatePathsInterval(intervalPaths);
|
||||
|
|
@ -166,20 +160,13 @@ static void opCommitReferencesClosure(Strings opFlags, Strings opArgs)
|
|||
subversionedpaths.push_back(fullstatedir);
|
||||
|
||||
if(d.type == "interval"){
|
||||
|
||||
//TODO comment
|
||||
|
||||
//Get the interval-counter from the database, and update it.
|
||||
//printMsg(lvlError, format("Interval: %1% - %2%") % % );
|
||||
|
||||
//Get the interval-counter from the database
|
||||
int interval_counter = intervals[intervalAt];
|
||||
int interval = d.getInterval();
|
||||
|
||||
subversionedpathsCommitBoolean.push_back(interval_counter % interval == 0);
|
||||
|
||||
//update the interval
|
||||
intervals[intervalAt] = interval_counter + 1;
|
||||
|
||||
intervalAt++;
|
||||
}
|
||||
else if(d.type == "full")
|
||||
|
|
@ -191,7 +178,7 @@ static void opCommitReferencesClosure(Strings opFlags, Strings opArgs)
|
|||
}
|
||||
|
||||
//Update the intervals again
|
||||
//store->setStatePathsInterval(intervalPaths, intervals); //TODO
|
||||
//store->setStatePathsInterval(intervalPaths, intervals);
|
||||
|
||||
//Call the commit script with the appropiate paramenters
|
||||
string subversionedstatepathsarray;
|
||||
|
|
@ -248,6 +235,10 @@ void run(Strings args)
|
|||
--run-without-commit
|
||||
|
||||
--backup
|
||||
|
||||
--exclude-commit-paths
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue