From fa4def3d4675c8b2d6aacb56959dbbf9e52df66a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 6 Aug 2018 11:48:35 +0200 Subject: Require libbrotli --- Makefile.config.in | 1 - configure.ac | 9 +++------ src/libutil/compression.cc | 50 ---------------------------------------------- tests/brotli.sh | 7 ------- tests/common.sh.in | 1 - 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 #include -#if HAVE_BROTLI #include #include -#endif // HAVE_BROTLI #include @@ -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 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; - 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 makeCompressionSink(const std::string & method, Sink & nextSink, const bool parallel) { @@ -544,11 +498,7 @@ ref makeCompressionSink(const std::string & method, Sink & next else if (method == "bzip2") return make_ref(nextSink); else if (method == "br") -#if HAVE_BROTLI return make_ref(nextSink); -#else - return make_ref(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@ -- cgit v1.2.3