]> git.ipfire.org Git - pakfire.git/commitdiff
dist: Remove the old solution to pass the filename
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 30 Mar 2025 16:32:18 +0000 (16:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 30 Mar 2025 16:32:18 +0000 (16:32 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/dist.c
src/pakfire/dist.c
src/pakfire/dist.h
src/pakfire/packager.c
src/pakfire/packager.h
src/pakfire/pakfire.c
src/python/pakfire.c
tests/libpakfire/makefile.c

index b8a9977179b043007acb43ad3203eb5478139348..4e09fdde5e7fa243fc7ea4c36c810421b431e437 100644 (file)
@@ -62,15 +62,18 @@ static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
 
 static int do_dist(struct pakfire* pakfire, const char* makefile, const char* resultdir) {
        struct pakfire_archive* archive = NULL;
-       char* filename = NULL;
+       const char* filename = NULL;
        char path[PATH_MAX];
        int r;
 
        // Create the archive
-       r = pakfire_dist(pakfire, makefile, &archive, &filename);
+       r = pakfire_dist(pakfire, makefile, &archive);
        if (r < 0)
                goto ERROR;
 
+       // Fetch the filename
+       filename = pakfire_archive_get_filename(archive);
+
        // Make the final path
        r = pakfire_path_append(path, resultdir, filename);
        if (r < 0)
@@ -89,8 +92,6 @@ static int do_dist(struct pakfire* pakfire, const char* makefile, const char* re
 ERROR:
        if (archive)
                pakfire_archive_unref(archive);
-       if (filename)
-               free(filename);
 
        return r;
 }
index 040af3a96d0ef68ee052f1022710c30ea2338107..dd923bc8d3fbd1477cf93f78b0049ff6a28fce3c 100644 (file)
@@ -450,8 +450,8 @@ ERROR:
        return r;
 }
 
-int pakfire_dist(struct pakfire* pakfire, const char* path,
-               struct pakfire_archive** archive, char** filename) {
+int pakfire_dist(struct pakfire* pakfire,
+               const char* path, struct pakfire_archive** archive) {
        struct pakfire_packager* packager = NULL;
        struct pakfire_package* pkg = NULL;
        struct pakfire_parser* makefile = NULL;
@@ -510,10 +510,6 @@ int pakfire_dist(struct pakfire* pakfire, const char* path,
        if (r < 0)
                goto ERROR;
 
-       // Return the filename
-       if (filename)
-               *filename = pakfire_packager_filename(packager);
-
        // Return a reference to the archive
        *archive = pakfire_archive_ref(a);
 
index 9cdc9c176c6855d371b7b9b0e47f39cbf1d65799..e0961ecb4de6f6b549d3b6be944792ee705c9cad 100644 (file)
@@ -25,8 +25,8 @@
 #include <pakfire/pakfire.h>
 #include <pakfire/parser.h>
 
-int pakfire_dist(struct pakfire* pakfire, const char* path,
-               struct pakfire_archive** archive, char** filename);
+int pakfire_dist(struct pakfire* pakfire,
+       const char* path, struct pakfire_archive** archive);
 
 int pakfire_read_makefile(struct pakfire_parser** parser, struct pakfire* pakfire,
        const char* path, struct pakfire_parser_error** error);
index 506aeeb276607ffe7d8f8fd7fa4f02dc5eb7bba3..4af3a98a510f6412ad02a250e428f9c73aa63508 100644 (file)
@@ -220,18 +220,6 @@ struct pakfire_packager* pakfire_packager_unref(
        return NULL;
 }
 
-char* pakfire_packager_filename(struct pakfire_packager* packager) {
-       const char* filename = NULL;
-
-       // Fetch the filename from the package
-       filename = pakfire_package_get_string(packager->pkg, PAKFIRE_PKG_FILENAME);
-       if (!filename)
-               return NULL;
-
-       // Copy the string
-       return strdup(filename);
-}
-
 static int pakfire_packager_write_format(struct pakfire_packager* packager,
                struct pakfire_archive_writer* writer) {
        const char format[] = TO_STRING(PACKAGE_FORMAT) "\n";
index 88ed4b76eb1e94e27833157bc5eadf9253177fbe..39d7a0784ce479aa180f8530053d9dc53072a342 100644 (file)
@@ -37,8 +37,6 @@ int pakfire_packager_create(struct pakfire_packager** packager,
 struct pakfire_packager* pakfire_packager_ref(struct pakfire_packager* packager);
 struct pakfire_packager* pakfire_packager_unref(struct pakfire_packager* packager);
 
-char* pakfire_packager_filename(struct pakfire_packager* packager);
-
 int pakfire_packager_write_archive(struct pakfire_packager* self,
        struct pakfire_archive** archive);
 
index eea0a94b17568338aedae5c119d02d76ae3351f3..0892213deffe71d8ef033ae6fbe563f2a0b309a9 100644 (file)
@@ -1450,7 +1450,7 @@ static int pakfire_commandline_dist(struct pakfire* pakfire, struct pakfire_repo
        int r;
 
        // Run dist()
-       r = pakfire_dist(pakfire, path, &archive, NULL);
+       r = pakfire_dist(pakfire, path, &archive);
        if (r < 0)
                goto ERROR;
 
index cfe3466d71a4e48f365748e8cd32e5d02732c2c6..54226fef45ac70cb64643f8f2832134612f2dd37 100644 (file)
@@ -369,7 +369,7 @@ static PyObject* Pakfire_dist(PakfireObject* self, PyObject* args) {
 
        Py_BEGIN_ALLOW_THREADS
 
-       r = pakfire_dist(self->pakfire, path, &archive, NULL);
+       r = pakfire_dist(self->pakfire, path, &archive);
        if (r) {
                Py_BLOCK_THREADS
                PyErr_SetFromErrno(PyExc_OSError);
index 5ea58749b19d339b14c5df6b81d198c738ba261c..18b46d96e3165388a4eed5d7c062f35cd131dbac 100644 (file)
@@ -180,14 +180,9 @@ static int test_dist_dummy(const struct test* t) {
        char* tmp = test_mkdtemp();
        ASSERT(tmp);
 
-       char* filename = NULL;
-
        // Attempt to dist the dummy package
        ASSERT_SUCCESS(pakfire_dist(t->pakfire,
-               TEST_SRC_PATH "data/packages/dummy/dummy.nm", &archive, &filename));
-
-       // Check if filename is set
-       ASSERT(filename);
+               TEST_SRC_PATH "data/packages/dummy/dummy.nm", &archive));
 
        // Extract all package metadata
        ASSERT_SUCCESS(pakfire_archive_make_package(archive, NULL, &package));