dcavalca / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone

Blame SOURCES/0012-Revert-Add-compatible-layer-for-MdDocuments-v2.patch

2e24b4
From 833966d8a8a6c87a3d51447f2adf2aa76190ecd8 Mon Sep 17 00:00:00 2001
2e24b4
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
2e24b4
Date: Sun, 25 Apr 2021 19:47:53 +0200
2e24b4
Subject: [PATCH 12/19] Revert "Add compatible layer for MdDocuments v2"
2e24b4
2e24b4
This reverts commit 32ccf6743cb9ce1579ff88804855a94f30876860.
2e24b4
---
2e24b4
 libdnf/module/ModulePackageContainer.cpp  | 68 +----------------------
2e24b4
 libdnf/module/modulemd/ModuleMetadata.cpp | 11 +---
2e24b4
 libdnf/module/modulemd/ModuleMetadata.hpp |  2 +-
2e24b4
 3 files changed, 4 insertions(+), 77 deletions(-)
2e24b4
2e24b4
diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
2e24b4
index 3f30037e..6e6134d2 100644
2e24b4
--- a/libdnf/module/ModulePackageContainer.cpp
2e24b4
+++ b/libdnf/module/ModulePackageContainer.cpp
2e24b4
@@ -69,23 +69,6 @@ void goal2name_query(libdnf::Goal & goal, libdnf::Query & query)
2e24b4
     query.addFilter(HY_PKG_NAME, HY_EQ, module_names.data());
2e24b4
 }
2e24b4
 
2e24b4
-/**
2e24b4
- * @brief In python => ";".join(list.sort())
2e24b4
- */
2e24b4
-std::string concentrateVectorString(std::vector<std::string> & list)
2e24b4
-{
2e24b4
-    if (list.empty()) {
2e24b4
-        return {};
2e24b4
-    }
2e24b4
-    std::sort(list.begin(), list.end());
2e24b4
-    std::ostringstream ss;
2e24b4
-    ss << *list.begin();
2e24b4
-    for (auto require = std::next(list.begin()); require != list.end(); ++require) {
2e24b4
-        ss << ";" << *require;
2e24b4
-    }
2e24b4
-    return ss.str();
2e24b4
-}
2e24b4
-
2e24b4
 }
2e24b4
 
2e24b4
 namespace std {
2e24b4
@@ -189,8 +172,6 @@ public:
2e24b4
         const std::vector<ModulePackage *> & modules, bool debugSolver);
2e24b4
     bool insert(const std::string &moduleName, const char *path);
2e24b4
     std::vector<ModulePackage *> getLatestActiveEnabledModules();
2e24b4
-    /// Required to call after all modules v3 are in metadata
2e24b4
-    void addVersion2Modules();
2e24b4
 
2e24b4
 private:
2e24b4
     friend struct ModulePackageContainer;
2e24b4
@@ -204,8 +185,6 @@ private:
2e24b4
     ModuleMetadata moduleMetadata;
2e24b4
 
2e24b4
     std::map<std::string, std::string> moduleDefaults;
2e24b4
-    std::vector<std::tuple<LibsolvRepo *, ModulemdModuleStream *, std::string>> modulesV2;
2e24b4
-
2e24b4
     bool isEnabled(const std::string &name, const std::string &stream);
2e24b4
 };
2e24b4
 
2e24b4
@@ -339,7 +318,6 @@ ModulePackageContainer::add(DnfSack * sack)
2e24b4
                             exception.what()));
2e24b4
         }
2e24b4
     }
2e24b4
-    pImpl->addVersion2Modules();
2e24b4
 }
2e24b4
 
2e24b4
 void ModulePackageContainer::addDefaultsFromDisk()
2e24b4
@@ -375,7 +353,7 @@ ModulePackageContainer::add(const std::string &fileContent, const std::string &
2e24b4
         if (strcmp(r->name, "available") == 0) {
2e24b4
             g_autofree gchar * path = g_build_filename(pImpl->installRoot.c_str(),
2e24b4
                                                       "/etc/dnf/modules.d", NULL);
2e24b4
-            auto packages = md.getAllModulePackages(pImpl->moduleSack, r, repoID, pImpl->modulesV2);
2e24b4
+            std::vector<ModulePackage *> packages = md.getAllModulePackages(pImpl->moduleSack, r, repoID);
2e24b4
             for(auto const& modulePackagePtr: packages) {
2e24b4
                 std::unique_ptr<ModulePackage> modulePackage(modulePackagePtr);
2e24b4
                 pImpl->modules.insert(std::make_pair(modulePackage->getId(), std::move(modulePackage)));
2e24b4
@@ -1701,50 +1679,6 @@ std::vector<ModulePackage *> ModulePackageContainer::Impl::getLatestActiveEnable
2e24b4
     return latest;
2e24b4
 }
2e24b4
 
2e24b4
-void ModulePackageContainer::Impl::addVersion2Modules()
2e24b4
-{
2e24b4
-    if (modulesV2.empty()) {
2e24b4
-        return;
2e24b4
-    }
2e24b4
-    std::map<std::string, std::map<std::string, std::vector<ModulePackage *>>> v3_context_map;
2e24b4
-    for (auto const & module_pair : modules) {
2e24b4
-        auto * module = module_pair.second.get();
2e24b4
-        auto requires = module->getRequires(true);
2e24b4
-        auto concentratedRequires = concentrateVectorString(requires);
2e24b4
-        v3_context_map[module->getNameStream()][concentratedRequires].push_back(module);
2e24b4
-    }
2e24b4
-    libdnf::LibsolvRepo * repo;
2e24b4
-    ModulemdModuleStream * mdStream;
2e24b4
-    std::string repoID;
2e24b4
-    g_autofree gchar * path = g_build_filename(installRoot.c_str(), "/etc/dnf/modules.d", NULL);
2e24b4
-    for (auto & module_tuple : modulesV2) {
2e24b4
-        std::tie(repo, mdStream, repoID) = module_tuple;
2e24b4
-        auto nameStream = ModulePackage::getNameStream(mdStream);
2e24b4
-        auto requires = ModulePackage::getRequires(mdStream, true);
2e24b4
-        auto concentratedRequires = concentrateVectorString(requires);
2e24b4
-        auto streamIterator = v3_context_map.find(nameStream);
2e24b4
-        if (streamIterator != v3_context_map.end()) {
2e24b4
-            auto contextIterator = streamIterator->second.find(concentratedRequires);
2e24b4
-            if (contextIterator != streamIterator->second.end()) {
2e24b4
-                auto v3_context = contextIterator->second[0]->getContext();
2e24b4
-                std::unique_ptr<ModulePackage> modulePackage(new ModulePackage(moduleSack, repo, mdStream, repoID, v3_context));
2e24b4
-                persistor->insert(modulePackage->getName(), path);
2e24b4
-                modules.insert(std::make_pair(modulePackage->getId(), std::move(modulePackage)));
2e24b4
-                g_object_unref(mdStream);
2e24b4
-                continue;
2e24b4
-            }
2e24b4
-        }
2e24b4
-        if (concentratedRequires.empty()) {
2e24b4
-            concentratedRequires.append("NoRequires");
2e24b4
-        }
2e24b4
-        std::unique_ptr<ModulePackage> modulePackage(new ModulePackage(moduleSack, repo, mdStream, repoID, concentratedRequires));
2e24b4
-        persistor->insert(modulePackage->getName(), path);
2e24b4
-        modules.insert(std::make_pair(modulePackage->getId(), std::move(modulePackage)));
2e24b4
-        g_object_unref(mdStream);
2e24b4
-    }
2e24b4
-    modulesV2.clear();
2e24b4
-}
2e24b4
-
2e24b4
 void ModulePackageContainer::updateFailSafeData()
2e24b4
 {
2e24b4
     auto fileNames = getYamlFilenames(pImpl->persistDir.c_str());
2e24b4
diff --git a/libdnf/module/modulemd/ModuleMetadata.cpp b/libdnf/module/modulemd/ModuleMetadata.cpp
2e24b4
index 07817ce1..fbdd8a13 100644
2e24b4
--- a/libdnf/module/modulemd/ModuleMetadata.cpp
2e24b4
+++ b/libdnf/module/modulemd/ModuleMetadata.cpp
2e24b4
@@ -126,8 +126,7 @@ void ModuleMetadata::resolveAddedMetadata()
2e24b4
 
2e24b4
 std::vector<ModulePackage *> ModuleMetadata::getAllModulePackages(DnfSack * moduleSack,
2e24b4
                                                                   LibsolvRepo * repo,
2e24b4
-                                                                  const std::string & repoID,
2e24b4
-                                                                  std::vector<std::tuple<LibsolvRepo *, ModulemdModuleStream *, std::string>> & modulesV2)
2e24b4
+                                                                  const std::string & repoID)
2e24b4
 {
2e24b4
     std::vector<ModulePackage *> result;
2e24b4
     if (!resultingModuleIndex)
2e24b4
@@ -141,13 +140,7 @@ std::vector<ModulePackage *> ModuleMetadata::getAllModulePackages(DnfSack * modu
2e24b4
         //TODO(amatej): replace with
2e24b4
         //GPtrArray * streams = modulemd_module_index_search_streams_by_nsvca_glob(resultingModuleIndex, NULL);
2e24b4
         for (unsigned int i = 0; i < streams->len; i++){
2e24b4
-            ModulemdModuleStream * moduleMdStream = static_cast<ModulemdModuleStream *>(g_ptr_array_index(streams, i));
2e24b4
-            if (modulemd_module_stream_get_mdversion(moduleMdStream) > 2) {
2e24b4
-                result.push_back(new ModulePackage(moduleSack, repo, moduleMdStream, repoID));
2e24b4
-            } else {
2e24b4
-                g_object_ref(moduleMdStream);
2e24b4
-                modulesV2.push_back(std::make_tuple(repo, moduleMdStream, repoID));
2e24b4
-            }
2e24b4
+            result.push_back(new ModulePackage(moduleSack, repo, (ModulemdModuleStream *) g_ptr_array_index(streams, i), repoID));
2e24b4
         }
2e24b4
     }
2e24b4
 
2e24b4
diff --git a/libdnf/module/modulemd/ModuleMetadata.hpp b/libdnf/module/modulemd/ModuleMetadata.hpp
2e24b4
index 901d7402..df753b11 100644
2e24b4
--- a/libdnf/module/modulemd/ModuleMetadata.hpp
2e24b4
+++ b/libdnf/module/modulemd/ModuleMetadata.hpp
2e24b4
@@ -36,7 +36,7 @@ public:
2e24b4
     ~ModuleMetadata();
2e24b4
     void addMetadataFromString(const std::string & yaml, int priority);
2e24b4
     void resolveAddedMetadata();
2e24b4
-    std::vector<ModulePackage *> getAllModulePackages(DnfSack * moduleSack, LibsolvRepo * repo, const std::string & repoID, std::vector<std::tuple<LibsolvRepo *, ModulemdModuleStream *, std::string>> & modulesV2);
2e24b4
+    std::vector<ModulePackage *> getAllModulePackages(DnfSack * moduleSack, LibsolvRepo * repo, const std::string & repoID);
2e24b4
     std::map<std::string, std::string> getDefaultStreams();
2e24b4
     std::vector<std::string> getDefaultProfiles(std::string moduleName, std::string moduleStream);
2e24b4
     ModulemdObsoletes * getNewestActiveObsolete(ModulePackage *p);
2e24b4
-- 
2e24b4
2.31.1
2e24b4