aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-01-17 15:37:52 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-01-17 15:47:26 +0100
commit536c85ea49c16a2ecd5a1ba169975b296cd6158c (patch)
treea364afe890c857d5b5e728fdb4aa7d7507186357 /src/libstore
parent66fa9e6a4d7cf4c0a32d33adfc464f84c492f6d1 (diff)
Store build logs in /nix/var/log/nix/drvs/<XX>
...where <XX> is the first two characters of the derivation. Otherwise /nix/var/log/nix/drvs may become so large that we run into all sorts of weird filesystem limits/inefficiences. For instance, ext3/ext4 filesystems will barf with "ext4_dx_add_entry:1551: Directory index full!" once you hit a few million files.
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 75802c324..d9a7f3109 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2343,13 +2343,15 @@ Path DerivationGoal::openLogFile()
{
if (!settings.keepLog) return "";
+ string baseName = baseNameOf(drvPath);
+
/* Create a log file. */
- Path dir = (format("%1%/%2%") % settings.nixLogDir % drvsLogDir).str();
+ Path dir = (format("%1%/%2%/%3%/") % settings.nixLogDir % drvsLogDir % string(baseName, 0, 2)).str();
createDirs(dir);
if (settings.compressLog) {
- Path logFileName = (format("%1%/%2%.bz2") % dir % baseNameOf(drvPath)).str();
+ Path logFileName = (format("%1%/%2%.bz2") % dir % string(baseName, 2)).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);
@@ -2364,7 +2366,7 @@ Path DerivationGoal::openLogFile()
return logFileName;
} else {
- Path logFileName = (format("%1%/%2%") % dir % baseNameOf(drvPath)).str();
+ Path logFileName = (format("%1%/%2%") % dir % string(baseName, 2)).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);