From aa4ece079d2ce43d3454c561944e201622829a54 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 30 Mar 2025 16:32:18 +0000 Subject: [PATCH] dist: Remove the old solution to pass the filename Signed-off-by: Michael Tremer --- src/cli/lib/dist.c | 9 +++++---- src/pakfire/dist.c | 8 ++------ src/pakfire/dist.h | 4 ++-- src/pakfire/packager.c | 12 ------------ src/pakfire/packager.h | 2 -- src/pakfire/pakfire.c | 2 +- src/python/pakfire.c | 2 +- tests/libpakfire/makefile.c | 7 +------ 8 files changed, 12 insertions(+), 34 deletions(-) diff --git a/src/cli/lib/dist.c b/src/cli/lib/dist.c index b8a997717..4e09fdde5 100644 --- a/src/cli/lib/dist.c +++ b/src/cli/lib/dist.c @@ -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; } diff --git a/src/pakfire/dist.c b/src/pakfire/dist.c index 040af3a96..dd923bc8d 100644 --- a/src/pakfire/dist.c +++ b/src/pakfire/dist.c @@ -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); diff --git a/src/pakfire/dist.h b/src/pakfire/dist.h index 9cdc9c176..e0961ecb4 100644 --- a/src/pakfire/dist.h +++ b/src/pakfire/dist.h @@ -25,8 +25,8 @@ #include #include -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); diff --git a/src/pakfire/packager.c b/src/pakfire/packager.c index 506aeeb27..4af3a98a5 100644 --- a/src/pakfire/packager.c +++ b/src/pakfire/packager.c @@ -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"; diff --git a/src/pakfire/packager.h b/src/pakfire/packager.h index 88ed4b76e..39d7a0784 100644 --- a/src/pakfire/packager.h +++ b/src/pakfire/packager.h @@ -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); diff --git a/src/pakfire/pakfire.c b/src/pakfire/pakfire.c index eea0a94b1..0892213de 100644 --- a/src/pakfire/pakfire.c +++ b/src/pakfire/pakfire.c @@ -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; diff --git a/src/python/pakfire.c b/src/python/pakfire.c index cfe3466d7..54226fef4 100644 --- a/src/python/pakfire.c +++ b/src/python/pakfire.c @@ -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); diff --git a/tests/libpakfire/makefile.c b/tests/libpakfire/makefile.c index 5ea58749b..18b46d96e 100644 --- a/tests/libpakfire/makefile.c +++ b/tests/libpakfire/makefile.c @@ -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)); -- 2.39.5