]> git.ipfire.org Git - pakfire.git/commitdiff
filelist: Add dump function to dump an entire filelist
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 20 Sep 2022 09:56:30 +0000 (09:56 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 20 Sep 2022 09:56:30 +0000 (09:56 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/filelist.c
src/libpakfire/include/pakfire/filelist.h
src/libpakfire/packager.c

index c894ad3ef0dd8cd366a6d48c4537f03c79b49a9b..97acff18c05a8c81f98fffa18269e4c81edcd6ab 100644 (file)
@@ -397,6 +397,33 @@ int pakfire_filelist_walk(struct pakfire_filelist* list,
        return r;
 }
 
+static int __pakfire_filelist_dump(
+               struct pakfire* pakfire, struct pakfire_file* file, void* p) {
+       const int debug = *(int*)p;
+
+       char* s = pakfire_file_dump(file);
+       if (s) {
+               if (debug)
+                       DEBUG(pakfire, "%s\n", s);
+               else
+                       INFO(pakfire, "%s\n", s);
+
+               free(s);
+       }
+
+       return 0;
+}
+
+int pakfire_filelist_dump(struct pakfire_filelist* list, int debug) {
+#ifndef ENABLE_DEBUG
+       // Avoid walking through the entire filelist in non-debug mode
+       if (debug)
+               return 0;
+#endif
+
+       return pakfire_filelist_walk(list, __pakfire_filelist_dump, &debug);
+}
+
 /*
        Verifies all files on the filelist
 */
index 11ee505b41e495643a47f2973d9c40e2e52edfc9..519ce82fcd8a8e3f569fe81b8c0b94be05c0da94 100644 (file)
@@ -56,6 +56,7 @@ typedef int (*pakfire_filelist_walk_callback)
 
 int pakfire_filelist_walk(struct pakfire_filelist* list,
        pakfire_filelist_walk_callback callback, void* data);
+int pakfire_filelist_dump(struct pakfire_filelist* list, int debug);
 
 int pakfire_filelist_verify(struct pakfire_filelist* list, struct pakfire_filelist* errors);
 
index 3bfef56ec47407927f73763b061bca2dbd66a98e..434074ed00efa53b38fb56330981b184f8ecfb66 100644 (file)
@@ -345,6 +345,15 @@ int pakfire_packager_finish(struct pakfire_packager* packager, FILE* f) {
        if (pakfire_package_has_rich_deps(packager->pkg))
                pakfire_package_add_requires(packager->pkg, "pakfire(RichDependencies)");
 
+#ifdef ENABLE_DEBUG
+       DEBUG(packager->pakfire, "Filelist:\n");
+
+       // Dump filelist
+       r = pakfire_filelist_dump(packager->filelist, 1);
+       if (r)
+               goto ERROR;
+#endif
+
        // Add filelist
        r = pakfire_package_set_filelist(packager->pkg, packager->filelist);
        if (r)