]> git.ipfire.org Git - pakfire.git/commitdiff
packager: Do not write an empty filelist and payload
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 5 Oct 2021 19:57:16 +0000 (19:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 5 Oct 2021 19:57:16 +0000 (19:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/packager.c

index bdce258a199d2e360abc9cc53f30fe4db164b82c..42657e7961dd538f912d2872e68e5d50c09b9302 100644 (file)
@@ -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;