mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
Allow disabling log compression
This commit is contained in:
parent
a7a43adb79
commit
53b24f3518
2 changed files with 35 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
int err;
|
||||
if (!(bzLogFile = BZ2_bzWriteOpen(&err, fLogFile, 9, 0, 0)))
|
||||
throw Error(format("cannot open compressed log file `%1%'") % logFileName);
|
||||
if (!(fLogFile = fdopen(fd.borrow(), "w")))
|
||||
throw SysError(format("opening file `%1%'") % logFileName);
|
||||
|
||||
return logFileName;
|
||||
int err;
|
||||
if (!(bzLogFile = BZ2_bzWriteOpen(&err, fLogFile, 9, 0, 0)))
|
||||
throw Error(format("cannot open compressed log file `%1%'") % 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)
|
||||
|
|
Loading…
Reference in a new issue