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