mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 20:20:58 +01:00
the command /nixstate/nix/bin/nix-state --run /nix/store/sig2qgvaayydrwy5hn6b2dm5r2ayhv5s-hellohardcodedstateworld-1.0 now causes state to be checked and comitted
This commit is contained in:
parent
653e557e81
commit
25117fd165
10 changed files with 378 additions and 202 deletions
|
|
@ -67,56 +67,5 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
|
|||
store->setStatePathsInterval(intervalPaths, empty, true);
|
||||
}
|
||||
|
||||
//executes a shell command and captures and prints the output.
|
||||
void executeAndPrintShellCommand(const string & command, const string & commandName)
|
||||
{
|
||||
string tempoutput = "svnoutput.txt";
|
||||
string newcommand = command + " > " + tempoutput;
|
||||
|
||||
int kidstatus, deadpid;
|
||||
pid_t kidpid = fork();
|
||||
switch (kidpid) {
|
||||
case -1:
|
||||
throw SysError("unable to fork");
|
||||
case 0:
|
||||
try { // child
|
||||
int rv = system(newcommand.c_str());
|
||||
//int rv = execlp(svnbin.c_str(), svnbin.c_str(), ">", tempoutput.c_str(), NULL); //TODO make this work ... ?
|
||||
|
||||
string line;
|
||||
std::ifstream myfile (tempoutput.c_str());
|
||||
if (myfile.is_open()){
|
||||
while (! myfile.eof() )
|
||||
{
|
||||
getline (myfile,line);
|
||||
if(trim(line) != "")
|
||||
printMsg(lvlError, format("[%2%]: %1%") % line % commandName);
|
||||
}
|
||||
myfile.close();
|
||||
}
|
||||
else{
|
||||
throw SysError("svn state error");
|
||||
quickExit(1);
|
||||
}
|
||||
|
||||
if (rv == -1) {
|
||||
throw SysError("svn state error");
|
||||
quickExit(99);
|
||||
}
|
||||
quickExit(0);
|
||||
|
||||
} catch (std::exception & e) {
|
||||
std::cerr << format("state child error: %1%\n") % e.what();
|
||||
quickExit(1);
|
||||
}
|
||||
}
|
||||
deadpid = waitpid(kidpid, &kidstatus, 0);
|
||||
if (deadpid == -1) {
|
||||
std::cerr << format("state child waitpid error\n");
|
||||
quickExit(1);
|
||||
}
|
||||
|
||||
remove(tempoutput.c_str()); //Remove the tempoutput file
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue