]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
build: Delete static libraries only when there is a shared object
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 4 Mar 2023 11:44:59 +0000 (11:44 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 4 Mar 2023 11:44:59 +0000 (11:44 +0000)
This brings back the former behaviour.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c
src/libpakfire/include/pakfire/util.h
src/libpakfire/util.c

index 225ce36e85035b5199ec71e9785f648269fd3df8..b0ba23f02772e64ec664c2c460a682c86726c9f6 100644 (file)
@@ -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;
 }
index f0742169e57aaa142c9a73b2f446ff572c6488aa..89ffeb5184fdcc275e35d9431bba8a07c73c5f3d 100644 (file)
@@ -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);
 
index 442ddc0a03e126087d2cabbe774210fc134f5058..8fe802f39c7a812fd3ba292bf1bdf36d86595dc4 100644 (file)
@@ -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;