aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-07-17 09:40:12 -0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-07-17 09:40:12 -0400
commit53b24f351852498c52377c2f011617af04bc76fa (patch)
tree39b5940695ca8157c8d8eeab875f1e439b1aa731
parenta7a43adb79393084a27589bc929e5a22877ba944 (diff)
Allow disabling log compression
-rw-r--r--doc/manual/conf-file.xml10
-rw-r--r--src/libstore/build.cc37
2 files changed, 35 insertions, 12 deletions
diff --git a/doc/manual/conf-file.xml b/doc/manual/conf-file.xml
index 7fd104eb4..1b19e56b5 100644
--- a/doc/manual/conf-file.xml
+++ b/doc/manual/conf-file.xml
@@ -297,6 +297,16 @@ build-use-chroot = /dev /proc /bin</programlisting>
</varlistentry>
+ <varlistentry><term><literal>build-compress-log</literal></term>
+
+ <listitem><para>If set to <literal>true</literal> (the default),
+ build logs written to <filename>/nix/var/log/nix/drvs</filename>
+ will be compressed on the fly using bzip2. Otherwise, they will
+ not be compressed.</para></listitem>
+
+ </varlistentry>
+
+
<varlistentry><term><literal>system</literal></term>
<listitem><para>This option specifies the canonical Nix system
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index d5bbd540b..8eb5dfa41 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -769,6 +769,7 @@ private:
/* File descriptor for the log file. */
FILE * fLogFile;
BZFILE * bzLogFile;
+ AutoCloseFD fdLogFile;
/* Pipe for the builder's standard output/error. */
Pipe builderOut;
@@ -2119,20 +2120,29 @@ Path DerivationGoal::openLogFile()
Path dir = (format("%1%/%2%") % nixLogDir % drvsLogDir).str();
createDirs(dir);
- Path logFileName = (format("%1%/%2%.bz2") % dir % baseNameOf(drvPath)).str();
- AutoCloseFD fd = open(logFileName.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0666);
- if (fd == -1)
- throw SysError(format("creating log file `%1%'") % logFileName);
- closeOnExec(fd);
+ if (queryBoolSetting("build-compress-log", true)) {
- if (!(fLogFile = fdopen(fd.borrow(), "w")))
- throw SysError(format("opening file `%1%'") % logFileName);
+ Path logFileName = (format("%1%/%2%.bz2") % dir % baseNameOf(drvPath)).str();
+ AutoCloseFD fd = open(logFileName.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0666);
+ if (fd == -1) throw SysError(format("creating log file `%1%'") % logFileName);
+ closeOnExec(fd);
+
+ if (!(fLogFile = fdopen(fd.borrow(), "w")))
+ throw SysError(format("opening file `%1%'") % logFileName);
+
+ int err;
+ if (!(bzLogFile = BZ2_bzWriteOpen(&err, fLogFile, 9, 0, 0)))
+ throw Error(format("cannot open compressed log file `%1%'") % logFileName);
- int err;
- if (!(bzLogFile = BZ2_bzWriteOpen(&err, fLogFile, 9, 0, 0)))
- throw Error(format("cannot open compressed log file `%1%'") % logFileName);
+ return logFileName;
- return logFileName;
+ } else {
+ Path logFileName = (format("%1%/%2%") % dir % baseNameOf(drvPath)).str();
+ fdLogFile = open(logFileName.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0666);
+ if (fdLogFile == -1) throw SysError(format("creating log file `%1%'") % logFileName);
+ closeOnExec(fdLogFile);
+ return logFileName;
+ }
}
@@ -2149,6 +2159,8 @@ void DerivationGoal::closeLogFile()
fclose(fLogFile);
fLogFile = 0;
}
+
+ fdLogFile.close();
}
@@ -2180,7 +2192,8 @@ void DerivationGoal::handleChildOutput(int fd, const string & data)
int err;
BZ2_bzWrite(&err, bzLogFile, (unsigned char *) data.data(), data.size());
if (err != BZ_OK) throw Error(format("cannot write to compressed log file (BZip2 error = %1%)") % err);
- }
+ } else if (fdLogFile != -1)
+ writeFull(fdLogFile, (unsigned char *) data.data(), data.size());
}
if (hook && fd == hook->fromHook.readSide)