mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
Now using ln -snf to ensure symlinks are overwritten; Fixed --showstatepaths
This commit is contained in:
parent
7e0dcc5dcb
commit
c28742f633
7 changed files with 57 additions and 13 deletions
|
|
@ -712,6 +712,12 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||||
continue;
|
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);
|
debug(format("dead path `%1%'") % *i);
|
||||||
result.insert(*i);
|
result.insert(*i);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -718,8 +718,6 @@ bool queryAvailableStateRevisions(Database & nixDB, const Transaction & txn, Tab
|
||||||
|
|
||||||
for (Strings::const_iterator i = keys.begin(); i != keys.end(); ++i) {
|
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
|
if((*i).substr(0, statePath.length()) != statePath || (*i).length() == statePath.length()) //dont check the new-revision key or other keys
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
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;
|
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("-c");
|
||||||
p_args.push_back("ln -sf " + existingDir + " " + newLinkName);
|
p_args.push_back("ln -snf " + existingDir + " " + newLinkName);
|
||||||
runProgram_AndPrintOutput("/bin/sh", true, p_args, "sh-ln");
|
runProgram_AndPrintOutput("/bin/sh", true, p_args, "sh-ln");
|
||||||
printMsg(lvlError, format("ln -sf %1% %2%") % existingDir % newLinkName);
|
printMsg(lvlError, format("ln -sf %1% %2%") % existingDir % newLinkName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -595,7 +595,7 @@ static void installDerivations(Globals & globals,
|
||||||
{
|
{
|
||||||
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
||||||
string stateIdentifier = stateOutputs.find("state")->second.stateIdentifier;
|
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 == "")
|
if(stateIdentifier == "")
|
||||||
i->setStateIdentifier("__EMTPY__");
|
i->setStateIdentifier("__EMTPY__");
|
||||||
else
|
else
|
||||||
|
|
@ -722,7 +722,7 @@ static void installDerivations(Globals & globals,
|
||||||
PathSet comparePaths;
|
PathSet comparePaths;
|
||||||
comparePaths.insert(statePath);
|
comparePaths.insert(statePath);
|
||||||
comparePaths.insert(read_statePath);
|
comparePaths.insert(read_statePath);
|
||||||
if(store->toNonSharedPathSet(comparePaths).size() != 1) //TODO !!!!!!!!!!!!!??
|
if(store->toNonSharedPathSet(comparePaths).size() != 1)
|
||||||
rsyncPaths(externalState, statePath, true);
|
rsyncPaths(externalState, statePath, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -741,7 +741,7 @@ static void installDerivations(Globals & globals,
|
||||||
}
|
}
|
||||||
|
|
||||||
//Now we create a symlink externalState --> statePath
|
//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");
|
executeShellCommand("whoami");
|
||||||
symlinkPath(statePath, externalState);
|
symlinkPath(statePath, externalState);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,11 @@ Run Options:
|
||||||
Information:
|
Information:
|
||||||
|
|
||||||
--showstatepath: print the state path
|
--showstatepath: print the state path
|
||||||
|
--showstorepath: print the store path
|
||||||
--showderivations: print all derivations of this path
|
--showderivations: print all derivations of this path
|
||||||
--showrevisions: show all revisions of the state path
|
--showrevisions: show all revisions of the state path
|
||||||
--showsharedpaths: show where this path points to
|
--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
|
--version: output version information
|
||||||
--help: display help
|
--help: display help
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -163,6 +163,20 @@ static void opShowStatePath(Strings opFlags, Strings opArgs)
|
||||||
printMsg(lvlError, format("%1%") % statePath);
|
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)
|
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)
|
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))
|
if(!store->isValidStatePath(statePath))
|
||||||
throw UsageError(format("Path '%1%' is not a valid state path.") % statePath);
|
throw UsageError(format("Path '%1%' is not a valid state path.") % statePath);
|
||||||
|
|
||||||
|
|
@ -656,9 +676,14 @@ void run(Strings args)
|
||||||
printMsg(lvlError, format("SI: %1% %2% %3%") % si.path % si.type % si.interval);
|
printMsg(lvlError, format("SI: %1% %2% %3%") % si.path % si.type % si.interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
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 */
|
/* test */
|
||||||
|
|
||||||
if(args.size() == 1 && ( *(args.begin()) == "--help" || *(args.begin()) == "--statehelp")){
|
if(args.size() == 1 && ( *(args.begin()) == "--help" || *(args.begin()) == "--statehelp")){
|
||||||
|
|
@ -702,6 +727,8 @@ void run(Strings args)
|
||||||
//Info options
|
//Info options
|
||||||
else if (arg == "--showstatepath")
|
else if (arg == "--showstatepath")
|
||||||
op = opShowStatePath;
|
op = opShowStatePath;
|
||||||
|
else if (arg == "--showstorepath")
|
||||||
|
op = opShowStorePath;
|
||||||
else if (arg == "--showderivations")
|
else if (arg == "--showderivations")
|
||||||
op = opShowDerivations;
|
op = opShowDerivations;
|
||||||
else if (arg == "--showrevisions")
|
else if (arg == "--showrevisions")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue