From: Michael Tremer Date: Sat, 4 Mar 2023 11:44:59 +0000 (+0000) Subject: build: Delete static libraries only when there is a shared object X-Git-Tag: 0.9.29~369 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=add08b7d58da2829b1e7e3991a4f2f06625d3ca3;p=pakfire.git build: Delete static libraries only when there is a shared object This brings back the former behaviour. Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index 225ce36e8..b0ba23f02 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -1040,10 +1040,25 @@ ERROR: static int __pakfire_build_remove_static_libraries( struct pakfire* pakfire, struct pakfire_file* file, void* data) { struct pakfire_filelist* removees = (struct pakfire_filelist*)data; + char path[PATH_MAX]; + int r; // Find all static libraries - if (pakfire_file_matches_class(file, PAKFIRE_FILE_STATIC_LIBRARY)) - return pakfire_filelist_add(removees, file); + if (pakfire_file_matches_class(file, PAKFIRE_FILE_STATIC_LIBRARY)) { + // Copy the filename + r = pakfire_string_set(path, pakfire_file_get_abspath(file)); + if (r) + return -1; + + // Remove the extension + r = pakfire_path_replace_extension(path, "so"); + if (r) + return -1; + + // Only delete if there is a shared object with the same name + if (pakfire_path_exists(path)) + return pakfire_filelist_add(removees, file); + } return 0; } diff --git a/src/libpakfire/include/pakfire/util.h b/src/libpakfire/include/pakfire/util.h index f0742169e..89ffeb518 100644 --- a/src/libpakfire/include/pakfire/util.h +++ b/src/libpakfire/include/pakfire/util.h @@ -41,6 +41,10 @@ time_t pakfire_path_age(const char* path); int pakfire_path_strip_extension(char* path); +#define pakfire_path_replace_extension(path, extension) \ + __pakfire_path_replace_extension(path, sizeof(path), extension) +int __pakfire_path_replace_extension(char* path, const size_t length, const char* extension); + const char* pakfire_basename(const char* path); const char* pakfire_dirname(const char* path); diff --git a/src/libpakfire/util.c b/src/libpakfire/util.c index 442ddc0a0..8fe802f39 100644 --- a/src/libpakfire/util.c +++ b/src/libpakfire/util.c @@ -166,6 +166,24 @@ int pakfire_path_strip_extension(char* path) { return 0; } +int __pakfire_path_replace_extension(char* path, const size_t length, const char* extension) { + char buffer[PATH_MAX]; + int r; + + // Copy path to buffer + r = pakfire_string_set(buffer, path); + if (r) + return r; + + // Strip any old extension + r = pakfire_path_strip_extension(buffer); + if (r) + return r; + + // Compose the new string + return __pakfire_string_format(path, length, "%s.%s", buffer, extension); +} + int pakfire_file_write(struct pakfire* pakfire, const char* path, uid_t owner, gid_t group, mode_t mode, const char* format, ...) { va_list args;