Remove ugly hack for detecting build environment setup errors

This commit is contained in:
Eelco Dolstra 2014-08-01 19:38:21 +02:00
parent 4c4b219c07
commit 51485dcda2

View file

@ -759,11 +759,6 @@ private:
outputs to allow hard links between outputs. */ outputs to allow hard links between outputs. */
InodesSeen inodesSeen; InodesSeen inodesSeen;
/* Magic exit code denoting that setting up the child environment
failed. (It's possible that the child actually returns the
exit code, but ah well.) */
const static int childSetupFailed = 189;
public: public:
DerivationGoal(const Path & drvPath, const StringSet & wantedOutputs, Worker & worker, BuildMode buildMode = bmNormal); DerivationGoal(const Path & drvPath, const StringSet & wantedOutputs, Worker & worker, BuildMode buildMode = bmNormal);
~DerivationGoal(); ~DerivationGoal();
@ -1408,9 +1403,6 @@ void DerivationGoal::buildDone()
if (pathExists(chrootRootDir + *i)) if (pathExists(chrootRootDir + *i))
rename((chrootRootDir + *i).c_str(), i->c_str()); rename((chrootRootDir + *i).c_str(), i->c_str());
if (WIFEXITED(status) && WEXITSTATUS(status) == childSetupFailed)
throw Error(format("failed to set up the build environment for `%1%'") % drvPath);
if (diskFull) if (diskFull)
printMsg(lvlError, "note: build failure may have been caused by lack of free disk space"); printMsg(lvlError, "note: build failure may have been caused by lack of free disk space");
@ -1944,10 +1936,15 @@ void DerivationGoal::startBuilder()
worker.childStarted(shared_from_this(), pid, worker.childStarted(shared_from_this(), pid,
singleton<set<int> >(builderOut.readSide), true, true); singleton<set<int> >(builderOut.readSide), true, true);
/* Check if setting up the build environment failed. */
string msg = readLine(builderOut.readSide);
if (!msg.empty()) throw Error(msg);
if (settings.printBuildTrace) { if (settings.printBuildTrace) {
printMsg(lvlError, format("@ build-started %1% - %2% %3%") printMsg(lvlError, format("@ build-started %1% - %2% %3%")
% drvPath % drv.platform % logFile); % drvPath % drv.platform % logFile);
} }
} }
@ -1956,8 +1953,6 @@ void DerivationGoal::initChild()
/* Warning: in the child we should absolutely not make any SQLite /* Warning: in the child we should absolutely not make any SQLite
calls! */ calls! */
bool inSetup = true;
try { /* child */ try { /* child */
_writeToStderr = 0; _writeToStderr = 0;
@ -2152,15 +2147,17 @@ void DerivationGoal::initChild()
restoreSIGPIPE(); restoreSIGPIPE();
/* Indicate that we managed to set up the build environment. */
writeToStderr("\n");
/* Execute the program. This should not return. */ /* Execute the program. This should not return. */
inSetup = false;
execve(program.c_str(), (char * *) &args[0], (char * *) envArr); execve(program.c_str(), (char * *) &args[0], (char * *) envArr);
throw SysError(format("executing `%1%'") % drv.builder); throw SysError(format("executing `%1%'") % drv.builder);
} catch (std::exception & e) { } catch (std::exception & e) {
writeToStderr("build error: " + string(e.what()) + "\n"); writeToStderr("while setting up the build environment: " + string(e.what()) + "\n");
_exit(inSetup ? childSetupFailed : 1); _exit(1);
} }
abort(); /* never reached */ abort(); /* never reached */