From 90a6a68a184f13e7361a4fb660e92c9a627e8424 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 4 Jan 2025 13:41:02 +0000 Subject: [PATCH] packages: Automatically ignore any dependencies that are provided by the package itself Signed-off-by: Michael Tremer --- src/pakfire/build.c | 4 ---- src/pakfire/package.c | 29 +++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/pakfire/build.c b/src/pakfire/build.c index 345c1aa83..798149aef 100644 --- a/src/pakfire/build.c +++ b/src/pakfire/build.c @@ -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 diff --git a/src/pakfire/package.c b/src/pakfire/package.c index 848ee074e..b0ca108b4 100644 --- a/src/pakfire/package.c +++ b/src/pakfire/package.c @@ -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) { -- 2.47.2