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