From c28742f633671b00f3f87eb1c9d2e9f6e5df339e Mon Sep 17 00:00:00 2001 From: Wouter den Breejen Date: Fri, 26 Oct 2007 10:02:58 +0000 Subject: [PATCH] Now using ln -snf to ensure symlinks are overwritten; Fixed --showstatepaths --- src/libstore/gc.cc | 6 ++++++ src/libstore/store-state.cc | 2 -- src/libutil/util.cc | 20 ++++++++++++++++---- src/nix-env/nix-env.cc | 6 +++--- src/nix-state/help.txt | 3 ++- src/nix-state/help.txt.hh | 2 +- src/nix-state/nix-state.cc | 31 +++++++++++++++++++++++++++++-- 7 files changed, 57 insertions(+), 13 deletions(-) diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index 66472e8aa..07a78f0a7 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -712,6 +712,12 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete, continue; } + string lostAndFound = nixStoreState + "/lost+found"; + if(*i == lostAndFound){ + debug(format("Keeping `%1%' because its a special path") % lostAndFound); + continue; + } + debug(format("dead path `%1%'") % *i); result.insert(*i); diff --git a/src/libstore/store-state.cc b/src/libstore/store-state.cc index 6c52e443e..e0f09fa53 100644 --- a/src/libstore/store-state.cc +++ b/src/libstore/store-state.cc @@ -718,8 +718,6 @@ bool queryAvailableStateRevisions(Database & nixDB, const Transaction & txn, Tab for (Strings::const_iterator i = keys.begin(); i != keys.end(); ++i) { - printMsg(lvlError, format("QQQQ %1%") % *i); - if((*i).substr(0, statePath.length()) != statePath || (*i).length() == statePath.length()) //dont check the new-revision key or other keys continue; diff --git a/src/libutil/util.cc b/src/libutil/util.cc index f8b29ad9b..7f4bc8726 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1312,11 +1312,23 @@ string padd(const string & s, char c , unsigned int size, bool front) void symlinkPath(const Path & existingDir, const Path & newLinkName) //TODO bool shellexpansion { - //Symlink link to the share path - //Usage: ln [OPTION]... [-T] TARGET LINK_NAME (1st form) + /* + * Symlink link to the share path + * Usage: ln [OPTION]... [-T] TARGET LINK_NAME (1st form) + * + * we call the shell (/bin/sh -c) so it expands the ~ to a users home dir + * + * We do -snf for: + * -s : symlinking + * -f : To remove existing destination files (this does NOT always overwrite the newLinkName !!!!) + * -n : Treat destination that is a symlink to a directory as if it were a normal file (This makes sure + * that newLinkName is really overwritten) + */ + + Strings p_args; - p_args.push_back("-c"); //we call the shell (/bin/sh -c) so it expands the ~ to a users home dir - p_args.push_back("ln -sf " + existingDir + " " + newLinkName); + p_args.push_back("-c"); + p_args.push_back("ln -snf " + existingDir + " " + newLinkName); runProgram_AndPrintOutput("/bin/sh", true, p_args, "sh-ln"); printMsg(lvlError, format("ln -sf %1% %2%") % existingDir % newLinkName); } diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index b2b627cc6..a80856fb1 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -595,7 +595,7 @@ static void installDerivations(Globals & globals, { DerivationStateOutputs stateOutputs = drv.stateOutputs; string stateIdentifier = stateOutputs.find("state")->second.stateIdentifier; - printMsg(lvlError, format("Add '%2%' with '%1%'") % stateIdentifier % i->queryOutPath(globals.state)); + printMsg(lvlError, format("Add state component '%2%' with identifier '%1%'") % stateIdentifier % i->queryOutPath(globals.state)); if(stateIdentifier == "") i->setStateIdentifier("__EMTPY__"); else @@ -722,7 +722,7 @@ static void installDerivations(Globals & globals, PathSet comparePaths; comparePaths.insert(statePath); comparePaths.insert(read_statePath); - if(store->toNonSharedPathSet(comparePaths).size() != 1) //TODO !!!!!!!!!!!!!?? + if(store->toNonSharedPathSet(comparePaths).size() != 1) rsyncPaths(externalState, statePath, true); } else @@ -741,7 +741,7 @@ static void installDerivations(Globals & globals, } //Now we create a symlink externalState --> statePath - printMsg(lvlError, format("SYMLINK: '%1%' --> '%2%'") % externalState % statePath); + printMsg(lvlError, format("SYMLINK: '%1%' --> '%2%'") % externalState % statePath); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DOESNT WORK OK >..... executeShellCommand("whoami"); symlinkPath(statePath, externalState); } diff --git a/src/nix-state/help.txt b/src/nix-state/help.txt index 690b7d0ec..40446b3e6 100644 --- a/src/nix-state/help.txt +++ b/src/nix-state/help.txt @@ -17,10 +17,11 @@ Run Options: Information: --showstatepath: print the state path + --showstorepath: print the store path --showderivations: print all derivations of this path --showrevisions: show all revisions of the state path --showsharedpaths: show where this path points to - --XXXXXXXXXXXXXXXX: print if the path is a state/store path + --TODO: print if the path is a state/store path --version: output version information --help: display help diff --git a/src/nix-state/help.txt.hh b/src/nix-state/help.txt.hh index 4a079a68e..bb5070ebf 100644 --- a/src/nix-state/help.txt.hh +++ b/src/nix-state/help.txt.hh @@ -1 +1 @@ -static unsigned char helpText[] = {0x55, 0x73, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x6e, 0x69, 0x78, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x5b, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x2e, 0x2e, 0x2e, 0x5d, 0x20, 0x5b, 0x41, 0x52, 0x47, 0x55, 0x4d, 0x45, 0x4e, 0x54, 0x53, 0x2e, 0x2e, 0x2e, 0x5d, 0x20, 0x5b, 0x4e, 0x49, 0x58, 0x20, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2d, 0x50, 0x61, 0x74, 0x68, 0x5d, 0x0a, 0x0a, 0x60, 0x6e, 0x69, 0x78, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x27, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x20, 0x74, 0x6f, 0x20, 0x6d, 0x61, 0x6e, 0x69, 0x70, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x4e, 0x69, 0x78, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2d, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x0a, 0x0a, 0x52, 0x75, 0x6e, 0x20, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x75, 0x6e, 0x20, 0x2f, 0x20, 0x2d, 0x72, 0x3a, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2d, 0x6f, 0x6e, 0x6c, 0x79, 0x3a, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x75, 0x6e, 0x2d, 0x6f, 0x6e, 0x6c, 0x79, 0x3a, 0x20, 0x72, 0x75, 0x6e, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x63, 0x61, 0x6e, 0x2d, 0x6f, 0x6e, 0x6c, 0x79, 0x3a, 0x20, 0x73, 0x63, 0x61, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x0a, 0x0a, 0x52, 0x75, 0x6e, 0x20, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x09, 0x09, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x63, 0x61, 0x6e, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x3a, 0x20, 0x73, 0x65, 0x74, 0x20, 0x73, 0x63, 0x61, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x3d, 0x2e, 0x2e, 0x2e, 0x3a, 0x20, 0x41, 0x64, 0x64, 0x20, 0x61, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x20, 0x0a, 0x0a, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x61, 0x74, 0x68, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x64, 0x65, 0x72, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x64, 0x65, 0x72, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x20, 0x73, 0x68, 0x6f, 0x77, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x70, 0x61, 0x74, 0x68, 0x73, 0x3a, 0x20, 0x73, 0x68, 0x6f, 0x77, 0x20, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x20, 0x74, 0x6f, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x69, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x68, 0x65, 0x6c, 0x70, 0x3a, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x68, 0x65, 0x6c, 0x70, 0x0a, 0x0a, 0x28, 0x55, 0x6e, 0x29, 0x53, 0x68, 0x61, 0x72, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x75, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x3a, 0x20, 0x75, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2d, 0x77, 0x69, 0x74, 0x68, 0x3d, 0x61, 0x20, 0x62, 0x3a, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x61, 0x74, 0x68, 0x20, 0x62, 0x20, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x73, 0x79, 0x6e, 0x63, 0x2d, 0x66, 0x72, 0x6f, 0x6d, 0x3d, 0x61, 0x20, 0x62, 0x3a, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x61, 0x74, 0x68, 0x20, 0x62, 0x20, 0x65, 0x71, 0x75, 0x61, 0x6c, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x0a, 0x0a, 0x55, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x75, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2d, 0x61, 0x6e, 0x64, 0x2d, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x20, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x75, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2d, 0x61, 0x6e, 0x64, 0x2d, 0x72, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2d, 0x6f, 0x6c, 0x64, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x20, 0x28, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x29, 0x0a, 0x20, 0x0a, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x2d, 0x74, 0x6f, 0x2d, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x78, 0x3a, 0x20, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x78, 0x0a, 0x0a, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x2d, 0x74, 0x6f, 0x2d, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x72, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x6c, 0x79, 0x3a, 0x20, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x20, 0x72, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x6c, 0x79, 0x0a, }; +static unsigned char helpText[] = {0x55, 0x73, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x6e, 0x69, 0x78, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x5b, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x2e, 0x2e, 0x2e, 0x5d, 0x20, 0x5b, 0x41, 0x52, 0x47, 0x55, 0x4d, 0x45, 0x4e, 0x54, 0x53, 0x2e, 0x2e, 0x2e, 0x5d, 0x20, 0x5b, 0x4e, 0x49, 0x58, 0x20, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2d, 0x50, 0x61, 0x74, 0x68, 0x5d, 0x0a, 0x0a, 0x60, 0x6e, 0x69, 0x78, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x27, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x20, 0x74, 0x6f, 0x20, 0x6d, 0x61, 0x6e, 0x69, 0x70, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x4e, 0x69, 0x78, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2d, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x0a, 0x0a, 0x52, 0x75, 0x6e, 0x20, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x75, 0x6e, 0x20, 0x2f, 0x20, 0x2d, 0x72, 0x3a, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2d, 0x6f, 0x6e, 0x6c, 0x79, 0x3a, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x75, 0x6e, 0x2d, 0x6f, 0x6e, 0x6c, 0x79, 0x3a, 0x20, 0x72, 0x75, 0x6e, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x63, 0x61, 0x6e, 0x2d, 0x6f, 0x6e, 0x6c, 0x79, 0x3a, 0x20, 0x73, 0x63, 0x61, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x0a, 0x0a, 0x52, 0x75, 0x6e, 0x20, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x09, 0x09, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x63, 0x61, 0x6e, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x3a, 0x20, 0x73, 0x65, 0x74, 0x20, 0x73, 0x63, 0x61, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x3d, 0x2e, 0x2e, 0x2e, 0x3a, 0x20, 0x41, 0x64, 0x64, 0x20, 0x61, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x20, 0x0a, 0x0a, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x61, 0x74, 0x68, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x70, 0x61, 0x74, 0x68, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x64, 0x65, 0x72, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x64, 0x65, 0x72, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x20, 0x73, 0x68, 0x6f, 0x77, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x70, 0x61, 0x74, 0x68, 0x73, 0x3a, 0x20, 0x73, 0x68, 0x6f, 0x77, 0x20, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x20, 0x74, 0x6f, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x54, 0x4f, 0x44, 0x4f, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x69, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x68, 0x65, 0x6c, 0x70, 0x3a, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x68, 0x65, 0x6c, 0x70, 0x0a, 0x0a, 0x28, 0x55, 0x6e, 0x29, 0x53, 0x68, 0x61, 0x72, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x75, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x3a, 0x20, 0x75, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2d, 0x77, 0x69, 0x74, 0x68, 0x3d, 0x61, 0x20, 0x62, 0x3a, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x61, 0x74, 0x68, 0x20, 0x62, 0x20, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x73, 0x79, 0x6e, 0x63, 0x2d, 0x66, 0x72, 0x6f, 0x6d, 0x3d, 0x61, 0x20, 0x62, 0x3a, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x61, 0x74, 0x68, 0x20, 0x62, 0x20, 0x65, 0x71, 0x75, 0x61, 0x6c, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x0a, 0x0a, 0x55, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x75, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2d, 0x61, 0x6e, 0x64, 0x2d, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x20, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x75, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2d, 0x61, 0x6e, 0x64, 0x2d, 0x72, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2d, 0x6f, 0x6c, 0x64, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x20, 0x28, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x29, 0x0a, 0x20, 0x0a, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x2d, 0x74, 0x6f, 0x2d, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x78, 0x3a, 0x20, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x78, 0x0a, 0x0a, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x2d, 0x74, 0x6f, 0x2d, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x72, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x6c, 0x79, 0x3a, 0x20, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x20, 0x72, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x6c, 0x79, 0x0a, }; diff --git a/src/nix-state/nix-state.cc b/src/nix-state/nix-state.cc index 476c59d4a..9bc623752 100644 --- a/src/nix-state/nix-state.cc +++ b/src/nix-state/nix-state.cc @@ -163,6 +163,20 @@ static void opShowStatePath(Strings opFlags, Strings opArgs) printMsg(lvlError, format("%1%") % statePath); } +//Prints the storepath of a component +static void opShowStorePath(Strings opFlags, Strings opArgs) +{ + Path componentPath; + Path statePath; + string binary; + string derivationPath; + bool isStateComponent; + Strings program_args; + getPathInfo_andCheckArgs(opFlags, opArgs, componentPath, statePath, binary, derivationPath, isStateComponent, program_args); + + printMsg(lvlError, format("%1%") % componentPath); +} + static void revertToRevision(Strings opFlags, Strings opArgs) { @@ -252,7 +266,13 @@ static void opIsStateStorePath(Strings opFlags, Strings opArgs) //Used by ..... static void opShowSharedPaths(Strings opFlags, Strings opArgs) { - Path statePath = *(opArgs.begin()); + //Path statePath = *(opArgs.begin()); + Path componentPath, statePath; + string binary, derivationPath; + bool isStateComponent; + Strings program_args; + getPathInfo_andCheckArgs(opFlags, opArgs, componentPath, statePath, binary, derivationPath, isStateComponent, program_args); + if(!store->isValidStatePath(statePath)) throw UsageError(format("Path '%1%' is not a valid state path.") % statePath); @@ -655,10 +675,15 @@ void run(Strings args) StateInfo si = *i; printMsg(lvlError, format("SI: %1% %2% %3%") % si.path % si.type % si.interval); } + + printMsg(lvlError, format("DIREXTIST '%1%'") % DirectoryExist("/nix/state/test/test") ); //file 0 + printMsg(lvlError, format("DIREXTIST '%1%'") % DirectoryExist("/nix/state/test/test2") ); //symlink 0 + printMsg(lvlError, format("DIREXTIST '%1%'") % DirectoryExist("/nix/state/test/d1") ); //dir 1 + printMsg(lvlError, format("DIREXTIST '%1%'") % DirectoryExist("/nix/state/test/d2") ); //symlink 1 return; - */ + /* test */ if(args.size() == 1 && ( *(args.begin()) == "--help" || *(args.begin()) == "--statehelp")){ @@ -702,6 +727,8 @@ void run(Strings args) //Info options else if (arg == "--showstatepath") op = opShowStatePath; + else if (arg == "--showstorepath") + op = opShowStorePath; else if (arg == "--showderivations") op = opShowDerivations; else if (arg == "--showrevisions")