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");
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)
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) {