diff options
-rw-r--r-- | meson.build | 1 | ||||
-rw-r--r-- | src/import/import-compress.c | 14 | ||||
-rw-r--r-- | src/import/import-compress.h | 4 |
3 files changed, 18 insertions, 1 deletions
diff --git a/meson.build b/meson.build index a503e3bf00..c29f622143 100644 --- a/meson.build +++ b/meson.build @@ -1200,7 +1200,6 @@ want_importd = get_option('importd') if want_importd != 'false' have = (conf.get('HAVE_LIBCURL') == 1 and conf.get('HAVE_ZLIB') == 1 and - conf.get('HAVE_BZIP2') == 1 and conf.get('HAVE_XZ') == 1 and conf.get('HAVE_GCRYPT') == 1) if want_importd == 'true' and not have diff --git a/src/import/import-compress.c b/src/import/import-compress.c index 1cf29e26f1..3fbd067790 100644 --- a/src/import/import-compress.c +++ b/src/import/import-compress.c @@ -14,11 +14,13 @@ void import_compress_free(ImportCompress *c) { deflateEnd(&c->gzip); else inflateEnd(&c->gzip); +#if HAVE_BZIP2 } else if (c->type == IMPORT_COMPRESS_BZIP2) { if (c->encoding) BZ2_bzCompressEnd(&c->bzip2); else BZ2_bzDecompressEnd(&c->bzip2); +#endif } c->type = IMPORT_COMPRESS_UNKNOWN; @@ -65,12 +67,14 @@ int import_uncompress_detect(ImportCompress *c, const void *data, size_t size) { c->type = IMPORT_COMPRESS_GZIP; +#if HAVE_BZIP2 } else if (memcmp(data, bzip2_signature, sizeof(bzip2_signature)) == 0) { r = BZ2_bzDecompressInit(&c->bzip2, 0, 0); if (r != BZ_OK) return -EIO; c->type = IMPORT_COMPRESS_BZIP2; +#endif } else c->type = IMPORT_COMPRESS_UNCOMPRESSED; @@ -149,6 +153,7 @@ int import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCo break; +#if HAVE_BZIP2 case IMPORT_COMPRESS_BZIP2: c->bzip2.next_in = (void*) data; c->bzip2.avail_in = size; @@ -169,6 +174,7 @@ int import_uncompress(ImportCompress *c, const void *data, size_t size, ImportCo } break; +#endif default: assert_not_reached("Unknown compression"); @@ -203,6 +209,7 @@ int import_compress_init(ImportCompress *c, ImportCompressType t) { c->type = IMPORT_COMPRESS_GZIP; break; +#if HAVE_BZIP2 case IMPORT_COMPRESS_BZIP2: r = BZ2_bzCompressInit(&c->bzip2, 9, 0, 0); if (r != BZ_OK) @@ -210,6 +217,7 @@ int import_compress_init(ImportCompress *c, ImportCompressType t) { c->type = IMPORT_COMPRESS_BZIP2; break; +#endif case IMPORT_COMPRESS_UNCOMPRESSED: c->type = IMPORT_COMPRESS_UNCOMPRESSED; @@ -307,6 +315,7 @@ int import_compress(ImportCompress *c, const void *data, size_t size, void **buf break; +#if HAVE_BZIP2 case IMPORT_COMPRESS_BZIP2: c->bzip2.next_in = (void*) data; @@ -328,6 +337,7 @@ int import_compress(ImportCompress *c, const void *data, size_t size, void **buf } break; +#endif case IMPORT_COMPRESS_UNCOMPRESSED: @@ -411,6 +421,7 @@ int import_compress_finish(ImportCompress *c, void **buffer, size_t *buffer_size break; +#if HAVE_BZIP2 case IMPORT_COMPRESS_BZIP2: c->bzip2.avail_in = 0; @@ -430,6 +441,7 @@ int import_compress_finish(ImportCompress *c, void **buffer, size_t *buffer_size } while (r != BZ_STREAM_END); break; +#endif case IMPORT_COMPRESS_UNCOMPRESSED: break; @@ -446,7 +458,9 @@ static const char* const import_compress_type_table[_IMPORT_COMPRESS_TYPE_MAX] = [IMPORT_COMPRESS_UNCOMPRESSED] = "uncompressed", [IMPORT_COMPRESS_XZ] = "xz", [IMPORT_COMPRESS_GZIP] = "gzip", +#if HAVE_BZIP2 [IMPORT_COMPRESS_BZIP2] = "bzip2", +#endif }; DEFINE_STRING_TABLE_LOOKUP(import_compress_type, ImportCompressType); diff --git a/src/import/import-compress.h b/src/import/import-compress.h index 6fb87ccdfb..859bd0e1a4 100644 --- a/src/import/import-compress.h +++ b/src/import/import-compress.h @@ -1,7 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #pragma once +#if HAVE_BZIP2 #include <bzlib.h> +#endif #include <lzma.h> #include <sys/types.h> #include <zlib.h> @@ -24,7 +26,9 @@ typedef struct ImportCompress { union { lzma_stream xz; z_stream gzip; +#if HAVE_BZIP2 bz_stream bzip2; +#endif }; } ImportCompress; |