]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
build: Do not add dependencies to files provided by the same package
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 16 Dec 2022 10:26:05 +0000 (10:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 16 Dec 2022 10:26:05 +0000 (10:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c

index d0be3ce9ebdbb6685f048a56a75503a0dd56924c..93b8bf58a36be8ccc1caee8138fd3394e177cc28 100644 (file)
@@ -316,18 +316,32 @@ ERROR:
 static int pakfire_build_process_deps(struct pakfire* pakfire,
                void* data, int priority, const char* buffer, const size_t length) {
        const struct pakfire_find_deps_ctx* ctx = (struct pakfire_find_deps_ctx*)data;
+       char dep[PATH_MAX];
        int r;
 
+       // Nothing to do for an empty buffer
+       if (!buffer || !*buffer)
+               return 0;
+
        switch (priority) {
                // Add every dependency that we have received
                case LOG_INFO:
+                       // Copy the dependency to the stack (and remove the trailing newline)
+                       r = pakfire_string_format(dep, "%.*s", (int)length - 1, buffer);
+                       if (r)
+                               return r;
+
+                       DEBUG(pakfire, "Processing dependency: %s\n", dep);
+
                        // Filter out any dependencies that are provided by this package
                        if (ctx->dep == PAKFIRE_PKG_REQUIRES) {
-                               if (pakfire_package_matches_dep(ctx->pkg, PAKFIRE_PKG_PROVIDES, buffer)) {
-                                       DEBUG(pakfire,
-                                               "Skipping dependency that is provided by the package itself: %s\n", buffer);
-                                       return 0;
-                               }
+                               // If this is a file, we check if it is on the filelist
+                               if (pakfire_filelist_contains(ctx->filelist, dep))
+                                       goto SKIP;
+
+                               // Otherwise check if this dependency is provided by this package
+                               else if (pakfire_package_matches_dep(ctx->pkg, PAKFIRE_PKG_PROVIDES, dep))
+                                       goto SKIP;
                        }
 
                        // Add dependency
@@ -344,6 +358,11 @@ static int pakfire_build_process_deps(struct pakfire* pakfire,
                        break;
        }
 
+       return 0;
+
+SKIP:
+       DEBUG(pakfire, "Skipping dependency that is provided by the package itself: %s\n", dep);
+
        return 0;
 }