From: Michael Tremer Date: Thu, 9 Mar 2023 13:30:47 +0000 (+0000) Subject: repo: Handle relative paths on compose X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d31bb2713d59d20a3d3a7b779e348778c963284;p=people%2Fstevee%2Fpakfire.git repo: Handle relative paths on compose Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index ee4a84c5..95091607 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -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;