]> git.ipfire.org Git - pakfire.git/commitdiff
packager: Create its own type
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Jun 2025 14:27:59 +0000 (14:27 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Jun 2025 14:27:59 +0000 (14:27 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/build.c
src/pakfire/dist.c
src/pakfire/packager.c
src/pakfire/packager.h
tests/libpakfire/packager.c

index d19ba7a8c6881af8ff28348522d863f33780dc20..37bc5bd813b55d925cb8b72ebdbd7f9a64333c10 100644 (file)
@@ -955,7 +955,7 @@ ERROR:
 
 static int pakfire_build_package_add_files(pakfire_build* build,
                struct pakfire_parser* makefile, const char* buildroot, const char* namespace,
-               struct pakfire_package* pkg, struct pakfire_packager* packager) {
+               struct pakfire_package* pkg, pakfire_packager* packager) {
        pakfire_filelist* filelist = NULL;
        char** includes = NULL;
        char** excludes = NULL;
@@ -1140,7 +1140,7 @@ static int pakfire_build_add_scriptlet_requires(pakfire_build* build,
 }
 
 static int pakfire_build_package_add_scriptlet(pakfire_build* build,
-               struct pakfire_package* pkg, struct pakfire_packager* packager,
+               struct pakfire_package* pkg, pakfire_packager* packager,
                const char* type, const char* data) {
        struct pakfire_scriptlet* scriptlet = NULL;
        char* shell = NULL;
@@ -1184,7 +1184,7 @@ ERROR:
 
 static int pakfire_build_package_add_scriptlets(pakfire_build* build,
                struct pakfire_parser* makefile, const char* namespace,
-               struct pakfire_package* pkg, struct pakfire_packager* packager) {
+               struct pakfire_package* pkg, pakfire_packager* packager) {
        char name[NAME_MAX];
        int r;
 
@@ -1215,7 +1215,7 @@ static int pakfire_build_package(pakfire_build* build, struct pakfire_parser* ma
                const char* buildroot, const char* namespace) {
        pakfire_archive* archive = NULL;
        struct pakfire_package* pkg = NULL;
-       struct pakfire_packager* packager = NULL;
+       pakfire_packager* packager = NULL;
 
        int r = 1;
 
index d3979deb75627b314e785124f1216e1d4fbc44f7..59b6b4f0e248494c55c698bfb0ae9378da6c1c57 100644 (file)
@@ -324,7 +324,7 @@ ERROR:
        return r;
 }
 
-static int pakfire_dist_add_source(struct pakfire* pakfire, struct pakfire_packager* packager,
+static int pakfire_dist_add_source(struct pakfire* pakfire, pakfire_packager* packager,
                struct pakfire_package* pkg, pakfire_ctx* ctx,
                pakfire_mirrorlist* mirrorlist, const char* filename) {
        char archive_path[PATH_MAX];
@@ -352,7 +352,7 @@ static int pakfire_dist_add_source(struct pakfire* pakfire, struct pakfire_packa
 }
 
 static int pakfire_dist_add_sources(pakfire_ctx* ctx, struct pakfire* pakfire,
-               struct pakfire_packager* packager, struct pakfire_package* pkg, struct pakfire_parser* makefile) {
+               pakfire_packager* packager, struct pakfire_package* pkg, struct pakfire_parser* makefile) {
        pakfire_mirrorlist* mirrorlist = NULL;
        char* sources = NULL;
        char* p = NULL;
@@ -413,7 +413,7 @@ static int __pakfire_dist_find_root(char* root, const size_t length, const char*
 }
 
 static int pakfire_dist_add_files(pakfire_ctx* ctx, struct pakfire* pakfire,
-               struct pakfire_packager* packager, const char* file) {
+               pakfire_packager* packager, const char* file) {
        pakfire_filelist* filelist = NULL;
        char root[PATH_MAX];
        int r;
@@ -452,7 +452,7 @@ ERROR:
 
 int pakfire_dist(struct pakfire* pakfire,
                const char* path, pakfire_archive** archive) {
-       struct pakfire_packager* packager = NULL;
+       pakfire_packager* packager = NULL;
        struct pakfire_package* pkg = NULL;
        struct pakfire_parser* makefile = NULL;
        struct pakfire_parser_error* error = NULL;
index 4035d948c0963674908d78ecb33ba338334d65bf..125a3311e5cae181ffcb33d9fbccd53e6f740bc6 100644 (file)
@@ -69,7 +69,7 @@ struct pakfire_packager {
        unsigned int digests;
 };
 
-static void pakfire_packager_free(struct pakfire_packager* packager) {
+static void pakfire_packager_free(pakfire_packager* packager) {
        if (packager->reader)
                archive_read_free(packager->reader);
 
@@ -91,9 +91,9 @@ static void pakfire_packager_free(struct pakfire_packager* packager) {
        free(packager);
 }
 
-int pakfire_packager_create(struct pakfire_packager** packager,
+int pakfire_packager_create(pakfire_packager** packager,
                struct pakfire* pakfire, struct pakfire_package* pkg) {
-       struct pakfire_packager* p = NULL;
+       pakfire_packager* p = NULL;
        char hostname[HOST_NAME_MAX];
        int r = 1;
 
@@ -204,15 +204,15 @@ ERROR:
        return r;
 }
 
-struct pakfire_packager* pakfire_packager_ref(
-               struct pakfire_packager* packager) {
+pakfire_packager* pakfire_packager_ref(
+               pakfire_packager* packager) {
        ++packager->nrefs;
 
        return packager;
 }
 
-struct pakfire_packager* pakfire_packager_unref(
-               struct pakfire_packager* packager) {
+pakfire_packager* pakfire_packager_unref(
+               pakfire_packager* packager) {
        if (--packager->nrefs > 0)
                return packager;
 
@@ -220,7 +220,7 @@ struct pakfire_packager* pakfire_packager_unref(
        return NULL;
 }
 
-static int pakfire_packager_write_format(struct pakfire_packager* packager,
+static int pakfire_packager_write_format(pakfire_packager* packager,
                pakfire_archive_writer* writer) {
        const char format[] = TO_STRING(PACKAGE_FORMAT) "\n";
        int r;
@@ -244,7 +244,7 @@ static int pakfire_packager_write_format(struct pakfire_packager* packager,
        return 0;
 }
 
-static int pakfire_packager_write_metadata(struct pakfire_packager* packager,
+static int pakfire_packager_write_metadata(pakfire_packager* packager,
                pakfire_archive_writer* writer) {
        struct json_object* md = NULL;
        int r;
@@ -270,7 +270,7 @@ ERROR:
        return r;
 }
 
-static int pakfire_packager_write_scriptlet(struct pakfire_packager* packager,
+static int pakfire_packager_write_scriptlet(pakfire_packager* packager,
                pakfire_archive_writer* writer, struct pakfire_scriptlet* scriptlet) {
        char filename[PATH_MAX];
        size_t size;
@@ -298,7 +298,7 @@ static int pakfire_packager_write_scriptlet(struct pakfire_packager* packager,
 
        It will create a new archive and write the package to the given file descriptor.
 */
-int pakfire_packager_finish(struct pakfire_packager* packager, FILE* f) {
+int pakfire_packager_finish(pakfire_packager* packager, FILE* f) {
        pakfire_archive_writer* writer = NULL;
        int r;
 
@@ -375,7 +375,7 @@ ERROR:
        return r;
 }
 
-int pakfire_packager_write_archive(struct pakfire_packager* self,
+int pakfire_packager_write_archive(pakfire_packager* self,
                pakfire_archive** archive) {
        FILE* f = NULL;
        char path[PATH_MAX];
@@ -425,7 +425,7 @@ ERROR:
        return r;
 }
 
-int pakfire_packager_add_file(struct pakfire_packager* packager, pakfire_file* file) {
+int pakfire_packager_add_file(pakfire_packager* packager, pakfire_file* file) {
        int r;
 
        // Check input
@@ -487,7 +487,7 @@ int pakfire_packager_add_file(struct pakfire_packager* packager, pakfire_file* f
        return pakfire_filelist_add(packager->filelist, file);
 }
 
-int pakfire_packager_add(struct pakfire_packager* packager,
+int pakfire_packager_add(pakfire_packager* packager,
                const char* sourcepath, const char* path) {
        struct archive_entry* entry = NULL;
        pakfire_file* file = NULL;
@@ -538,18 +538,18 @@ ERROR:
 
 static int __pakfire_packager_add_files(
                pakfire_ctx* ctx, pakfire_file* file, void* data) {
-       struct pakfire_packager* packager = data;
+       pakfire_packager* packager = data;
 
        return pakfire_packager_add_file(packager, file);
 }
 
 int pakfire_packager_add_files(
-               struct pakfire_packager* packager, pakfire_filelist* filelist) {
+               pakfire_packager* packager, pakfire_filelist* filelist) {
        // Add all files on the filelist
        return pakfire_filelist_walk(filelist, __pakfire_packager_add_files, packager, 0, NULL);
 }
 
-int pakfire_packager_add_scriptlet(struct pakfire_packager* packager,
+int pakfire_packager_add_scriptlet(pakfire_packager* packager,
                struct pakfire_scriptlet* scriptlet) {
        if (!scriptlet)
                return -EINVAL;
@@ -569,7 +569,7 @@ int pakfire_packager_add_scriptlet(struct pakfire_packager* packager,
 /*
        Removes all files on the filelist
 */
-int pakfire_packager_cleanup(struct pakfire_packager* packager) {
+int pakfire_packager_cleanup(pakfire_packager* packager) {
        // Delete all files on the filelist
        return pakfire_filelist_cleanup(packager->filelist, PAKFIRE_FILE_CLEANUP_TIDY);
 }
index 965d11a15174b567cacad80c2882cf4ddc319600..f064055db6642ab2ca99e55301508d565f176776 100644 (file)
 
 #define PAKFIRE_PACKAGER_HASHES (PAKFIRE_HASH_SHA3_512|PAKFIRE_HASH_BLAKE2B512)
 
-struct pakfire_packager;
+typedef struct pakfire_packager pakfire_packager;
 
-int pakfire_packager_create(struct pakfire_packager** packager,
+int pakfire_packager_create(pakfire_packager** packager,
        struct pakfire* pakfire, struct pakfire_package* pkg);
 
-struct pakfire_packager* pakfire_packager_ref(struct pakfire_packager* packager);
-struct pakfire_packager* pakfire_packager_unref(struct pakfire_packager* packager);
+pakfire_packager* pakfire_packager_ref(pakfire_packager* packager);
+pakfire_packager* pakfire_packager_unref(pakfire_packager* packager);
 
-int pakfire_packager_write_archive(struct pakfire_packager* self,
+int pakfire_packager_write_archive(pakfire_packager* self,
        pakfire_archive** archive);
 
-int pakfire_packager_finish(struct pakfire_packager* packager, FILE* f);
+int pakfire_packager_finish(pakfire_packager* packager, FILE* f);
 
 int pakfire_packager_add_file(
-       struct pakfire_packager* packager, pakfire_file* file);
-int pakfire_packager_add_files(struct pakfire_packager* packager,
+       pakfire_packager* packager, pakfire_file* file);
+int pakfire_packager_add_files(pakfire_packager* packager,
        pakfire_filelist* filelist);
-int pakfire_packager_add(struct pakfire_packager* packager,
+int pakfire_packager_add(pakfire_packager* packager,
        const char* sourcepath, const char* path);
 
-int pakfire_packager_add_scriptlet(struct pakfire_packager* packager,
+int pakfire_packager_add_scriptlet(pakfire_packager* packager,
        struct pakfire_scriptlet* scriptlet);
 
-int pakfire_packager_cleanup(struct pakfire_packager* packager);
+int pakfire_packager_cleanup(pakfire_packager* packager);
 
 #endif /* PAKFIRE_PACKAGER_H */
index b712bf993f9523c99d5d09828bf78ceafb554f66..5e6ad34cd105cf6329baa13a3f69614d0c9bd54a 100644 (file)
@@ -28,7 +28,7 @@
 #include "../testsuite.h"
 
 static int test_create(const struct test* t) {
-       struct pakfire_packager* packager = NULL;
+       pakfire_packager* packager = NULL;
        struct pakfire_package* pkg = NULL;
        struct pakfire_repo* repo = NULL;
        int r = EXIT_FAILURE;
@@ -68,7 +68,7 @@ static int test_compare_metadata(const struct test* t) {
        pakfire_archive* archive = NULL;
        struct pakfire_package* pkg1 = NULL;
        struct pakfire_package* pkg2 = NULL;
-       struct pakfire_packager* packager = NULL;
+       pakfire_packager* packager = NULL;
        char* path = NULL;
        const char* s = NULL;
        int r = EXIT_FAILURE;