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> | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |   <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> |   <varlistentry><term><literal>system</literal></term> | ||||||
| 
 | 
 | ||||||
|     <listitem><para>This option specifies the canonical Nix system |     <listitem><para>This option specifies the canonical Nix system | ||||||
|  |  | ||||||
|  | @ -769,6 +769,7 @@ private: | ||||||
|     /* File descriptor for the log file. */ |     /* File descriptor for the log file. */ | ||||||
|     FILE * fLogFile; |     FILE * fLogFile; | ||||||
|     BZFILE * bzLogFile; |     BZFILE * bzLogFile; | ||||||
|  |     AutoCloseFD fdLogFile; | ||||||
| 
 | 
 | ||||||
|     /* Pipe for the builder's standard output/error. */ |     /* Pipe for the builder's standard output/error. */ | ||||||
|     Pipe builderOut; |     Pipe builderOut; | ||||||
|  | @ -2119,10 +2120,11 @@ Path DerivationGoal::openLogFile() | ||||||
|     Path dir = (format("%1%/%2%") % nixLogDir % drvsLogDir).str(); |     Path dir = (format("%1%/%2%") % nixLogDir % drvsLogDir).str(); | ||||||
|     createDirs(dir); |     createDirs(dir); | ||||||
| 
 | 
 | ||||||
|  |     if (queryBoolSetting("build-compress-log", true)) { | ||||||
|  | 
 | ||||||
|         Path logFileName = (format("%1%/%2%.bz2") % dir % baseNameOf(drvPath)).str(); |         Path logFileName = (format("%1%/%2%.bz2") % dir % baseNameOf(drvPath)).str(); | ||||||
|         AutoCloseFD fd = open(logFileName.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0666); |         AutoCloseFD fd = open(logFileName.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0666); | ||||||
|     if (fd == -1) |         if (fd == -1) throw SysError(format("creating log file `%1%'") % logFileName); | ||||||
|         throw SysError(format("creating log file `%1%'") % logFileName); |  | ||||||
|         closeOnExec(fd); |         closeOnExec(fd); | ||||||
| 
 | 
 | ||||||
|         if (!(fLogFile = fdopen(fd.borrow(), "w"))) |         if (!(fLogFile = fdopen(fd.borrow(), "w"))) | ||||||
|  | @ -2133,6 +2135,14 @@ Path DerivationGoal::openLogFile() | ||||||
|             throw Error(format("cannot open compressed log file `%1%'") % logFileName); |             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); |         fclose(fLogFile); | ||||||
|         fLogFile = 0; |         fLogFile = 0; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     fdLogFile.close(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -2180,7 +2192,8 @@ void DerivationGoal::handleChildOutput(int fd, const string & data) | ||||||
|             int err; |             int err; | ||||||
|             BZ2_bzWrite(&err, bzLogFile, (unsigned char *) data.data(), data.size()); |             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); |             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) |     if (hook && fd == hook->fromHook.readSide) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue