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

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