forked from lix-project/lix
Require libbrotli
This commit is contained in:
parent
4361a4331f
commit
fa4def3d46
5 changed files with 3 additions and 65 deletions
|
@ -6,7 +6,6 @@ CXXFLAGS = @CXXFLAGS@
|
||||||
ENABLE_S3 = @ENABLE_S3@
|
ENABLE_S3 = @ENABLE_S3@
|
||||||
HAVE_SODIUM = @HAVE_SODIUM@
|
HAVE_SODIUM = @HAVE_SODIUM@
|
||||||
HAVE_READLINE = @HAVE_READLINE@
|
HAVE_READLINE = @HAVE_READLINE@
|
||||||
HAVE_BROTLI = @HAVE_BROTLI@
|
|
||||||
HAVE_SECCOMP = @HAVE_SECCOMP@
|
HAVE_SECCOMP = @HAVE_SECCOMP@
|
||||||
LIBCURL_LIBS = @LIBCURL_LIBS@
|
LIBCURL_LIBS = @LIBCURL_LIBS@
|
||||||
OPENSSL_LIBS = @OPENSSL_LIBS@
|
OPENSSL_LIBS = @OPENSSL_LIBS@
|
||||||
|
|
|
@ -179,12 +179,9 @@ AC_CHECK_LIB([lzma], [lzma_stream_encoder_mt],
|
||||||
[AC_DEFINE([HAVE_LZMA_MT], [1], [xz multithreaded compression support])])
|
[AC_DEFINE([HAVE_LZMA_MT], [1], [xz multithreaded compression support])])
|
||||||
|
|
||||||
|
|
||||||
# Look for libbrotli{enc,dec}, optional dependencies
|
# Look for libbrotli{enc,dec}.
|
||||||
PKG_CHECK_MODULES([LIBBROTLI], [libbrotlienc libbrotlidec],
|
PKG_CHECK_MODULES([LIBBROTLI], [libbrotlienc libbrotlidec], [CXXFLAGS="$LIBBROTLI_CFLAGS $CXXFLAGS"])
|
||||||
[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 libseccomp, required for Linux sandboxing.
|
# Look for libseccomp, required for Linux sandboxing.
|
||||||
if test "$sys_name" = linux; then
|
if test "$sys_name" = linux; then
|
||||||
|
|
|
@ -8,10 +8,8 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#if HAVE_BROTLI
|
|
||||||
#include <brotli/decode.h>
|
#include <brotli/decode.h>
|
||||||
#include <brotli/encode.h>
|
#include <brotli/encode.h>
|
||||||
#endif // HAVE_BROTLI
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -132,12 +130,6 @@ static void decompressBzip2(Source & source, Sink & sink)
|
||||||
|
|
||||||
static void decompressBrotli(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);
|
auto *s = BrotliDecoderCreateInstance(nullptr, nullptr, nullptr);
|
||||||
if (!s)
|
if (!s)
|
||||||
throw CompressionError("unable to initialize brotli decoder");
|
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;
|
if (ret == BROTLI_DECODER_RESULT_SUCCESS) return;
|
||||||
}
|
}
|
||||||
#endif // HAVE_BROTLI
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<std::string> decompress(const std::string & method, const std::string & in)
|
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
|
struct BrotliSink : CompressionSink
|
||||||
{
|
{
|
||||||
Sink & nextSink;
|
Sink & nextSink;
|
||||||
|
@ -525,7 +480,6 @@ struct BrotliSink : CompressionSink
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif // HAVE_BROTLI
|
|
||||||
|
|
||||||
ref<CompressionSink> makeCompressionSink(const std::string & method, Sink & nextSink, const bool parallel)
|
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")
|
else if (method == "bzip2")
|
||||||
return make_ref<BzipSink>(nextSink);
|
return make_ref<BzipSink>(nextSink);
|
||||||
else if (method == "br")
|
else if (method == "br")
|
||||||
#if HAVE_BROTLI
|
|
||||||
return make_ref<BrotliSink>(nextSink);
|
return make_ref<BrotliSink>(nextSink);
|
||||||
#else
|
|
||||||
return make_ref<BrotliCmdSink>(nextSink);
|
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
throw UnknownCompressionMethod(format("unknown compression method '%s'") % method);
|
throw UnknownCompressionMethod(format("unknown compression method '%s'") % method);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
source common.sh
|
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
|
clearStore
|
||||||
clearCache
|
clearCache
|
||||||
|
|
||||||
|
@ -24,5 +19,3 @@ nix copy --from $cacheURI $outPath --no-check-sigs
|
||||||
HASH2=$(nix hash-path $outPath)
|
HASH2=$(nix hash-path $outPath)
|
||||||
|
|
||||||
[[ $HASH = $HASH2 ]]
|
[[ $HASH = $HASH2 ]]
|
||||||
|
|
||||||
fi # HAVE_BROTLI
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ export xmllint="@xmllint@"
|
||||||
export SHELL="@bash@"
|
export SHELL="@bash@"
|
||||||
export PAGER=cat
|
export PAGER=cat
|
||||||
export HAVE_SODIUM="@HAVE_SODIUM@"
|
export HAVE_SODIUM="@HAVE_SODIUM@"
|
||||||
export HAVE_BROTLI="@HAVE_BROTLI@"
|
|
||||||
|
|
||||||
export version=@PACKAGE_VERSION@
|
export version=@PACKAGE_VERSION@
|
||||||
export system=@system@
|
export system=@system@
|
||||||
|
|
Loading…
Reference in a new issue