1
1
Fork 0
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:
Wouter den Breejen 2007-05-31 17:18:13 +00:00
parent 986a50ac78
commit 9c46444641
9 changed files with 120 additions and 97 deletions

View file

@ -22,10 +22,21 @@ checkouts=( $5 )
#echo nonversionedpaths: $nonversionedpaths #echo nonversionedpaths: $nonversionedpaths
#echo checkouts: $checkouts #echo checkouts: $checkouts
#TODO
#
# silence "is already under version control" messages
# after a "revert $x" you can silence the "skipped '$x'"
#
#TODO
i=0 i=0
for path in ${subversionedpaths[@]} for path in ${subversionedpaths[@]}
do 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; cd $path;
output=$($svnbin stat 2>&1 | grep "is not a working copy"); output=$($svnbin stat 2>&1 | grep "is not a working copy");
@ -37,38 +48,43 @@ do
echo "Entering $path" echo "Entering $path"
allsubdirs=( $(echo *) ) #TODO, maybe also add hidden files starting with a '.' , but we dont want to add .svn dirs 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 ?
subdirs=(); subitems=();
for subdir in ${allsubdirs[@]} #add all, exlucding explicity stated direct versioned-subdirs or explicity stated nonversioned-subdirs 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' 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; 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 do
if [ "$svnp" = "$subdir" ]; then if [ "$svnp" = "$subitem" ]; then
exclude=1; exclude=1;
#echo "exclude versioned $svnp" #echo "exclude versioned $svnp"
fi fi
done 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 do
if [ "$nonvp" = "$subdir" ]; then if [ "$nonvp" = "$subitem" ]; then
exclude=1; exclude=1;
#echo "exclude nonversioned $svnp" #echo "exclude nonversioned $svnp"
fi fi
done done
if [ $exclude = 0 ]; then #Exclude the subdir if nessecary if [ $exclude = 0 ]; then #Exclude the subitem if nessecary
subdirs[${#subdirs[*]}]=$subdir subitems[${#subitems[*]}]=$subitem
fi fi
done done
if [ "$subdirs" != "" ]; then if [ "$subitems" != "" ]; then
echo "adding ${subdirs[@]}" echo "adding ${subitems[@]}"
$debug svn add ${subdirs[@]} #add all subdirs $debug svn add ${subitems[@]} #add all subitems
for revpath in ${nonversionedpaths[@]} #We need to revert sub-sub* dirs, since these havent been excluded for revpath in ${nonversionedpaths[@]} #We need to revert sub-sub* dirs, since these havent been excluded
do do

View file

@ -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 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 bool disableState = false; //Becomes true if the user explicitly says: no state
string shareState = "none"; string shareState = "none";
string syncState = "all"; string syncState = "none";
string stateIdentifier = ""; string stateIdentifier = "";
bool createDirsBeforeInstall = false; bool createDirsBeforeInstall = false;
string runtimeStateParamters = ""; string runtimeStateParamters = "";

View file

@ -764,7 +764,7 @@ void DerivationGoal::haveDerivation()
assert(store->isValidPath(drvPath)); assert(store->isValidPath(drvPath));
/* Get the derivation. */ /* Get the derivation. */
drv = derivationFromPath(drvPath); //wouter look here drv = derivationFromPath(drvPath);
for (DerivationOutputs::iterator i = drv.outputs.begin(); for (DerivationOutputs::iterator i = drv.outputs.begin();
i != drv.outputs.end(); ++i) i != drv.outputs.end(); ++i)
@ -773,6 +773,8 @@ void DerivationGoal::haveDerivation()
/* Check what outputs paths are not already valid. */ /* Check what outputs paths are not already valid. */
PathSet invalidOutputs = checkPathValidity(false); PathSet invalidOutputs = checkPathValidity(false);
/* If they are all valid, then we're done. */ /* If they are all valid, then we're done. */
if (invalidOutputs.size() == 0) { if (invalidOutputs.size() == 0) {
amDone(ecSuccess); amDone(ecSuccess);
@ -1377,6 +1379,7 @@ void DerivationGoal::startBuilder()
tmpDir = createTempDir(); tmpDir = createTempDir();
/* Create the state directory where the component can store it's state files place */ /* 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 //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.size() != 0)
if(drv.stateOutputs.find("state")->second.getCreateDirsBeforeInstall()) if(drv.stateOutputs.find("state")->second.getCreateDirsBeforeInstall())
@ -2476,9 +2479,10 @@ void LocalStore::buildDerivations(const PathSet & drvPaths)
Worker worker; Worker worker;
Goals goals; Goals goals;
for (PathSet::const_iterator i = drvPaths.begin(); for (PathSet::const_iterator i = drvPaths.begin(); i != drvPaths.end(); ++i){
i != drvPaths.end(); ++i)
goals.insert(worker.makeDerivationGoal(*i)); goals.insert(worker.makeDerivationGoal(*i));
printMsg(lvlError, format("No component build, but state check: %1%") % *i);
}
worker.run(goals); worker.run(goals);

View file

@ -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) 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); 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); throw Error(format("synchronization '%1%' is not a correct type") % synchronization);
//TODO //TODO
@ -93,7 +93,7 @@ struct DerivationStateOutputDir
} }
DerivationStateOutputDir(string path, string type, string interval) 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); throw Error(format("interval '%1%' is not a correct type") % type);
this->path = path; this->path = path;

View file

@ -1095,6 +1095,8 @@ void verifyStore(bool checkContents)
} }
//TODO Check statecounters table....
txn.commit(); txn.commit();
} }
@ -1142,6 +1144,9 @@ vector<int> getStatePathsInterval(const PathSet & statePaths)
nixDB.queryString(txn, dbStateCounters, *i, data); nixDB.queryString(txn, dbStateCounters, *i, data);
//TODO check if every key returns a value from the db //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; int n;
if (!string2Int(data, n)) throw Error("number expected"); if (!string2Int(data, n)) throw Error("number expected");

View file

@ -31,7 +31,7 @@ bool isStorePath(const Path & path)
void assertStorePath(const Path & path) void assertStorePath(const Path & path)
{ {
if (!isStorePath(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 ...
} }

View file

@ -15,6 +15,14 @@
namespace nix { namespace nix {
void dsfsdfas()
{
}
void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const DerivationStateOutputs & stateOutputs, const StringPairs & env) void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const DerivationStateOutputs & stateOutputs, const StringPairs & env)
{ {
Path statePath = stateOutputs.find("state")->second.statepath; Path statePath = stateOutputs.find("state")->second.statepath;

View file

@ -491,8 +491,7 @@ static void installDerivations(Globals & globals,
} }
for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i) for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i)
printMsg(lvlInfo, printMsg(lvlInfo, format("installing `%1%'") % i->name);
format("installing `%1%'") % i->name);
if (globals.dryRun) { if (globals.dryRun) {
printMissing(globals.state, newElems); printMissing(globals.state, newElems);

View file

@ -26,41 +26,60 @@ 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 (!opFlags.empty()) throw UsageError("unknown flag");
if (opArgs.size() != 1) throw UsageError("only one argument allowed"); if (opArgs.size() != 1 && opArgs.size() != 2) throw UsageError("only one or two arguments allowed (the component path & the identiefier which can be empty)");
string path = *opArgs.begin();
string component = path; //TODO Parse //Parse the full path like /nix/store/...../bin/hello
Path componentPath = component; //TODO call coerce function string fullPath = opArgs.front();
return store->getStateDerivation(componentPath); 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) static void opShowStatePath(Strings opFlags, Strings opArgs)
{ {
Derivation drv = getDerivation_oneArgumentNoFlags(opFlags, opArgs); Path componentPath;
DerivationStateOutputs stateOutputs = drv.stateOutputs; Path statePath;
Path statePath = stateOutputs.find("state")->second.statepath; string stateIdentifier;
string binary;
Derivation drv = getDerivation_andCheckArgs(opFlags, opArgs, componentPath, statePath, stateIdentifier, binary);
printMsg(lvlError, format("%1%") % statePath); 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) static void opShowStateReposRootPath(Strings opFlags, Strings opArgs)
{ {
Derivation drv = getDerivation_oneArgumentNoFlags(opFlags, opArgs); Path componentPath;
DerivationStateOutputs stateOutputs = drv.stateOutputs; Path statePath;
Path statePath = stateOutputs.find("state")->second.statepath; string stateIdentifier;
string binary;
Derivation drv = getDerivation_andCheckArgs(opFlags, opArgs, componentPath, statePath, stateIdentifier, binary);
string drvName = drv.env.find("name")->second; string drvName = drv.env.find("name")->second;
string stateIdentifier = stateOutputs.find("state")->second.stateIdentifier;
//Get the a repository for this state location //Get the a repository for this state location
string repos = makeStateReposPath("stateOutput:staterepospath", statePath, "", drvName, stateIdentifier); //this is a copy from store-state.cc 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); printMsg(lvlError, format("%1%") % repos);
} }
@ -68,61 +87,37 @@ static void opShowStateReposRootPath(Strings opFlags, Strings opArgs)
static void opCommitReferencesClosure(Strings opFlags, Strings opArgs) 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 //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; DerivationStateOutputDirs stateOutputDirs = drv.stateOutputDirs;
DerivationStateOutputs stateOutputs = drv.stateOutputs; DerivationStateOutputs stateOutputs = drv.stateOutputs;
DerivationOutputs outputs = drv.outputs; DerivationOutputs outputs = drv.outputs;
string drvName = drv.env.find("name")->second; 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? //Wait for locks?
//Run the component
//******************* Run the component
//TODO
//********************* Commit state ********************* //******************* Afterwards, call the commit script (recursively)
//get dependecies (if neccecary) of all state components that need to be updated //get dependecies (if neccecary | recusively) of all state components that need to be updated
PathSet paths = store->getStateReferencesClosure(componentPath); 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(...){ //for(...){
// //
//} //}
string svnbin = nixSVNPath + "/svn"; string svnbin = nixSVNPath + "/svn";
string svnadminbin = nixSVNPath + "/svnadmin"; string svnadminbin = nixSVNPath + "/svnadmin";
Path statePath = stateOutputs.find("state")->second.statepath;
//Vector includeing all commit scripts: //Vector includeing all commit scripts:
vector<string> subversionedpaths; vector<string> subversionedpaths;
@ -137,10 +132,9 @@ static void opCommitReferencesClosure(Strings opFlags, Strings opArgs)
string thisdir = d.path; string thisdir = d.path;
string fullstatedir = statePath + "/" + thisdir; string fullstatedir = statePath + "/" + thisdir;
Path statePath = fullstatedir; //TODO call coerce function
if(d.type == "interval"){ if(d.type == "interval"){
intervalPaths.insert(statePath); intervalPaths.insert(fullstatedir);
} }
} }
vector<int> intervals = store->getStatePathsInterval(intervalPaths); vector<int> intervals = store->getStatePathsInterval(intervalPaths);
@ -166,20 +160,13 @@ static void opCommitReferencesClosure(Strings opFlags, Strings opArgs)
subversionedpaths.push_back(fullstatedir); subversionedpaths.push_back(fullstatedir);
if(d.type == "interval"){ if(d.type == "interval"){
//Get the interval-counter from the database
//TODO comment
//Get the interval-counter from the database, and update it.
//printMsg(lvlError, format("Interval: %1% - %2%") % % );
int interval_counter = intervals[intervalAt]; int interval_counter = intervals[intervalAt];
int interval = d.getInterval(); int interval = d.getInterval();
subversionedpathsCommitBoolean.push_back(interval_counter % interval == 0); subversionedpathsCommitBoolean.push_back(interval_counter % interval == 0);
//update the interval //update the interval
intervals[intervalAt] = interval_counter + 1; intervals[intervalAt] = interval_counter + 1;
intervalAt++; intervalAt++;
} }
else if(d.type == "full") else if(d.type == "full")
@ -191,7 +178,7 @@ static void opCommitReferencesClosure(Strings opFlags, Strings opArgs)
} }
//Update the intervals again //Update the intervals again
//store->setStatePathsInterval(intervalPaths, intervals); //TODO //store->setStatePathsInterval(intervalPaths, intervals);
//Call the commit script with the appropiate paramenters //Call the commit script with the appropiate paramenters
string subversionedstatepathsarray; string subversionedstatepathsarray;
@ -249,6 +236,10 @@ void run(Strings args)
--backup --backup
--exclude-commit-paths
*/ */
else else