]> git.ipfire.org Git - pakfire.git/commitdiff
packages: Automatically ignore any dependencies that are provided by the package...
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 4 Jan 2025 13:41:02 +0000 (13:41 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 4 Jan 2025 13:41:02 +0000 (13:41 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/build.c
src/pakfire/package.c

index 345c1aa83a81bc9881afbd852891a16bbb6cff53..798149aefe388d39acbad3993fcb11ac8a7c856b 100644 (file)
@@ -396,10 +396,6 @@ static int pakfire_build_process_deps(struct pakfire_ctx* ctx, void* data,
                // If this is a file, we check if it is on the filelist
                if (pakfire_filelist_contains(p->filelist, dep))
                        goto SKIP;
-
-               // Otherwise check if this dependency is provided by this package
-               else if (pakfire_package_matches_dep(p->pkg, PAKFIRE_PKG_PROVIDES, dep))
-                       goto SKIP;
        }
 
        // Add dependency
index 848ee074eb00a78ea23afaaf1b5682f145909036..b0ca108b422290e5a231dca157497918c2412347 100644 (file)
@@ -1512,6 +1512,14 @@ int pakfire_package_add_dep(struct pakfire_package* pkg,
                                        return 0;
                        }
 
+                       // Skip any dependencies that are provided by this package
+                       if (pakfire_package_matches_dep(pkg, PAKFIRE_PKG_PROVIDES, buffer)) {
+                               DEBUG(pkg->ctx, "Ignoring '%s' because it is provided by the package itself\n", buffer);
+                               return 0;
+                       }
+
+                       break;
+
                default:
                        break;
        }
@@ -1608,8 +1616,8 @@ int pakfire_package_has_rich_deps(struct pakfire_package* pkg) {
        return 0;
 }
 
-int pakfire_package_matches_dep(struct pakfire_package* pkg,
-               const enum pakfire_package_key key, const char* dep) {
+static int pakfire_package_matches_depid(struct pakfire_package* pkg,
+               const enum pakfire_package_key key, const Id dep) {
        int r;
 
        Id id = ID_NULL;
@@ -1620,16 +1628,21 @@ int pakfire_package_matches_dep(struct pakfire_package* pkg,
        if (r)
                return r;
 
-       // Get the dependency
-       Id depid = pakfire_str2dep(pkg->pakfire, dep);
-       if (!depid)
-               return -1;
-
        // Fetch the solvable
        Solvable* s = get_solvable(pkg);
 
        // Check whether this solvable matches the requested dependency
-       return solvable_matchesdep(s, id, depid, marker);
+       return solvable_matchesdep(s, id, dep, marker);
+}
+
+int pakfire_package_matches_dep(struct pakfire_package* pkg,
+               const enum pakfire_package_key key, const char* dep) {
+       // Get the dependency
+       Id id = pakfire_str2dep(pkg->pakfire, dep);
+       if (!id)
+               return -EINVAL;
+
+       return pakfire_package_matches_depid(pkg, key, id);
 }
 
 struct pakfire_repo* pakfire_package_get_repo(struct pakfire_package* pkg) {