diff --git a/scripts/nix-statecommit.sh.in b/scripts/nix-statecommit.sh.in index 449c21683..e9590e0b6 100755 --- a/scripts/nix-statecommit.sh.in +++ b/scripts/nix-statecommit.sh.in @@ -31,7 +31,7 @@ function subversionSingleStateDir { excludelist=( "." ".." ".svn" ); cd $1; - echo cd $1; + #echo cd $1; empty=$(ls) diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 71183d182..fe3e7be31 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -473,9 +473,6 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args) if(s[0] == '/' && s.length() != 1) s = s.substr(1, s.length()); - if(s == stateRootRepos) - throw EvalError(format("The statedir `%1%' is a keyword and cannot be used, choose another name") % stateRootRepos); - dir.path = s; } else if (statekey == "type") { dir.type = s; } diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index 20deae73e..2e65df36d 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -19,7 +19,6 @@ string nixSVNPath = "/UNINIT"; string nixConfDir = "/UNINIT"; string nixLibexecDir = "/UNINIT"; string nixBinDir = "/UNINIT"; -string stateRootRepos = "root_repos/"; bool keepFailed = false; bool keepGoing = false; diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index 16ee5eb35..75cfe83ce 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -75,9 +75,6 @@ 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); diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 0741f4a8c..50a586dd0 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -31,14 +31,14 @@ 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); //TODO bug: this prints an empty path ... + throw Error(format("path `%1%' is not in the Nix store (1)") % path); //TODO bug: this prints an empty path ... } Path toStorePath(const Path & path) { if (!isInStore(path)) - throw Error(format("path `%1%' is not in the Nix store") % path); + throw Error(format("path `%1%' is not in the Nix store (2)") % path); Path::size_type slash = path.find('/', nixStore.size() + 1); if (slash == Path::npos) return path; @@ -102,10 +102,12 @@ Path makeStateReposPath(const string & type, const Path statePath, const string //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; + //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 subfolder_ = printHash32(compressHash(hashString(htSHA256, hash_subfolder), 20)) + "-" + subfolder; string suffix_stateIdentifier = stateIdentifier; if(suffix_stateIdentifier != "") diff --git a/src/libstore/store-state.cc b/src/libstore/store-state.cc index 28248fba9..961da852b 100644 --- a/src/libstore/store-state.cc +++ b/src/libstore/store-state.cc @@ -22,6 +22,15 @@ void updatedStateDerivation(Path storePath) //Create new repositorys, or use existing... //createStateDirs already does that ... + + printMsg(lvlError, format("Resetting state drv settings like repositorys")); + + //Create a repository for this state location + //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 ?? + + } diff --git a/src/nix-state/nix-state.cc b/src/nix-state/nix-state.cc index 9375441f6..adceded2c 100644 --- a/src/nix-state/nix-state.cc +++ b/src/nix-state/nix-state.cc @@ -39,16 +39,19 @@ Derivation getDerivation_andCheckArgs(Strings opFlags, Strings opArgs, Path & co componentPath = fullPath.substr(0, pos + nixStore.size() + 1); binary = fullPath.substr(pos + nixStore.size() + 1, fullPath.size()); - //TODO CHECK for validity of componentPath ... ? - + //TODO REAL CHECK for validity of componentPath ... ? + //printMsg(lvlError, format("%1% - %2% - %3% - %4%") % componentPath % statePath % stateIdentifier % binary); + if(componentPath == "/nix/store") + throw UsageError("You must specify the full! binary path"); + 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); + //TODO check if this identifier exists !!!!!!!!!!! + Derivation drv = store->getStateDerivation(componentPath); DerivationStateOutputs stateOutputs = drv.stateOutputs; @@ -78,8 +81,10 @@ static void opShowStateReposRootPath(Strings opFlags, Strings opArgs) string drvName = drv.env.find("name")->second; //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() + 1) ); + string repos = makeStateReposPath("stateOutput:staterepospath", statePath, "/", drvName, stateIdentifier); //this is a copy from store-state.cc + + //TODO Strip off + //repos = repos.substr(0, repos.length() - .... ); printMsg(lvlError, format("%1%") % repos); } @@ -93,7 +98,7 @@ static void opRunComponent(Strings opFlags, Strings opArgs) Path statePath; string stateIdentifier; string binary; - + Derivation drv = getDerivation_andCheckArgs(opFlags, opArgs, componentPath, statePath, stateIdentifier, binary); DerivationStateOutputDirs stateOutputDirs = drv.stateOutputDirs; DerivationStateOutputs stateOutputs = drv.stateOutputs;