dcavalca / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone

Blame SOURCES/0002-Skip-rich-deps-for-autodetection-of-unmet-dependencies-RhBug2033130-2048394.patch

f23e2a
From 025d477f63baf3df2f6da3b10a21f00d4a339073 Mon Sep 17 00:00:00 2001
f23e2a
From: Jaroslav Mracek <jmracek@redhat.com>
f23e2a
Date: Tue, 8 Feb 2022 09:30:03 +0100
f23e2a
Subject: [PATCH] Skip rich deps for autodetection of unmet dependencies (RhBug:2033130, 2048394)
f23e2a
f23e2a
Rich dependencies are difficult to properly evaluate because we do not
f23e2a
have enough information about past and only libsolv is capable to
f23e2a
evaluate it in comparison to present state of the system.
f23e2a
f23e2a
Additionally - rich deps are used for langpacks therefore disabling
f23e2a
unmet rich deps will have a negative impact on UX.
f23e2a
f23e2a
https://bugzilla.redhat.com/show_bug.cgi?id=2048394
f23e2a
https://bugzilla.redhat.com/show_bug.cgi?id=2033130
f23e2a
---
f23e2a
 libdnf/goal/Goal.cpp | 22 +++++++++++++++++++---
f23e2a
 1 file changed, 19 insertions(+), 3 deletions(-)
f23e2a
f23e2a
diff --git a/libdnf/goal/Goal.cpp b/libdnf/goal/Goal.cpp
f23e2a
index 2b698f7..ebe2fbd 100644
f23e2a
--- a/libdnf/goal/Goal.cpp
f23e2a
+++ b/libdnf/goal/Goal.cpp
f23e2a
@@ -835,8 +835,12 @@ Goal::exclude_from_weak_autodetect()
f23e2a
         installed_names.push_back(dnf_package_get_name(pkg));
f23e2a
         std::unique_ptr<libdnf::DependencyContainer> recommends(dnf_package_get_recommends(pkg));
f23e2a
         for (int i = 0; i < recommends->count(); ++i) {
f23e2a
-            Query query(base_query);
f23e2a
             std::unique_ptr<libdnf::Dependency> dep(recommends->getPtr(i));
f23e2a
+            const char * dep_string = dep->toString();
f23e2a
+            if (dep_string[0] == '(') {
f23e2a
+                continue;
f23e2a
+            }
f23e2a
+            Query query(base_query);
f23e2a
             const char * version = dep->getVersion();
f23e2a
             //  There can be installed provider in different version or upgraded packed can recommend a different version
f23e2a
             //  Ignore version and search only by reldep name
f23e2a
@@ -858,7 +862,7 @@ Goal::exclude_from_weak_autodetect()
f23e2a
         }
f23e2a
     }
f23e2a
 
f23e2a
-    // Invesigate supplements of only available packages with a different name to installed packages
f23e2a
+    // Investigate supplements of only available packages with a different name to installed packages
f23e2a
     installed_names.push_back(nullptr);
f23e2a
     base_query.addFilter(HY_PKG_NAME, HY_NEQ, installed_names.data());
f23e2a
     auto * available_pset = base_query.getResultPset();
f23e2a
@@ -870,8 +874,20 @@ Goal::exclude_from_weak_autodetect()
f23e2a
         if (supplements->count() == 0) {
f23e2a
             continue;
f23e2a
         }
f23e2a
+        libdnf::DependencyContainer supplements_without_rich(getSack());
f23e2a
+        for (int i = 0; i < supplements->count(); ++i) {
f23e2a
+            std::unique_ptr<libdnf::Dependency> dep(supplements->getPtr(i));
f23e2a
+            const char * dep_string = dep->toString();
f23e2a
+            if (dep_string[0] == '(') {
f23e2a
+                continue;
f23e2a
+            }
f23e2a
+            supplements_without_rich.add(dep.get());
f23e2a
+        }
f23e2a
+        if (supplements_without_rich.count() == 0) {
f23e2a
+            continue;
f23e2a
+        }
f23e2a
         Query query(installed_query);
f23e2a
-        query.addFilter(HY_PKG_PROVIDES, supplements.get());
f23e2a
+        query.addFilter(HY_PKG_PROVIDES, &supplements_without_rich);
f23e2a
         // When supplemented package already installed, exclude_from_weak available package
f23e2a
         if (!query.empty()) {
f23e2a
             add_exclude_from_weak(pkg);
f23e2a
--
f23e2a
libgit2 1.1.0
f23e2a