diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-08-03T16·04+0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-08-03T16·04+0200 |
commit | 30d19a2bdcb2f543586ac42f8d0b7dd719a9e48f (patch) | |
tree | 9eae83cb2e923f7c2d1df41a065a5c40cee22f9d | |
parent | 3db950aab734b63d70fa0f151233c062ae6168eb (diff) |
Handle debug messages from runChild()
Turns out that "nix-build -vvv" with chroots enabled has been broken for some time, because some debug message got interpreted as an error.
-rw-r--r-- | src/libstore/build.cc | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc index d1703f483a89..1f9e4fb1e6be 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1,3 +1,4 @@ +#include <iostream> #include "config.h" #include "references.hh" @@ -2161,8 +2162,14 @@ void DerivationGoal::startBuilder() 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); + while (true) { + string msg = readLine(builderOut.readSide); + if (string(msg, 0, 1) == "\1") { + if (msg.size() == 1) break; + throw Error(string(msg, 1)); + } + printMsg(lvlDebug, msg); + } if (settings.printBuildTrace) { printMsg(lvlError, format("@ build-started %1% - %2% %3%") @@ -2178,6 +2185,8 @@ void DerivationGoal::runChild() try { /* child */ + logType = ltFlat; + commonChildInit(builderOut); #if CHROOT_ENABLED @@ -2502,6 +2511,9 @@ void DerivationGoal::runChild() } sandboxProfile += ")\n"; + debug("Generated sandbox profile:"); + debug(sandboxProfile); + builder = "/usr/bin/sandbox-exec"; args.push_back("sandbox-exec"); args.push_back("-p"); @@ -2519,13 +2531,7 @@ void DerivationGoal::runChild() restoreSIGPIPE(); /* Indicate that we managed to set up the build environment. */ - writeFull(STDERR_FILENO, "\n"); - - /* This needs to be after that fateful '\n', and I didn't want to duplicate code */ - if (useChroot && SANDBOX_ENABLED) { - printMsg(lvlDebug, "Generated sandbox profile:"); - printMsg(lvlDebug, sandboxProfile); - } + writeFull(STDERR_FILENO, string("\1\n")); /* Execute the program. This should not return. */ if (isBuiltin(*drv)) { @@ -2547,7 +2553,7 @@ void DerivationGoal::runChild() throw SysError(format("executing ‘%1%’") % drv->builder); } catch (std::exception & e) { - writeFull(STDERR_FILENO, "while setting up the build environment: " + string(e.what()) + "\n"); + writeFull(STDERR_FILENO, "\1while setting up the build environment: " + string(e.what()) + "\n"); _exit(1); } } |