]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
packager: Compress the outer tarball
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 21 Aug 2022 12:55:20 +0000 (12:55 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 21 Aug 2022 12:55:20 +0000 (12:55 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/packager.c

index ceaade3670acd3a4922d01aa070ebf1d88d52f52..f8170c9b3b4393383b2d57a1997e803330a66f40 100644 (file)
@@ -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) {