From: Michael Tremer Date: Tue, 5 Oct 2021 19:57:16 +0000 (+0000) Subject: packager: Do not write an empty filelist and payload X-Git-Tag: 0.9.28~890 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bee2e8a7c8ce460d80f096ddfc274879f0b47d41;p=pakfire.git packager: Do not write an empty filelist and payload Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/packager.c b/src/libpakfire/packager.c index bdce258a1..42657e796 100644 --- a/src/libpakfire/packager.c +++ b/src/libpakfire/packager.c @@ -58,6 +58,7 @@ struct pakfire_packager { struct archive* mtree; FILE* fmtree; size_t installsize; + unsigned int files; struct pakfire_scriptlet** scriptlets; unsigned int num_scriptlets; @@ -853,21 +854,23 @@ int pakfire_packager_finish(struct pakfire_packager* packager, FILE* f) { } // Write the filelist in mtree format - r = pakfire_packager_write_archive(packager, a, mtree, "filelist", - &packager->mtree, packager->fmtree); - if (r) { - ERROR(packager->pakfire, "Could not add filelist to archive: %s\n", - archive_error_string(a)); - goto ERROR; - } + if (packager->files) { + r = pakfire_packager_write_archive(packager, a, mtree, "filelist", + &packager->mtree, packager->fmtree); + if (r) { + ERROR(packager->pakfire, "Could not add filelist to archive: %s\n", + archive_error_string(a)); + goto ERROR; + } - // Write the payload - r = pakfire_packager_write_archive(packager, a, mtree, "data.img", - &packager->payload, packager->fpayload); - if (r) { - ERROR(packager->pakfire, "Could not add payload to archive: %s\n", - archive_error_string(a)); - goto ERROR; + // Write the payload + r = pakfire_packager_write_archive(packager, a, mtree, "data.img", + &packager->payload, packager->fpayload); + if (r) { + ERROR(packager->pakfire, "Could not add payload to archive: %s\n", + archive_error_string(a)); + goto ERROR; + } } // Write scriptlets @@ -1072,6 +1075,9 @@ int pakfire_packager_add(struct pakfire_packager* packager, // Increment installsize packager->installsize += archive_entry_size(entry); + // Increment file counter + packager->files++; + // Successful r = 0;