]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
repo: Handle relative paths on compose
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Mar 2023 13:30:47 +0000 (13:30 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Mar 2023 13:44:41 +0000 (13:44 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/repo.c

index ee4a84c5425c2c44adb83811fb9c4164e28f9989..950916073f23a3804d4dd4c8f9f53077e3969830 100644 (file)
@@ -1504,6 +1504,8 @@ ERROR:
 PAKFIRE_EXPORT int pakfire_repo_compose(struct pakfire* pakfire, const char* path,
                int flags, const char** files) {
        struct pakfire_repo* repo = NULL;
+       const char* abspath = NULL;
+       char baseurl[PATH_MAX];
        int r;
 
        // path cannot be NULL
@@ -1520,10 +1522,13 @@ PAKFIRE_EXPORT int pakfire_repo_compose(struct pakfire* pakfire, const char* pat
                        num_files++;
        }
 
-       char baseurl[PATH_MAX];
+       // Make path absolute
+       abspath = pakfire_path_abspath(path);
+       if (!abspath)
+               return 1;
 
        // Prefix path with file:// to form baseurl
-       r = pakfire_string_format(baseurl, "file://%s", path);
+       r = pakfire_string_format(baseurl, "file://%s", abspath);
        if (r)
                return 1;
 
@@ -1576,12 +1581,12 @@ PAKFIRE_EXPORT int pakfire_repo_compose(struct pakfire* pakfire, const char* pat
                        const char* filename = pakfire_package_get_string(package, PAKFIRE_PKG_FILENAME);
 
                        // Make new path
-                       r = pakfire_path_join(destination_path, path, filename);
+                       r = pakfire_path_join(destination_path, abspath, filename);
                        if (r)
                                goto OUT;
 
                        // Copying archive to destination
-                       r = pakfire_archive_copy(archive, destination_path);
+                       r = pakfire_archive_link_or_copy(archive, destination_path);
                        if (r) {
                                ERROR(pakfire, "Could not copy archive to %s: %m\n", destination_path);
                                goto OUT;