]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Fix composing import paths
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Feb 2025 14:53:44 +0000 (14:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Feb 2025 14:53:44 +0000 (14:53 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/repo.c

index a0f4a18f9acd739f94aa9d5876314c84aac26571..23c40beed0f41efa2694e0047fab0d1813f23070 100644 (file)
@@ -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