Blame SOURCES/0014-Revert-Adjust-modular-solver-to-new-context-type.patch

aea1e4
From 6c9540be5ac3e3bc3f9a60133b402945705b934f Mon Sep 17 00:00:00 2001
aea1e4
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
aea1e4
Date: Sun, 25 Apr 2021 19:47:53 +0200
aea1e4
Subject: [PATCH 14/19] Revert "Adjust modular solver to new context type"
aea1e4
aea1e4
This reverts commit 921d4db62cda41f7999aff67882ad0c01c766916.
aea1e4
---
aea1e4
 libdnf/module/ModulePackageContainer.cpp | 46 +++++-------------------
aea1e4
 1 file changed, 8 insertions(+), 38 deletions(-)
aea1e4
aea1e4
diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
aea1e4
index 6e6134d2..c0ad1260 100644
aea1e4
--- a/libdnf/module/ModulePackageContainer.cpp
aea1e4
+++ b/libdnf/module/ModulePackageContainer.cpp
aea1e4
@@ -49,28 +49,6 @@ extern "C" {
aea1e4
 #include "modulemd/ModuleMetadata.hpp"
aea1e4
 #include "modulemd/ModuleProfile.hpp"
aea1e4
 
aea1e4
-
aea1e4
-namespace {
aea1e4
-
aea1e4
-/// Requires resolved goal
aea1e4
-/// Takes listInstalls() from goal and keep solvables with the solvable-name (<name>:<stream>:<context>) in query 
aea1e4
-void goal2name_query(libdnf::Goal & goal, libdnf::Query & query)
aea1e4
-{
aea1e4
-    auto pool = dnf_sack_get_pool(goal.getSack());
aea1e4
-    auto installList = goal.listInstalls();
aea1e4
-    std::vector<const char *> module_names;
aea1e4
-    Id id = -1;
aea1e4
-    while ((id = installList.next(id)) != -1) {
aea1e4
-        Solvable * s = pool_id2solvable(pool, id);
aea1e4
-        const char * name = pool_id2str(pool, s->name);
aea1e4
-        module_names.push_back(name);
aea1e4
-    }
aea1e4
-    module_names.push_back(nullptr);
aea1e4
-    query.addFilter(HY_PKG_NAME, HY_EQ, module_names.data());
aea1e4
-}
aea1e4
-
aea1e4
-}
aea1e4
-
aea1e4
 namespace std {
aea1e4
 
aea1e4
 template<>
aea1e4
@@ -651,14 +629,14 @@ ModulePackageContainer::Impl::moduleSolve(const std::vector<ModulePackage *> & m
aea1e4
     for (const auto &module : modules) {
aea1e4
         std::ostringstream ss;
aea1e4
         auto name = module->getName();
aea1e4
-        ss << "module(" << name << ":" << module->getStream() << ")";
aea1e4
+        ss << "module(" << name << ":" << module->getStream() << ":" << module->getVersion() << ")";
aea1e4
         Selector selector(moduleSack);
aea1e4
         bool optional = persistor->getState(name) == ModuleState::DEFAULT;
aea1e4
         selector.set(HY_PKG_PROVIDES, HY_EQ, ss.str().c_str());
aea1e4
         goal.install(&selector, optional);
aea1e4
         goalWeak.install(&selector, true);
aea1e4
     }
aea1e4
-    auto ret = goal.run(static_cast<DnfGoalActions>(DNF_IGNORE_WEAK | DNF_FORCE_BEST));
aea1e4
+    auto ret = goal.run(DNF_IGNORE_WEAK);
aea1e4
     if (debugSolver) {
aea1e4
         goal.writeDebugdata("debugdata/modules");
aea1e4
     }
aea1e4
@@ -666,7 +644,7 @@ ModulePackageContainer::Impl::moduleSolve(const std::vector<ModulePackage *> & m
aea1e4
     auto problemType = ModulePackageContainer::ModuleErrorType::NO_ERROR;
aea1e4
     if (ret) {
aea1e4
         problems = goal.describeAllProblemRules(false);
aea1e4
-        ret = goal.run(DNF_FORCE_BEST);
aea1e4
+        ret = goal.run(DNF_NONE);
aea1e4
         if (ret) {
aea1e4
             // Conflicting modules has to be removed otherwice it could result than one of them will
aea1e4
             // be active
aea1e4
@@ -680,20 +658,14 @@ ModulePackageContainer::Impl::moduleSolve(const std::vector<ModulePackage *> & m
aea1e4
                 activatedModules.reset();
aea1e4
             } else {
aea1e4
                 problemType = ModulePackageContainer::ModuleErrorType::ERROR;
aea1e4
-                Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
aea1e4
-                goal2name_query(goalWeak, query);
aea1e4
-                activatedModules.reset(new PackageSet(*query.runSet()));
aea1e4
+                activatedModules.reset(new PackageSet(std::move(goalWeak.listInstalls())));
aea1e4
             }
aea1e4
         } else {
aea1e4
             problemType = ModulePackageContainer::ModuleErrorType::ERROR_IN_DEFAULTS;
aea1e4
-            Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
aea1e4
-            goal2name_query(goal, query);
aea1e4
-            activatedModules.reset(new PackageSet(*query.runSet()));
aea1e4
+            activatedModules.reset(new PackageSet(std::move(goal.listInstalls())));
aea1e4
         }
aea1e4
     } else {
aea1e4
-        Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
aea1e4
-        goal2name_query(goal, query);
aea1e4
-        activatedModules.reset(new PackageSet(*query.runSet()));
aea1e4
+        activatedModules.reset(new PackageSet(std::move(goal.listInstalls())));
aea1e4
     }
aea1e4
     return make_pair(problems, problemType);
aea1e4
 }
aea1e4
@@ -735,14 +707,12 @@ ModulePackageContainer::query(std::string name, std::string stream, std::string
aea1e4
     query.available();
aea1e4
     std::ostringstream ss;
aea1e4
     ss << stringFormater(name) << ":" << stringFormater(stream);
aea1e4
-    ss << ":" << stringFormater(context);
aea1e4
+    ss << ":" << stringFormater(version) << ":";
aea1e4
+    ss << stringFormater(context);
aea1e4
     query.addFilter(HY_PKG_NAME, HY_GLOB, ss.str().c_str());
aea1e4
     if (!arch.empty()) {
aea1e4
         query.addFilter(HY_PKG_ARCH, HY_GLOB, arch.c_str());
aea1e4
     }
aea1e4
-    if (!version.empty()) {
aea1e4
-        query.addFilter(HY_PKG_VERSION, HY_GLOB, version.c_str());
aea1e4
-    }
aea1e4
     auto pset = query.runSet();
aea1e4
     Id moduleId = -1;
aea1e4
     while ((moduleId = pset->next(moduleId)) != -1) {
aea1e4
-- 
aea1e4
2.31.1
aea1e4