From b4f736f9635cfcbc3afd4c0f241b667c3d528b72 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 3 Feb 2025 14:53:44 +0000 Subject: [PATCH] repo: Fix composing import paths Signed-off-by: Michael Tremer --- src/pakfire/repo.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/pakfire/repo.c b/src/pakfire/repo.c index a0f4a18f..23c40bee 100644 --- a/src/pakfire/repo.c +++ b/src/pakfire/repo.c @@ -512,7 +512,7 @@ int __pakfire_repo_make_path(struct pakfire_repo* self, char* path, size_t lengt // Compose the destination path switch (self->appdata->fs_layout) { case PAKFIRE_REPO_FLAT: - return __pakfire_repo_path(self, path, length, "%s", filename); + return __pakfire_string_set(path, length, filename); case PAKFIRE_REPO_UUID: // Fetch the UUID @@ -522,7 +522,7 @@ int __pakfire_repo_make_path(struct pakfire_repo* self, char* path, size_t lengt return -ENODATA; } - return __pakfire_repo_path(self, path, length, "%s/%s", uuid, filename); + return __pakfire_string_format(path, length, "%s/%s", uuid, filename); // In virtual mode, we don't actually import the file case PAKFIRE_REPO_VIRT: @@ -535,6 +535,7 @@ int __pakfire_repo_make_path(struct pakfire_repo* self, char* path, size_t lengt int pakfire_repo_import_archive(struct pakfire_repo* self, struct pakfire_archive* archive, struct pakfire_package** package) { struct pakfire_package* pkg = NULL; + char path[PATH_MAX]; int r; // This only works on internal or local repositories @@ -546,15 +547,24 @@ int pakfire_repo_import_archive(struct pakfire_repo* self, if (r < 0) goto ERROR; - // Fetch package path - const char* arc_path = pakfire_archive_get_path(archive); - const char* pkg_path = pakfire_package_get_string(pkg, PAKFIRE_PKG_PATH); + // Unless this is a virtual repository, copy the archive + switch (self->appdata->fs_layout) { + case PAKFIRE_REPO_VIRT: + break; - // Copy (or link) the archive - if (!pakfire_string_equals(arc_path, pkg_path)) { - r = pakfire_archive_link_or_copy(archive, pkg_path); - if (r < 0) - goto ERROR; + default: + // Make the path + r = pakfire_repo_path(self, path, "%s", + pakfire_package_get_string(pkg, PAKFIRE_PKG_PATH)); + if (r < 0) + goto ERROR; + + printf("PATH = %s\n", path); + + // Copy (or link) the archive + r = pakfire_archive_link_or_copy(archive, path); + if (r < 0) + goto ERROR; } // Return the package if requested -- 2.39.5