AC_CHECK_HEADERS([zlib.h], [true],
[AC_MSG_ERROR([Guix requires zlib. See http://www.zlib.net/.])])
- dnl Look for libbz2, a required dependency.
- AC_CHECK_LIB([bz2], [BZ2_bzWriteOpen], [true],
- [AC_MSG_ERROR([Guix requires libbz2, which is part of bzip2. See http://www.bzip.org/.])])
- AC_CHECK_HEADERS([bzlib.h], [true],
- [AC_MSG_ERROR([Guix requires libbz2, which is part of bzip2. See http://www.bzip.org/.])])
+ dnl Look for libbz2, an optional dependency.
+ AC_CHECK_LIB([bz2], [BZ2_bzWriteOpen], [HAVE_LIBBZ2=yes], [HAVE_LIBBZ2=no])
+ if test "x$HAVE_LIBBZ2" = xyes; then
+ AC_CHECK_HEADERS([bzlib.h])
+ HAVE_LIBBZ2="$ac_cv_header_bzlib_h"
+ fi
dnl Look for SQLite, a required dependency.
PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.6.19])
[chmod +x nix/scripts/offload])
fi
+AM_CONDITIONAL([HAVE_LIBBZ2], [test "x$HAVE_LIBBZ2" = "xyes"])
AM_CONDITIONAL([BUILD_DAEMON], [test "x$guix_build_daemon" = "xyes"])
AM_CONDITIONAL([BUILD_DAEMON_OFFLOAD], \
[test "x$guix_build_daemon" = "xyes" \
#include <grp.h>
#include <zlib.h>
-#include <bzlib.h>
+
+#if HAVE_BZLIB_H
+# include <bzlib.h>
+#endif
/* Includes required for chroot support. */
#if HAVE_SYS_PARAM_H
/* File descriptor for the log file. */
FILE * fLogFile;
gzFile gzLogFile;
+#if HAVE_BZLIB_H
BZFILE * bzLogFile;
+#endif
AutoCloseFD fdLogFile;
/* Number of bytes received from the builder's stdout/stderr. */
, retrySubstitution(false)
, fLogFile(0)
, gzLogFile(0)
+#if HAVE_BZLIB_H
, bzLogFile(0)
+#endif
, useChroot(false)
, buildMode(buildMode)
{
return logFileName;
}
+#if HAVE_BZLIB_H
case COMPRESSION_BZIP2: {
Path logFileName = (format("%1%/%2%.bz2") % dir % string(baseName, 2)).str();
AutoCloseFD fd = open(logFileName.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0666);
return logFileName;
}
+#endif
case COMPRESSION_NONE: {
Path logFileName = (format("%1%/%2%") % dir % string(baseName, 2)).str();
gzLogFile = NULL;
if (err != Z_OK) throw Error(format("cannot close compressed log file (gzip error = %1%)") % err);
}
+#if HAVE_BZLIB_H
else if (bzLogFile) {
int err;
BZ2_bzWriteClose(&err, bzLogFile, 0, 0, 0);
bzLogFile = 0;
if (err != BZ_OK) throw Error(format("cannot close compressed log file (BZip2 error = %1%)") % err);
}
+#endif
if (fLogFile) {
fclose(fLogFile);
count = gzwrite(gzLogFile, data.data(), data.size());
if (count == 0) throw Error(format("cannot write to compressed log file (gzip error = %1%)") % gzerror(gzLogFile, &err));
}
+#if HAVE_BZLIB_H
} else if (bzLogFile) {
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);
+#endif
} else if (fdLogFile != -1)
writeFull(fdLogFile, data);
}
useSshSubstituter = false;
impersonateLinux26 = false;
keepLog = true;
+#if HAVE_BZLIB_H
logCompression = COMPRESSION_BZIP2;
+#else
+ logCompression = COMPRESSION_GZIP;
+#endif
maxLogSize = 0;
cacheFailure = false;
pollInterval = 5;
#pragma once
+#include "config.h"
#include "types.hh"
#include <map>
enum CompressionType
{
COMPRESSION_NONE = 0,
- COMPRESSION_GZIP = 1,
- COMPRESSION_BZIP2 = 2
+ COMPRESSION_GZIP = 1
+#if HAVE_BZLIB_H
+ , COMPRESSION_BZIP2 = 2
+#endif
};
struct Settings {
-I$(top_srcdir)/%D%/libstore
guix_daemon_LDADD = \
- libstore.a libutil.a libformat.a -lz -lbz2 \
+ libstore.a libutil.a libformat.a -lz \
$(SQLITE3_LIBS) $(LIBGCRYPT_LIBS)
guix_daemon_headers = \
# XXX: Should we start using shared libs?
guix_register_LDADD = \
- libstore.a libutil.a libformat.a -lz -lbz2 \
+ libstore.a libutil.a libformat.a -lz \
$(SQLITE3_LIBS) $(LIBGCRYPT_LIBS)
+if HAVE_LIBBZ2
+
+guix_daemon_LDADD += -lbz2
+guix_register_LDADD += -lbz2
+
+endif HAVE_LIBBZ2
noinst_HEADERS = \
$(libformat_headers) $(libutil_headers) $(libstore_headers) \
settings.logCompression = COMPRESSION_NONE;
else if (strcmp (arg, "gzip") == 0)
settings.logCompression = COMPRESSION_GZIP;
+#if HAVE_BZLIB_H
else if (strcmp (arg, "bzip2") == 0)
settings.logCompression = COMPRESSION_BZIP2;
+#endif
else
{
fprintf (stderr, _("error: %s: unknown compression type\n"), arg);