aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-08-06 11:48:35 +0200
committerEelco Dolstra <edolstra@gmail.com>2018-08-06 14:06:54 +0200
commitfa4def3d4675c8b2d6aacb56959dbbf9e52df66a (patch)
tree1b459dacb68651abb3913684fd3f795c7f66cf16
parent4361a4331f1b2eb3fcfd954c96de353c9d516508 (diff)
Require libbrotli
-rw-r--r--Makefile.config.in1
-rw-r--r--configure.ac9
-rw-r--r--src/libutil/compression.cc50
-rw-r--r--tests/brotli.sh7
-rw-r--r--tests/common.sh.in1
5 files changed, 3 insertions, 65 deletions
diff --git a/Makefile.config.in b/Makefile.config.in
index a9785dc73..08edcb863 100644
--- a/Makefile.config.in
+++ b/Makefile.config.in
@@ -6,7 +6,6 @@ CXXFLAGS = @CXXFLAGS@
ENABLE_S3 = @ENABLE_S3@
HAVE_SODIUM = @HAVE_SODIUM@
HAVE_READLINE = @HAVE_READLINE@
-HAVE_BROTLI = @HAVE_BROTLI@
HAVE_SECCOMP = @HAVE_SECCOMP@
LIBCURL_LIBS = @LIBCURL_LIBS@
OPENSSL_LIBS = @OPENSSL_LIBS@
diff --git a/configure.ac b/configure.ac
index c41a83c97..6aeeacdba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -179,12 +179,9 @@ AC_CHECK_LIB([lzma], [lzma_stream_encoder_mt],
[AC_DEFINE([HAVE_LZMA_MT], [1], [xz multithreaded compression support])])
-# Look for libbrotli{enc,dec}, optional dependencies
-PKG_CHECK_MODULES([LIBBROTLI], [libbrotlienc libbrotlidec],
- [AC_DEFINE([HAVE_BROTLI], [1], [Whether to use libbrotli.])
- CXXFLAGS="$LIBBROTLI_CFLAGS $CXXFLAGS"]
- have_brotli=1], [have_brotli=])
-AC_SUBST(HAVE_BROTLI, [$have_brotli])
+# Look for libbrotli{enc,dec}.
+PKG_CHECK_MODULES([LIBBROTLI], [libbrotlienc libbrotlidec], [CXXFLAGS="$LIBBROTLI_CFLAGS $CXXFLAGS"])
+
# Look for libseccomp, required for Linux sandboxing.
if test "$sys_name" = linux; then
diff --git a/src/libutil/compression.cc b/src/libutil/compression.cc
index e1782f8c4..5de85ede1 100644
--- a/src/libutil/compression.cc
+++ b/src/libutil/compression.cc
@@ -8,10 +8,8 @@
#include <cstdio>
#include <cstring>
-#if HAVE_BROTLI
#include <brotli/decode.h>
#include <brotli/encode.h>
-#endif // HAVE_BROTLI
#include <iostream>
@@ -132,12 +130,6 @@ static void decompressBzip2(Source & source, Sink & sink)
static void decompressBrotli(Source & source, Sink & sink)
{
-#if !HAVE_BROTLI
- RunOptions options(BROTLI, {"-d"});
- options.standardIn = &source;
- options.standardOut = &sink;
- runProgram2(options);
-#else
auto *s = BrotliDecoderCreateInstance(nullptr, nullptr, nullptr);
if (!s)
throw CompressionError("unable to initialize brotli decoder");
@@ -193,7 +185,6 @@ static void decompressBrotli(Source & source, Sink & sink)
if (ret == BROTLI_DECODER_RESULT_SUCCESS) return;
}
-#endif // HAVE_BROTLI
}
ref<std::string> decompress(const std::string & method, const std::string & in)
@@ -403,42 +394,6 @@ struct BzipSink : CompressionSink
}
};
-struct LambdaCompressionSink : CompressionSink
-{
- Sink & nextSink;
- std::string data;
- using CompressFnTy = std::function<std::string(const std::string&)>;
- CompressFnTy compressFn;
- LambdaCompressionSink(Sink& nextSink, CompressFnTy compressFn)
- : nextSink(nextSink)
- , compressFn(std::move(compressFn))
- {
- };
-
- void finish() override
- {
- flush();
- nextSink(compressFn(data));
- }
-
- void write(const unsigned char * data, size_t len) override
- {
- checkInterrupt();
- this->data.append((const char *) data, len);
- }
-};
-
-struct BrotliCmdSink : LambdaCompressionSink
-{
- BrotliCmdSink(Sink& nextSink)
- : LambdaCompressionSink(nextSink, [](const std::string& data) {
- return runProgram(BROTLI, true, {}, data);
- })
- {
- }
-};
-
-#if HAVE_BROTLI
struct BrotliSink : CompressionSink
{
Sink & nextSink;
@@ -525,7 +480,6 @@ struct BrotliSink : CompressionSink
}
}
};
-#endif // HAVE_BROTLI
ref<CompressionSink> makeCompressionSink(const std::string & method, Sink & nextSink, const bool parallel)
{
@@ -544,11 +498,7 @@ ref<CompressionSink> makeCompressionSink(const std::string & method, Sink & next
else if (method == "bzip2")
return make_ref<BzipSink>(nextSink);
else if (method == "br")
-#if HAVE_BROTLI
return make_ref<BrotliSink>(nextSink);
-#else
- return make_ref<BrotliCmdSink>(nextSink);
-#endif
else
throw UnknownCompressionMethod(format("unknown compression method '%s'") % method);
}
diff --git a/tests/brotli.sh b/tests/brotli.sh
index 645dd4214..a3c6e55a8 100644
--- a/tests/brotli.sh
+++ b/tests/brotli.sh
@@ -1,10 +1,5 @@
source common.sh
-
-# Only test if we found brotli libraries
-# (CLI tool is likely unavailable if libraries are missing)
-if [ -n "$HAVE_BROTLI" ]; then
-
clearStore
clearCache
@@ -24,5 +19,3 @@ nix copy --from $cacheURI $outPath --no-check-sigs
HASH2=$(nix hash-path $outPath)
[[ $HASH = $HASH2 ]]
-
-fi # HAVE_BROTLI
diff --git a/tests/common.sh.in b/tests/common.sh.in
index fddd25b36..2ee2f589d 100644
--- a/tests/common.sh.in
+++ b/tests/common.sh.in
@@ -31,7 +31,6 @@ export xmllint="@xmllint@"
export SHELL="@bash@"
export PAGER=cat
export HAVE_SODIUM="@HAVE_SODIUM@"
-export HAVE_BROTLI="@HAVE_BROTLI@"
export version=@PACKAGE_VERSION@
export system=@system@