From: Michael Tremer Date: Sun, 21 Aug 2022 12:55:20 +0000 (+0000) Subject: packager: Compress the outer tarball X-Git-Tag: 0.9.28~409 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63476763c79434cb63cdcf54a9155049f137c337;p=pakfire.git packager: Compress the outer tarball Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/packager.c b/src/libpakfire/packager.c index ceaade367..f8170c9b3 100644 --- a/src/libpakfire/packager.c +++ b/src/libpakfire/packager.c @@ -66,9 +66,6 @@ struct pakfire_packager { static int pakfire_packager_create_payload(struct pakfire_packager* p) { char path[] = PAKFIRE_TMP_DIR "/pakfire-payload.XXXXXX"; - // Do not compress source packages - const int compress = !pakfire_package_is_source(p->pkg); - p->payload = archive_write_new(); if (!p->payload) { ERROR(p->pakfire, "archive_write_new() failed\n"); @@ -83,39 +80,6 @@ static int pakfire_packager_create_payload(struct pakfire_packager* p) { return r; } - // Store any extended attributes in the SCHILY headers - r = archive_write_set_format_option(p->payload, "pax", "xattrheader", "SCHILY"); - if (r) { - ERROR(p->pakfire, "Could not set xattrheader option: %s\n", - archive_error_string(p->payload)); - return r; - } - - // Add filters to compress the payload - if (compress) { - // Enable Zstd - r = archive_write_add_filter_zstd(p->payload); - if (r) { - ERROR(p->pakfire, "Could not enable Zstandard compression: %s\n", - archive_error_string(p->payload)); - return r; - } - - // Set compression level to highest - r = archive_write_set_filter_option(p->payload, NULL, "compression-level", "22"); - if (r) { - ERROR(p->pakfire, "Could not set Zstandard compression level: %s\n", - archive_error_string(p->payload)); - return r; - } - - // Add feature marker - pakfire_package_add_requires(p->pkg, "pakfire(Compress-Zstandard)"); - - // Do not pad the last block - archive_write_set_bytes_in_last_block(p->payload, 1); - } - // Create a new temporary file p->fpayload = pakfire_mktemp(path); if (!p->fpayload) @@ -485,6 +449,36 @@ int pakfire_packager_finish(struct pakfire_packager* packager, FILE* f) { goto ERROR; } + // Store any extended attributes in the SCHILY headers + r = archive_write_set_format_option(a, "pax", "xattrheader", "SCHILY"); + if (r) { + ERROR(packager->pakfire, "Could not set xattrheader option: %s\n", + archive_error_string(a)); + return r; + } + + // Enable Zstd + r = archive_write_add_filter_zstd(a); + if (r) { + ERROR(packager->pakfire, "Could not enable Zstandard compression: %s\n", + archive_error_string(a)); + return r; + } + + // Set compression level to highest + r = archive_write_set_filter_option(a, NULL, "compression-level", "22"); + if (r) { + ERROR(packager->pakfire, "Could not set Zstandard compression level: %s\n", + archive_error_string(a)); + return r; + } + + // Add feature marker + pakfire_package_add_requires(packager->pkg, "pakfire(Compress-Zstandard)"); + + // Do not pad the last block + archive_write_set_bytes_in_last_block(a, 1); + // Write archive to f r = archive_write_open_FILE(a, f); if (r) {