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

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