From 30d19a2bdcb2f543586ac42f8d0b7dd719a9e48f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 3 Aug 2015 18:04:32 +0200 Subject: 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. --- src/libstore/build.cc | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/libstore/build.cc') diff --git a/src/libstore/build.cc b/src/libstore/build.cc index d1703f483a..1f9e4fb1e6 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1,3 +1,4 @@ +#include #include "config.h" #include "references.hh" @@ -2161,8 +2162,14 @@ void DerivationGoal::startBuilder() singleton >(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); } } -- cgit 1.4.1