diff --git a/.gitignore b/.gitignore
index ce72cd2..84049ca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-SOURCES/libdnf-0.55.0.tar.gz
+SOURCES/libdnf-0.63.0.tar.gz
diff --git a/.libdnf.metadata b/.libdnf.metadata
index 85f3501..c25c067 100644
--- a/.libdnf.metadata
+++ b/.libdnf.metadata
@@ -1 +1 @@
-5d997c2c7113cd50af986ada5ff10a62853f1943 SOURCES/libdnf-0.55.0.tar.gz
+5bb88aae1c1b8c104e34916c7509b04fcf7b4de9 SOURCES/libdnf-0.63.0.tar.gz
diff --git a/SOURCES/0001-Better-msgs-if-basecachedir-or-proxy-password-isn-t-set-RhBug-1888946.patch b/SOURCES/0001-Better-msgs-if-basecachedir-or-proxy-password-isn-t-set-RhBug-1888946.patch
deleted file mode 100644
index 7666421..0000000
--- a/SOURCES/0001-Better-msgs-if-basecachedir-or-proxy-password-isn-t-set-RhBug-1888946.patch
+++ /dev/null
@@ -1,87 +0,0 @@
-From 2353dfbcb49a16bd37115915517417678fe49b19 Mon Sep 17 00:00:00 2001
-From: Jaroslav Rohel <jrohel@redhat.com>
-Date: Fri, 13 Nov 2020 09:55:23 +0100
-Subject: [PATCH] Better msgs if "basecachedir" or "proxy_password" isn't set
- (RhBug:1888946)
-
-Generates more specific error messages:
-- repo '%s': 'basecachedir' is not set
-- repo '%s': 'proxy_username' is set but not 'proxy_password'
-- 'proxy_username' is set but not 'proxy_password'
-instead of generic "GetValue(): Value not set"
----
- libdnf/repo/Repo.cpp | 24 ++++++++++++++++++++++--
- 1 file changed, 22 insertions(+), 2 deletions(-)
-
-diff --git a/libdnf/repo/Repo.cpp b/libdnf/repo/Repo.cpp
-index d7c137d75..34539e1ee 100644
---- a/libdnf/repo/Repo.cpp
-+++ b/libdnf/repo/Repo.cpp
-@@ -484,8 +484,12 @@ std::unique_ptr<LrHandle> Repo::Impl::lrHandleInitLocal()
-     handleSetOpt(h.get(), LRO_LOCAL, 1L);
- #ifdef LRO_SUPPORTS_CACHEDIR
-     /* If zchunk is enabled, set librepo cache dir */
--    if (conf->getMasterConfig().zchunk().getValue())
-+    if (conf->getMasterConfig().zchunk().getValue()) {
-+        if (conf->basecachedir().empty()) {
-+            throw Exception(tfm::format(_("repo '%s': 'basecachedir' is not set"), id));
-+        }
-         handleSetOpt(h.get(), LRO_CACHEDIR, conf->basecachedir().getValue().c_str());
-+    }
- #endif
-     return h;
- }
-@@ -526,6 +530,9 @@ std::unique_ptr<LrHandle> Repo::Impl::lrHandleInitRemote(const char *destdir)
-                 handleSetOpt(h.get(), LRO_METALINKURL, tmp.c_str());
-         }
-         handleSetOpt(h.get(), LRO_FASTESTMIRROR, conf->fastestmirror().getValue() ? 1L : 0L);
-+        if (conf->basecachedir().empty()) {
-+            throw Exception(tfm::format(_("repo '%s': 'basecachedir' is not set"), id));
-+        }
-         auto fastestMirrorCacheDir = conf->basecachedir().getValue();
-         if (fastestMirrorCacheDir.back() != '/')
-             fastestMirrorCacheDir.push_back('/');
-@@ -569,8 +576,12 @@ std::unique_ptr<LrHandle> Repo::Impl::lrHandleInitRemote(const char *destdir)
- 
- #ifdef LRO_SUPPORTS_CACHEDIR
-     /* If zchunk is enabled, set librepo cache dir */
--    if (conf->getMasterConfig().zchunk().getValue())
-+    if (conf->getMasterConfig().zchunk().getValue()) {
-+        if (conf->basecachedir().empty()) {
-+            throw Exception(tfm::format(_("repo '%s': 'basecachedir' is not set"), id));
-+        }
-         handleSetOpt(h.get(), LRO_CACHEDIR, conf->basecachedir().getValue().c_str());
-+    }
- #endif
- 
-     auto minrate = conf->minrate().getValue();
-@@ -610,6 +621,9 @@ std::unique_ptr<LrHandle> Repo::Impl::lrHandleInitRemote(const char *destdir)
-     if (!conf->proxy_username().empty()) {
-         userpwd = conf->proxy_username().getValue();
-         if (!userpwd.empty()) {
-+            if (conf->proxy_password().empty()) {
-+                throw RepoError(tfm::format(_("repo '%s': 'proxy_username' is set but not 'proxy_password'"), id));
-+            }
-             userpwd = formatUserPassString(userpwd, conf->proxy_password().getValue(), true);
-             handleSetOpt(h.get(), LRO_PROXYUSERPWD, userpwd.c_str());
-         }
-@@ -1346,6 +1360,9 @@ std::string Repo::Impl::getHash() const
- 
- std::string Repo::Impl::getCachedir() const
- {
-+    if (conf->basecachedir().empty()) {
-+        throw Exception(tfm::format(_("repo '%s': 'basecachedir' is not set"), id));
-+    }
-     auto repodir(conf->basecachedir().getValue());
-     if (repodir.back() != '/')
-         repodir.push_back('/');
-@@ -1690,6 +1707,9 @@ static LrHandle * newHandle(ConfigMain * conf)
-         if (!conf->proxy_username().empty()) {
-             auto userpwd = conf->proxy_username().getValue();
-             if (!userpwd.empty()) {
-+                if (conf->proxy_password().empty()) {
-+                    throw RepoError(_("'proxy_username' is set but not 'proxy_password'"));
-+                }
-                 userpwd = formatUserPassString(userpwd, conf->proxy_password().getValue(), true);
-                 handleSetOpt(h, LRO_PROXYUSERPWD, userpwd.c_str());
-             }
diff --git a/SOURCES/0001-Revert-Improve-performance-for-module-query.patch b/SOURCES/0001-Revert-Improve-performance-for-module-query.patch
new file mode 100644
index 0000000..87252e8
--- /dev/null
+++ b/SOURCES/0001-Revert-Improve-performance-for-module-query.patch
@@ -0,0 +1,32 @@
+From 293e10c58dadc023070f959b08999b6bc2efb1b2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:51 +0200
+Subject: [PATCH 01/19] Revert "Improve performance for module query"
+
+This reverts commit 38942d42b6980216e5d5e2e5798664cd08deb3ba.
+---
+ libdnf/module/ModulePackageContainer.cpp | 8 +++-----
+ 1 file changed, 3 insertions(+), 5 deletions(-)
+
+diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
+index 1d5070ca..edb7e9ec 100644
+--- a/libdnf/module/ModulePackageContainer.cpp
++++ b/libdnf/module/ModulePackageContainer.cpp
+@@ -775,11 +775,9 @@ ModulePackageContainer::query(std::string name, std::string stream, std::string
+     Query query(pImpl->moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
+     // platform modules are installed and not in modules std::Map.
+     query.available();
+-    if (!name.empty() || !stream.empty()) {
+-        std::ostringstream ss;
+-        ss << stringFormater(name) << ":" << stringFormater(stream);
+-        query.addFilter(HY_PKG_DESCRIPTION, HY_GLOB, ss.str().c_str());
+-    }
++    std::ostringstream ss;
++    ss << stringFormater(name) << ":" << stringFormater(stream);
++    query.addFilter(HY_PKG_DESCRIPTION, HY_GLOB, ss.str().c_str());
+     if (!context.empty()) {
+         query.addFilter(HY_PKG_SUMMARY, HY_GLOB, context.c_str());
+     }
+-- 
+2.31.1
+
diff --git a/SOURCES/0002-Revert-Enhance-description-of-modular-solvables.patch b/SOURCES/0002-Revert-Enhance-description-of-modular-solvables.patch
new file mode 100644
index 0000000..905ca45
--- /dev/null
+++ b/SOURCES/0002-Revert-Enhance-description-of-modular-solvables.patch
@@ -0,0 +1,26 @@
+From fe466856f54ed2cd261a863b2c929a064ae5e945 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:51 +0200
+Subject: [PATCH 02/19] Revert "Enhance description of modular solvables"
+
+This reverts commit 943d9a1ba905f2e10975b16edff0684964c135b6.
+---
+ libdnf/module/ModulePackage.cpp | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/libdnf/module/ModulePackage.cpp b/libdnf/module/ModulePackage.cpp
+index 3757f6ad..d0017877 100644
+--- a/libdnf/module/ModulePackage.cpp
++++ b/libdnf/module/ModulePackage.cpp
+@@ -50,8 +50,6 @@ namespace libdnf {
+  *   Arch: $arch (If arch is not defined, set "noarch")
+  *   Provides: module($name)
+  *   Provides: module($name:$stream)
+- *   Summary: original_context
+- *   Description: name:stream
+  */
+ static void setSovable(Pool * pool, Solvable * solvable, const std::string & name,
+     const std::string & stream, const std::string & version, const std::string & context, const char * arch, const std::string & original_context)
+-- 
+2.31.1
+
diff --git a/SOURCES/0002-modules-Add-special-handling-for-src-artifacts-RhBug-1809314.patch b/SOURCES/0002-modules-Add-special-handling-for-src-artifacts-RhBug-1809314.patch
deleted file mode 100644
index a16d544..0000000
--- a/SOURCES/0002-modules-Add-special-handling-for-src-artifacts-RhBug-1809314.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From 71db968178e5d8cd4c01ed36fa940c2a95f3e494 Mon Sep 17 00:00:00 2001
-From: Jaroslav Mracek <jmracek@redhat.com>
-Date: Mon, 9 Nov 2020 18:10:37 +0100
-Subject: [PATCH] [modules] Add special handling for src artifacts
- (RhBug:1809314)
-
-Source packages are special because they cannot be installed and provide
-nothing, therefore they should be handled by a different way than binary
-packages. Source rpm should not trigger a removal of binary packages.
----
- libdnf/dnf-sack.cpp | 22 +++++++++++++++++++---
- 1 file changed, 19 insertions(+), 3 deletions(-)
-
-diff --git a/libdnf/dnf-sack.cpp b/libdnf/dnf-sack.cpp
-index 9fd2c72d1..d44e1d86d 100644
---- a/libdnf/dnf-sack.cpp
-+++ b/libdnf/dnf-sack.cpp
-@@ -2335,20 +2335,29 @@ setModuleExcludes(DnfSack *sack, const char ** hotfixRepos,
- {
-     dnf_sack_set_module_excludes(sack, nullptr);
-     std::vector<std::string> names;
-+    std::vector<std::string> srcNames;
-     libdnf::DependencyContainer nameDependencies{sack};
-     libdnf::Nevra nevra;
-     for (const auto &rpm : includeNEVRAs) {
-         if (nevra.parse(rpm.c_str(), HY_FORM_NEVRA)) {
--            names.push_back(nevra.getName());
--            nameDependencies.addReldep(nevra.getName().c_str());
-+            auto arch = nevra.getArch();
-+            // source packages do not provide anything and must not cause excluding binary packages
-+            if (arch == "src" || arch == "nosrc") {
-+                srcNames.push_back(nevra.getName());
-+            } else {
-+                names.push_back(nevra.getName());
-+                nameDependencies.addReldep(nevra.getName().c_str());
-+            }
-         }
-     }
- 
-     std::vector<const char *> namesCString(names.size() + 1);
-+    std::vector<const char *> srcNamesCString(srcNames.size() + 1);
-     std::vector<const char *> excludeNEVRAsCString(excludeNEVRAs.size() + 1);
-     std::vector<const char *> includeNEVRAsCString(includeNEVRAs.size() + 1);
- 
-     transform(names.begin(), names.end(), namesCString.begin(), std::mem_fn(&std::string::c_str));
-+    transform(srcNames.begin(), srcNames.end(), srcNamesCString.begin(), std::mem_fn(&std::string::c_str));
-     transform(excludeNEVRAs.begin(), excludeNEVRAs.end(), excludeNEVRAsCString.begin(),
-               std::mem_fn(&std::string::c_str));
-     transform(includeNEVRAs.begin(), includeNEVRAs.end(), includeNEVRAsCString.begin(),
-@@ -2363,6 +2372,7 @@ setModuleExcludes(DnfSack *sack, const char ** hotfixRepos,
-     libdnf::Query excludeQuery{keepPackages};
-     libdnf::Query excludeProvidesQuery{keepPackages};
-     libdnf::Query excludeNamesQuery(keepPackages);
-+    libdnf::Query excludeSrcNamesQuery(keepPackages);
-     includeQuery.addFilter(HY_PKG_NEVRA_STRICT, HY_EQ, includeNEVRAsCString.data());
- 
-     excludeQuery.addFilter(HY_PKG_NEVRA_STRICT, HY_EQ, excludeNEVRAsCString.data());
-@@ -2372,8 +2382,14 @@ setModuleExcludes(DnfSack *sack, const char ** hotfixRepos,
-     excludeProvidesQuery.addFilter(HY_PKG_PROVIDES, &nameDependencies);
-     excludeProvidesQuery.queryDifference(includeQuery);
- 
--    // Requred to filtrate out source packages and packages with incompatible architectures
-+    // Search for source packages with same names as included source artifacts
-+    excludeSrcNamesQuery.addFilter(HY_PKG_NAME, HY_EQ, srcNamesCString.data());
-+    const char * srcArchs[] = {"src", "nosrc", nullptr};
-+    excludeSrcNamesQuery.addFilter(HY_PKG_ARCH, HY_EQ, srcArchs);
-+
-+    // Required to filtrate out source packages and packages with incompatible architectures
-     excludeNamesQuery.addFilter(HY_PKG_NAME, HY_EQ, namesCString.data());
-+    excludeNamesQuery.queryUnion(excludeSrcNamesQuery);
-     excludeNamesQuery.queryDifference(includeQuery);
- 
-     dnf_sack_set_module_excludes(sack, excludeQuery.getResultPset());
diff --git a/SOURCES/0003-Avoid-multilib-file-conflict-in-config.h-RhBug-1918818.patch b/SOURCES/0003-Avoid-multilib-file-conflict-in-config.h-RhBug-1918818.patch
deleted file mode 100644
index ae93fb0..0000000
--- a/SOURCES/0003-Avoid-multilib-file-conflict-in-config.h-RhBug-1918818.patch
+++ /dev/null
@@ -1,101 +0,0 @@
-From 3f6adc99506f065d0858e4d9d46055be9d070634 Mon Sep 17 00:00:00 2001
-From: Nicola Sella <nsella@redhat.com>
-Date: Fri, 22 Jan 2021 16:07:37 +0100
-Subject: [PATCH] Avoid multilib file conflict in config.h (RhBug:1918818)
-
-=changelog=
-msg: Avoid multilib file conflicts in config.h
-resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1918818
----
- .gitignore                             |  2 +-
- libdnf/CMakeLists.txt                  |  8 ++++++-
- libdnf/{config.h.in => config-64.h.in} |  6 +++---
- libdnf/config.h                        | 29 ++++++++++++++++++++++++++
- 4 files changed, 40 insertions(+), 5 deletions(-)
- rename libdnf/{config.h.in => config-64.h.in} (87%)
- create mode 100644 libdnf/config.h
-
-diff --git a/.gitignore b/.gitignore
-index e17a9b9bb..0a63bdae7 100644
---- a/.gitignore
-+++ b/.gitignore
-@@ -5,4 +5,4 @@
- build
- *.pyc
- data/tests/modules/yum.repos.d/test.repo
--libdnf/config.h
-+libdnf/config-64.h
-diff --git a/libdnf/CMakeLists.txt b/libdnf/CMakeLists.txt
-index e82aac11e..25f33d7b0 100644
---- a/libdnf/CMakeLists.txt
-+++ b/libdnf/CMakeLists.txt
-@@ -35,7 +35,13 @@ set(LIBDNF_SRCS
- include_directories(transaction)
- add_subdirectory("transaction")
- 
--configure_file("config.h.in" ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
-+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
-+    set(MULTILIB_ARCH "64")
-+    configure_file("config-64.h.in" ${CMAKE_CURRENT_SOURCE_DIR}/config-64.h)
-+elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
-+    set(MULTILIB_ARCH "32")
-+    configure_file("config-64.h.in" ${CMAKE_CURRENT_SOURCE_DIR}/config-32.h)
-+endif()
- configure_file("dnf-version.h.in"  ${CMAKE_CURRENT_SOURCE_DIR}/dnf-version.h)
- configure_file("libdnf.pc.in" ${CMAKE_CURRENT_BINARY_DIR}/libdnf.pc @ONLY)
- 
-diff --git a/libdnf/config.h.in b/libdnf/config-64.h.in
-similarity index 87%
-rename from libdnf/config.h.in
-rename to libdnf/config-64.h.in
-index 77974f757..e2329fe71 100644
---- a/libdnf/config.h.in
-+++ b/libdnf/config-64.h.in
-@@ -18,9 +18,9 @@
-  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-  */
- 
--#ifndef _LIBDNF_CONFIG_H_
--#define _LIBDNF_CONFIG_H_
-+#ifndef _LIBDNF_CONFIG_@MULTILIB_ARCH@_H_
-+#define _LIBDNF_CONFIG_@MULTILIB_ARCH@_H_
- 
- #define DEFAULT_PLUGINS_DIRECTORY "@CMAKE_INSTALL_FULL_LIBDIR@/libdnf/plugins/"
- 
--#endif // _LIBDNF_CONFIG_H_
-+#endif // _LIBDNF_CONFIG_@MULTILIB_ARCH@_H_
-diff --git a/libdnf/config.h b/libdnf/config.h
-new file mode 100644
-index 000000000..16121f6f5
---- /dev/null
-+++ b/libdnf/config.h
-@@ -0,0 +1,29 @@
-+/*
-+ * Copyright (C) 2018 Red Hat, Inc.
-+ *
-+ * Licensed under the GNU Lesser General Public License Version 2.1
-+ *
-+ * This library is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU Lesser General Public
-+ * License as published by the Free Software Foundation; either
-+ * version 2.1 of the License, or (at your option) any later version.
-+ *
-+ * This library is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+ * Lesser General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU Lesser General Public
-+ * License along with this library; if not, write to the Free Software
-+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-+ */
-+
-+#include <bits/wordsize.h>
-+
-+#if __WORDSIZE == 32
-+#include "config-32.h"
-+#elif __WORDSIZE == 64
-+#include "config-64.h"
-+#else
-+#error "Unknown word size"
-+#endif
diff --git a/SOURCES/0003-Revert-Fix-typo-lates-latest.patch b/SOURCES/0003-Revert-Fix-typo-lates-latest.patch
new file mode 100644
index 0000000..6ec9672
--- /dev/null
+++ b/SOURCES/0003-Revert-Fix-typo-lates-latest.patch
@@ -0,0 +1,26 @@
+From adf159cce65fa5b15f81dd3ee319e551f01def1a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:51 +0200
+Subject: [PATCH 03/19] Revert "Fix typo: lates -> latest"
+
+This reverts commit 2a7a315cda61355d60fc0dd0fae9ccd48079a9c5.
+---
+ libdnf/dnf-context.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libdnf/dnf-context.cpp b/libdnf/dnf-context.cpp
+index 926681c2..ccb6fe83 100644
+--- a/libdnf/dnf-context.cpp
++++ b/libdnf/dnf-context.cpp
+@@ -3253,7 +3253,7 @@ report_problems(const std::vector<std::tuple<libdnf::ModulePackageContainer::Mod
+                 logger->warning(tfm::format(_("Modular dependency problem with Defaults: %s"), report.c_str()));
+                 break;
+             case libdnf::ModulePackageContainer::ModuleErrorType::ERROR_IN_LATEST:
+-                logger->warning(tfm::format(_("Modular dependency problem with the latest modules: %s"),
++                logger->warning(tfm::format(_("Modular dependency problem with the lates modules: %s"),
+                                             report.c_str()));
+                 break;
+             case libdnf::ModulePackageContainer::ModuleErrorType::ERROR:
+-- 
+2.31.1
+
diff --git a/SOURCES/0004-Revert-Remove-unused-code-bump-version.patch b/SOURCES/0004-Revert-Remove-unused-code-bump-version.patch
new file mode 100644
index 0000000..a662d3d
--- /dev/null
+++ b/SOURCES/0004-Revert-Remove-unused-code-bump-version.patch
@@ -0,0 +1,39 @@
+From 291f0393b54b31228c7a4c8c112003b64632967b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:52 +0200
+Subject: [PATCH 04/19] Revert "Remove unused code bump version"
+
+This reverts commit f0fde46c42f2424135617b29fdfbcbf9e17fc79a.
+---
+ libdnf/module/ModulePackageContainer.cpp | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
+index edb7e9ec..1bfdd8c1 100644
+--- a/libdnf/module/ModulePackageContainer.cpp
++++ b/libdnf/module/ModulePackageContainer.cpp
+@@ -1014,6 +1014,21 @@ modulePackageLatestPerRepoSorter(DnfSack * sack, const ModulePackage * first, co
+     return first->getVersionNum() > second->getVersionNum();
+ }
+ 
++static bool
++modulePackageLatestSorter(DnfSack * sack, const ModulePackage * first, const ModulePackage * second)
++{
++    int cmp = g_strcmp0(first->getNameCStr(), second->getNameCStr());
++    if (cmp != 0)
++        return cmp < 0;
++    cmp = dnf_sack_evr_cmp(sack, first->getStreamCStr(), second->getStreamCStr());
++    if (cmp != 0)
++        return cmp < 0;
++    cmp = g_strcmp0(first->getArchCStr(), second->getArchCStr());
++    if (cmp != 0)
++        return cmp < 0;
++    return first->getVersionNum() > second->getVersionNum();
++}
++
+ std::vector<std::vector<std::vector<ModulePackage *>>>
+ ModulePackageContainer::getLatestModulesPerRepo(ModuleState moduleFilter,
+     std::vector<ModulePackage *> modulePackages)
+-- 
+2.31.1
+
diff --git a/SOURCES/0004-context-improve-retrieving-repository-configuration.patch b/SOURCES/0004-context-improve-retrieving-repository-configuration.patch
deleted file mode 100644
index 79bdeff..0000000
--- a/SOURCES/0004-context-improve-retrieving-repository-configuration.patch
+++ /dev/null
@@ -1,1136 +0,0 @@
-From be8449aa177473a834a5b2c401a8a3fcc61522b4 Mon Sep 17 00:00:00 2001
-From: Jaroslav Rohel <jrohel@redhat.com>
-Date: Wed, 2 Dec 2020 08:00:07 +0100
-Subject: [PATCH 1/9] Option: Add reset() method
-
-The method resets the option to its initial state.
-Can be used, for example, before reloading the configuration in daemon
-mode (PackageKit).
----
- libdnf/conf/Option.hpp           |  2 ++
- libdnf/conf/OptionBool.hpp       |  9 ++++++++-
- libdnf/conf/OptionChild.hpp      | 14 ++++++++++++++
- libdnf/conf/OptionEnum.hpp       | 15 +++++++++++++++
- libdnf/conf/OptionNumber.hpp     | 10 +++++++++-
- libdnf/conf/OptionString.cpp     | 11 ++++++++---
- libdnf/conf/OptionString.hpp     |  8 ++++++++
- libdnf/conf/OptionStringList.hpp |  9 ++++++++-
- 8 files changed, 72 insertions(+), 6 deletions(-)
-
-diff --git a/libdnf/conf/Option.hpp b/libdnf/conf/Option.hpp
-index e9a9dfc84..849871fe7 100644
---- a/libdnf/conf/Option.hpp
-+++ b/libdnf/conf/Option.hpp
-@@ -62,6 +62,8 @@ class Option {
-     virtual void set(Priority priority, const std::string & value) = 0;
-     virtual std::string getValueString() const = 0;
-     virtual bool empty() const noexcept;
-+    /// Resets the option to its initial state.
-+    virtual void reset() = 0;
-     virtual ~Option() = default;
- 
- protected:
-diff --git a/libdnf/conf/OptionBool.hpp b/libdnf/conf/OptionBool.hpp
-index c27ab0b79..a5e647807 100644
---- a/libdnf/conf/OptionBool.hpp
-+++ b/libdnf/conf/OptionBool.hpp
-@@ -47,6 +47,7 @@ class OptionBool : public Option {
-     std::string getValueString() const override;
-     const char * const * getTrueValues() const noexcept;
-     const char * const * getFalseValues() const noexcept;
-+    void reset() override;
- 
- protected:
-     const char * const * const trueValues;
-@@ -84,7 +85,13 @@ inline const char * const * OptionBool::getTrueValues() const noexcept
- 
- inline const char * const * OptionBool::getFalseValues() const noexcept
- {
--    return falseValues ? falseValues : defFalseValues; 
-+    return falseValues ? falseValues : defFalseValues;
-+}
-+
-+inline void OptionBool::reset()
-+{
-+    value = defaultValue;
-+    priority = Priority::DEFAULT;
- }
- 
- }
-diff --git a/libdnf/conf/OptionChild.hpp b/libdnf/conf/OptionChild.hpp
-index 5d1503cb6..3056345f9 100644
---- a/libdnf/conf/OptionChild.hpp
-+++ b/libdnf/conf/OptionChild.hpp
-@@ -39,6 +39,7 @@ class OptionChild : public Option {
-     const typename ParentOptionType::ValueType getDefaultValue() const;
-     std::string getValueString() const override;
-     bool empty() const noexcept override;
-+    void reset() override;
- 
- private:
-     const ParentOptionType * parent;
-@@ -56,6 +57,7 @@ class OptionChild<ParentOptionType, typename std::enable_if<std::is_same<typenam
-     const std::string & getDefaultValue() const;
-     std::string getValueString() const override;
-     bool empty() const noexcept override;
-+    void reset() override;
- 
- private:
-     const ParentOptionType * parent;
-@@ -119,6 +121,12 @@ inline bool OptionChild<ParentOptionType, Enable>::empty() const noexcept
-     return priority == Priority::EMPTY && parent->empty();
- }
- 
-+template <class ParentOptionType, class Enable>
-+inline void OptionChild<ParentOptionType, Enable>::reset()
-+{
-+    priority = Priority::EMPTY;
-+}
-+
- template <class ParentOptionType>
- inline OptionChild<ParentOptionType, typename std::enable_if<std::is_same<typename ParentOptionType::ValueType, std::string>::value>::type>::OptionChild(const ParentOptionType & parent)
- : parent(&parent) {}
-@@ -171,6 +179,12 @@ inline bool OptionChild<ParentOptionType, typename std::enable_if<std::is_same<t
-     return priority == Priority::EMPTY && parent->empty();
- }
- 
-+template <class ParentOptionType>
-+inline void OptionChild<ParentOptionType, typename std::enable_if<std::is_same<typename ParentOptionType::ValueType, std::string>::value>::type>::reset()
-+{
-+    priority = Priority::EMPTY;
-+}
-+
- }
- 
- #endif
-diff --git a/libdnf/conf/OptionEnum.hpp b/libdnf/conf/OptionEnum.hpp
-index c63156cb3..d2f710f20 100644
---- a/libdnf/conf/OptionEnum.hpp
-+++ b/libdnf/conf/OptionEnum.hpp
-@@ -49,6 +49,7 @@ class OptionEnum : public Option {
-     T getDefaultValue() const;
-     std::string toString(ValueType value) const;
-     std::string getValueString() const override;
-+    void reset() override;
- 
- protected:
-     FromStringFunc fromStringUser;
-@@ -74,6 +75,7 @@ class OptionEnum<std::string> : public Option {
-     const std::string & getValue() const;
-     const std::string & getDefaultValue() const;
-     std::string getValueString() const override;
-+    void reset() override;
- 
- protected:
-     FromStringFunc fromStringUser;
-@@ -88,6 +90,13 @@ inline OptionEnum<T> * OptionEnum<T>::clone() const
-     return new OptionEnum<T>(*this);
- }
- 
-+template <typename T>
-+inline void OptionEnum<T>::reset()
-+{
-+    value = defaultValue;
-+    priority = Priority::DEFAULT;
-+}
-+
- inline OptionEnum<std::string> * OptionEnum<std::string>::clone() const
- {
-     return new OptionEnum<std::string>(*this);
-@@ -108,6 +117,12 @@ inline std::string OptionEnum<std::string>::getValueString() const
-     return value;
- }
- 
-+inline void OptionEnum<std::string>::reset()
-+{
-+    value = defaultValue;
-+    priority = Priority::DEFAULT;
-+}
-+
- }
- 
- #endif
-diff --git a/libdnf/conf/OptionNumber.hpp b/libdnf/conf/OptionNumber.hpp
-index 98988fd50..f7a7b3d6e 100644
---- a/libdnf/conf/OptionNumber.hpp
-+++ b/libdnf/conf/OptionNumber.hpp
-@@ -50,6 +50,7 @@ class OptionNumber : public Option {
-     T getDefaultValue() const;
-     std::string toString(ValueType value) const;
-     std::string getValueString() const override;
-+    void reset() override;
- 
- protected:
-     FromStringFunc fromStringUser;
-@@ -80,7 +81,14 @@ inline T OptionNumber<T>::getDefaultValue() const
- template <typename T>
- inline std::string OptionNumber<T>::getValueString() const
- {
--    return toString(value); 
-+    return toString(value);
-+}
-+
-+template <typename T>
-+inline void OptionNumber<T>::reset()
-+{
-+    value = defaultValue;
-+    priority = Priority::DEFAULT;
- }
- 
- extern template class OptionNumber<std::int32_t>;
-diff --git a/libdnf/conf/OptionString.cpp b/libdnf/conf/OptionString.cpp
-index d27194f7a..b42e6c633 100644
---- a/libdnf/conf/OptionString.cpp
-+++ b/libdnf/conf/OptionString.cpp
-@@ -27,18 +27,21 @@
- namespace libdnf {
- 
- OptionString::OptionString(const std::string & defaultValue)
--: Option(Priority::DEFAULT), defaultValue(defaultValue), value(defaultValue) {}
-+: Option(Priority::DEFAULT), initPriority(Priority::DEFAULT), defaultValue(defaultValue), value(defaultValue) {}
- 
- OptionString::OptionString(const char * defaultValue)
- {
-     if (defaultValue) {
-         this->value = this->defaultValue = defaultValue;
--        this->priority = Priority::DEFAULT;
-+        this->initPriority = this->priority = Priority::DEFAULT;
-+    } else {
-+        this->initPriority = Priority::EMPTY;
-     }
- }
- 
- OptionString::OptionString(const std::string & defaultValue, const std::string & regex, bool icase)
--: Option(Priority::DEFAULT), regex(regex), icase(icase), defaultValue(defaultValue), value(defaultValue) { test(defaultValue); }
-+: Option(Priority::DEFAULT), initPriority(Priority::DEFAULT), regex(regex), icase(icase)
-+, defaultValue(defaultValue), value(defaultValue) { test(defaultValue); }
- 
- OptionString::OptionString(const char * defaultValue, const std::string & regex, bool icase)
- : regex(regex), icase(icase)
-@@ -48,6 +51,8 @@ OptionString::OptionString(const char * defaultValue, const std::string & regex,
-         test(this->defaultValue);
-         this->value = this->defaultValue;
-         this->priority = Priority::DEFAULT;
-+    } else {
-+        this->initPriority = Priority::EMPTY;
-     }
- }
- 
-diff --git a/libdnf/conf/OptionString.hpp b/libdnf/conf/OptionString.hpp
-index 2e26305c4..03fef8bcf 100644
---- a/libdnf/conf/OptionString.hpp
-+++ b/libdnf/conf/OptionString.hpp
-@@ -42,8 +42,10 @@ class OptionString : public Option {
-     const std::string & getValue() const;
-     const std::string & getDefaultValue() const noexcept;
-     std::string getValueString() const override;
-+    void reset() override;
- 
- protected:
-+    Priority initPriority;
-     std::string regex;
-     bool icase;
-     std::string defaultValue;
-@@ -70,6 +72,12 @@ inline std::string OptionString::fromString(const std::string & value) const
-     return value;
- }
- 
-+inline void OptionString::reset()
-+{
-+    value = defaultValue;
-+    priority = initPriority;
-+}
-+
- }
- 
- #endif
-diff --git a/libdnf/conf/OptionStringList.hpp b/libdnf/conf/OptionStringList.hpp
-index 942e56b16..20debaa8c 100644
---- a/libdnf/conf/OptionStringList.hpp
-+++ b/libdnf/conf/OptionStringList.hpp
-@@ -45,6 +45,7 @@ class OptionStringList : public Option {
-     const ValueType & getDefaultValue() const;
-     std::string toString(const ValueType & value) const;
-     std::string getValueString() const override;
-+    void reset() override;
- 
- protected:
-     std::string regex;
-@@ -70,7 +71,13 @@ inline const OptionStringList::ValueType & OptionStringList::getDefaultValue() c
- 
- inline std::string OptionStringList::getValueString() const
- {
--    return toString(value); 
-+    return toString(value);
-+}
-+
-+inline void OptionStringList::reset()
-+{
-+    value = defaultValue;
-+    priority = Priority::DEFAULT;
- }
- 
- }
-
-From 372a000414875f323147cd342dd8b4c8c7ebe260 Mon Sep 17 00:00:00 2001
-From: Jaroslav Rohel <jrohel@redhat.com>
-Date: Tue, 1 Dec 2020 08:29:53 +0100
-Subject: [PATCH 2/9] Add OptionBinds::getOption() method
-
-Sometime we want direct access to the underlying Option.
-E.g. we want to get its original value (not just a string representation)
-or find out the Option type.
----
- libdnf/conf/OptionBinds.cpp | 9 +++++++++
- libdnf/conf/OptionBinds.hpp | 2 ++
- 2 files changed, 11 insertions(+)
-
-diff --git a/libdnf/conf/OptionBinds.cpp b/libdnf/conf/OptionBinds.cpp
-index f7c67540b..ab53518a3 100644
---- a/libdnf/conf/OptionBinds.cpp
-+++ b/libdnf/conf/OptionBinds.cpp
-@@ -66,6 +66,15 @@ bool OptionBinds::Item::getAddValue() const
-     return addValue;
- }
- 
-+const Option & OptionBinds::Item::getOption() const
-+{
-+    return *option;
-+}
-+
-+Option & OptionBinds::Item::getOption()
-+{
-+    return *option;
-+}
- 
- // =========== OptionBinds class ===============
- 
-diff --git a/libdnf/conf/OptionBinds.hpp b/libdnf/conf/OptionBinds.hpp
-index 715c37e26..515120b93 100644
---- a/libdnf/conf/OptionBinds.hpp
-+++ b/libdnf/conf/OptionBinds.hpp
-@@ -55,6 +55,8 @@ class OptionBinds {
-         void newString(Option::Priority priority, const std::string & value);
-         std::string getValueString() const;
-         bool getAddValue() const;
-+        const Option & getOption() const;
-+        Option & getOption();
- 
-     private:
-         friend class OptionBinds;
-
-From 3a686c378978c90538a6ac5d9826d52ce7c8daf6 Mon Sep 17 00:00:00 2001
-From: Jaroslav Rohel <jrohel@redhat.com>
-Date: Tue, 1 Dec 2020 08:37:14 +0100
-Subject: [PATCH 3/9] [context] Add dnf_repo_conf_from_gkeyfile() and
- dnf_repo_conf_reset()
-
-dnf_repo_conf_from_gkeyfile():
-The function reloads repository configuration from GKeyFile.
-
-dnf_repo_conf_reset():
-Resets repository configuration options previously readed from repository
-configuration file to initial state.
----
- libdnf/dnf-repo.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 64 insertions(+)
-
-diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp
-index 00f4bbf7b..9f283df55 100644
---- a/libdnf/dnf-repo.cpp
-+++ b/libdnf/dnf-repo.cpp
-@@ -936,6 +936,70 @@ dnf_repo_get_boolean(GKeyFile *keyfile,
-     return false;
- }
- 
-+/* Resets repository configuration options previously readed from repository
-+ * configuration file to initial state. */
-+static void
-+dnf_repo_conf_reset(libdnf::ConfigRepo &config)
-+{
-+    for (auto & item : config.optBinds()) {
-+        auto & itemOption = item.second;
-+        if (itemOption.getPriority() == libdnf::Option::Priority::REPOCONFIG) {
-+            itemOption.getOption().reset();
-+        }
-+    }
-+}
-+
-+/* Loads repository configuration from GKeyFile */
-+static void
-+dnf_repo_conf_from_gkeyfile(libdnf::ConfigRepo &config, const char *repoId, GKeyFile *gkeyFile)
-+{
-+    // Reset to the initial state before reloading the configuration.
-+    dnf_repo_conf_reset(config);
-+
-+    g_auto(GStrv) keys = g_key_file_get_keys(gkeyFile, repoId, NULL, NULL);
-+    for (auto it = keys; *it != NULL; ++it) {
-+        auto key = *it;
-+        g_autofree gchar *str = g_key_file_get_value(gkeyFile, repoId, key, NULL);
-+        if (str) {
-+            try {
-+                auto & optionItem = config.optBinds().at(key);
-+
-+                if (dynamic_cast<libdnf::OptionStringList*>(&optionItem.getOption()) ||
-+                    dynamic_cast<libdnf::OptionChild<libdnf::OptionStringList>*>(&optionItem.getOption())
-+                ) {
-+
-+                    // reload list option from gKeyFile using g_key_file_get_string_list()
-+                    // g_key_file_get_value () is problematic for multiline lists
-+                    g_auto(GStrv) list = g_key_file_get_string_list(gkeyFile, repoId, key, NULL, NULL);
-+                    if (list) {
-+                        // list can be ['value1', 'value2, value3'] therefore we first join
-+                        // to have 'value1, value2, value3'
-+                        g_autofree gchar * tmp_strval = g_strjoinv(",", list);
-+                        try {
-+                            optionItem.newString(libdnf::Option::Priority::REPOCONFIG, tmp_strval);
-+                        } catch (const std::exception & ex) {
-+                            g_debug("Invalid configuration value: %s = %s in %s; %s", key, str, repoId, ex.what());
-+                        }
-+                    }
-+
-+                } else {
-+
-+                    // process other (non list) options
-+                    try {
-+                        optionItem.newString(libdnf::Option::Priority::REPOCONFIG, str);
-+                    } catch (const std::exception & ex) {
-+                        g_debug("Invalid configuration value: %s = %s in %s; %s", key, str, repoId, ex.what());
-+                    }
-+
-+                }
-+
-+            } catch (const std::exception &) {
-+                g_debug("Unknown configuration option: %s = %s in %s", key, str, repoId);
-+            }
-+        }
-+    }
-+}
-+
- /* Initialize (or potentially reset) repo & LrHandle from keyfile values. */
- static gboolean
- dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-
-From 5f1c06a66fcdb2c2340c11c07c5ba0ea3abf4b77 Mon Sep 17 00:00:00 2001
-From: Jaroslav Rohel <jrohel@redhat.com>
-Date: Wed, 2 Dec 2020 11:37:26 +0100
-Subject: [PATCH 4/9] [context] Use dnf_repo_conf_from_gkeyfile() for repo
- configuration reload
-
-The dnf_repo_set_key_file_data() uses dnf_repo_conf_from_gkeyfile() now.
-All occurrences of the direct use 'repo->getConfig()->.*set' and
-newString() were removed.
----
- libdnf/dnf-repo.cpp | 121 +++++++++-----------------------------------
- 1 file changed, 25 insertions(+), 96 deletions(-)
-
-diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp
-index 9f283df55..2837580f7 100644
---- a/libdnf/dnf-repo.cpp
-+++ b/libdnf/dnf-repo.cpp
-@@ -1006,7 +1006,6 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
- {
-     DnfRepoPrivate *priv = GET_PRIVATE(repo);
-     guint cost;
--    gboolean module_hotfixes = false;
-     g_autofree gchar *metadata_expire_str = NULL;
-     g_autofree gchar *mirrorlist = NULL;
-     g_autofree gchar *mirrorlisturl = NULL;
-@@ -1016,48 +1015,28 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-     g_autofree gchar *usr = NULL;
-     g_autofree gchar *usr_pwd = NULL;
-     g_autofree gchar *usr_pwd_proxy = NULL;
--    g_auto(GStrv) baseurls;
- 
-     auto repoId = priv->repo->getId().c_str();
-     g_debug("setting keyfile data for %s", repoId);
- 
--    /* skip_if_unavailable is optional */
--    if (g_key_file_has_key(priv->keyfile, repoId, "skip_if_unavailable", NULL)) {
--        bool skip = dnf_repo_get_boolean(priv->keyfile, repoId, "skip_if_unavailable");
--        priv->repo->getConfig()->skip_if_unavailable().set(libdnf::Option::Priority::REPOCONFIG, skip);
--    }
-+    auto conf = priv->repo->getConfig();
- 
--    /* priority is optional */
--    g_autofree gchar * priority_str = g_key_file_get_string(priv->keyfile, repoId, "priority", NULL);
--    if (priority_str) {
--        priv->repo->getConfig()->priority().set(libdnf::Option::Priority::REPOCONFIG, priority_str);
--    }
-+    // Reload repository configuration from keyfile.
-+    dnf_repo_conf_from_gkeyfile(*conf, repoId, priv->keyfile);
- 
-     /* cost is optional */
-     cost = g_key_file_get_integer(priv->keyfile, repoId, "cost", NULL);
-     if (cost != 0)
-         dnf_repo_set_cost(repo, cost);
- 
--    module_hotfixes = g_key_file_get_boolean(priv->keyfile, repoId, "module_hotfixes", NULL);
--    priv->repo->getConfig()->module_hotfixes().set(libdnf::Option::Priority::REPOCONFIG, module_hotfixes);
--
-     /* baseurl is optional; if missing, unset it */
--    baseurls = g_key_file_get_string_list(priv->keyfile, repoId, "baseurl", NULL, NULL);
--    if (baseurls) {
--        // baseruls can be ['value1', 'value2, value3'] therefore we first join to have 'value1, value2, value3'
--        g_autofree gchar * tmp_strval = g_strjoinv(",", baseurls);
--
--        auto & bindBaseurls = priv->repo->getConfig()->optBinds().at("baseurl");
--        bindBaseurls.newString(libdnf::Option::Priority::REPOCONFIG, tmp_strval);
--
--        auto & repoBaseurls = priv->repo->getConfig()->baseurl();
--        if (!repoBaseurls.getValue().empty()){
--            auto len = repoBaseurls.getValue().size();
--            g_strfreev(baseurls);
--            baseurls = g_new0(char *, len + 1);
--            for (size_t i = 0; i < len; ++i) {
--                baseurls[i] = g_strdup(repoBaseurls.getValue()[i].c_str());
--            }
-+    g_auto(GStrv) baseurls = NULL;
-+    auto & repoBaseurls = conf->baseurl().getValue();
-+    if (!repoBaseurls.empty()){
-+        auto len = repoBaseurls.size();
-+        baseurls = g_new0(char *, len + 1);
-+        for (size_t i = 0; i < len; ++i) {
-+            baseurls[i] = g_strdup(repoBaseurls[i].c_str());
-         }
-     }
-     if (!lr_handle_setopt(priv->repo_handle, error, LRO_URLS, baseurls))
-@@ -1093,18 +1072,6 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-     if (!lr_handle_setopt(priv->repo_handle, error, LRO_METALINKURL, metalinkurl))
-         return FALSE;
- 
--    /* needed in order for addCountmeFlag() to use the same persistdir as DNF
--     * would */
--    if (metalinkurl)
--        priv->repo->getConfig()->metalink().set(libdnf::Option::Priority::REPOCONFIG, metalinkurl);
--    if (mirrorlisturl)
--        priv->repo->getConfig()->mirrorlist().set(libdnf::Option::Priority::REPOCONFIG, mirrorlisturl);
--
--    if (g_key_file_has_key(priv->keyfile, repoId, "countme", NULL)) {
--        bool countme = dnf_repo_get_boolean(priv->keyfile, repoId, "countme");
--        priv->repo->getConfig()->countme().set(libdnf::Option::Priority::REPOCONFIG, countme);
--    }
--
-     /* file:// */
-     if (baseurls != NULL && baseurls[0] != NULL &&
-         mirrorlisturl == NULL && metalinkurl == NULL) {
-@@ -1150,42 +1117,20 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-         dnf_repo_set_location_tmp(repo, tmp->str);
-     }
- 
--    /* gpgkey is optional for gpgcheck=1, but required for repo_gpgcheck=1 */
-+    // Sync priv->gpgkeys
-     g_strfreev(priv->gpgkeys);
--    priv->gpgkeys = NULL;
--
--    g_auto(GStrv) gpgkeys;
--    gpgkeys = g_key_file_get_string_list(priv->keyfile, repoId, "gpgkey", NULL, NULL);
--
--    if (gpgkeys) {
--        // gpgkeys can be ['value1', 'value2, value3'] therefore we first join to have 'value1, value2, value3'
--        g_autofree gchar * tmp_strval = g_strjoinv(",", gpgkeys);
--
--        auto & bindGpgkeys = priv->repo->getConfig()->optBinds().at("gpgkey");
--        bindGpgkeys.newString(libdnf::Option::Priority::REPOCONFIG, tmp_strval);
--
--        auto & repoGpgkeys = priv->repo->getConfig()->gpgkey();
--        if (!repoGpgkeys.getValue().empty()){
--            auto len = repoGpgkeys.getValue().size();
--            priv->gpgkeys = g_new0(char *, len + 1);
--            for (size_t i = 0; i < len; ++i) {
--                priv->gpgkeys[i] = g_strdup(repoGpgkeys.getValue()[i].c_str());
--            }
--        } else {
--            /* Canonicalize the empty list to NULL for ease of checking elsewhere */
--            g_strfreev(static_cast<gchar **>(g_steal_pointer(&priv->gpgkeys)));
-+    auto & repoGpgkeys = conf->gpgkey().getValue();
-+    if (!repoGpgkeys.empty()){
-+        auto len = repoGpgkeys.size();
-+        priv->gpgkeys = g_new0(char *, len + 1);
-+        for (size_t i = 0; i < len; ++i) {
-+            priv->gpgkeys[i] = g_strdup(repoGpgkeys[i].c_str());
-         }
-+    } else {
-+        priv->gpgkeys = NULL;
-     }
- 
--    if (g_key_file_has_key(priv->keyfile, repoId, "gpgcheck", NULL)) {
--        auto gpgcheck_pkgs = dnf_repo_get_boolean(priv->keyfile, repoId, "gpgcheck");
--        priv->repo->getConfig()->gpgcheck().set(libdnf::Option::Priority::REPOCONFIG, gpgcheck_pkgs);
--    }
--
--    if (g_key_file_has_key(priv->keyfile, repoId, "repo_gpgcheck", NULL)) {
--        auto gpgcheck_md = dnf_repo_get_boolean(priv->keyfile, repoId, "repo_gpgcheck");
--        priv->repo->getConfig()->repo_gpgcheck().set(libdnf::Option::Priority::REPOCONFIG, gpgcheck_md);
--    }
-+    /* gpgkey is optional for gpgcheck=1, but required for repo_gpgcheck=1 */
-     auto gpgcheck_md = priv->repo->getConfig()->repo_gpgcheck().getValue();
-     if (gpgcheck_md && priv->gpgkeys == NULL) {
-         g_set_error_literal(error,
-@@ -1199,35 +1144,19 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-     if (!lr_handle_setopt(priv->repo_handle, error, LRO_GPGCHECK, (long)gpgcheck_md))
-         return FALSE;
- 
--    auto & repoExcludepkgs = priv->repo->getConfig()->excludepkgs();
--    repoExcludepkgs.set(libdnf::Option::Priority::REPOCONFIG, "");
--
--    auto & bindExcludepkgs = priv->repo->getConfig()->optBinds().at("excludepkgs");
--    if (auto excludepkgs = g_key_file_get_string(priv->keyfile, repoId, "exclude", NULL)) {
--        bindExcludepkgs.newString(libdnf::Option::Priority::REPOCONFIG, excludepkgs);
--        g_free(excludepkgs);
--    }
--    if (auto excludepkgs = g_key_file_get_string(priv->keyfile, repoId, "excludepkgs", NULL)) {
--        bindExcludepkgs.newString(libdnf::Option::Priority::REPOCONFIG, excludepkgs);
--        g_free(excludepkgs);
--    }
--
-+    // Sync priv->exclude_packages
-     g_strfreev(priv->exclude_packages);
--    if (!repoExcludepkgs.getValue().empty()) {
--        auto len = repoExcludepkgs.getValue().size();
-+    auto & repoExcludepkgs = conf->excludepkgs().getValue();
-+    if (!repoExcludepkgs.empty()) {
-+        auto len = repoExcludepkgs.size();
-         priv->exclude_packages = g_new0(char *, len + 1);
-         for (size_t i = 0; i < len; ++i) {
--            priv->exclude_packages[i] = g_strdup(repoExcludepkgs.getValue()[i].c_str());
-+            priv->exclude_packages[i] = g_strdup(repoExcludepkgs[i].c_str());
-         }
-     } else {
-         priv->exclude_packages = NULL;
-     }
- 
--    if (auto includepkgs = g_key_file_get_string(priv->keyfile, repoId, "includepkgs", NULL)) {
--        priv->repo->getConfig()->includepkgs().set(libdnf::Option::Priority::REPOCONFIG, includepkgs);
--        g_free(includepkgs);
--    }
--
-     /* proxy is optional */
-     proxy = g_key_file_get_string(priv->keyfile, repoId, "proxy", NULL);
-     auto repoProxy = proxy ? (strcasecmp(proxy, "_none_") == 0 ? NULL : proxy)
-
-From c6afbb4f93eee480c68201297e9c5c7afdf05dd3 Mon Sep 17 00:00:00 2001
-From: Jaroslav Rohel <jrohel@redhat.com>
-Date: Wed, 2 Dec 2020 13:26:51 +0100
-Subject: [PATCH 5/9] [context] Fix: "cost" and  "metadata_expire" repository
- options
-
-Changes in dnf_repo_set_keyfile_data():
-Removed the dnf_repo_set_cost() call.
-Removed the "metadata_expire" parsing and dnf_repo_set_metadata_expire() call.
-
-The options were set earlier. The function calls were redundant and
-set the priority to the wrong RUNTIME value.
----
- libdnf/dnf-repo.cpp | 103 --------------------------------------------
- 1 file changed, 103 deletions(-)
-
-diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp
-index 2837580f7..61d496750 100644
---- a/libdnf/dnf-repo.cpp
-+++ b/libdnf/dnf-repo.cpp
-@@ -816,93 +816,6 @@ dnf_repo_set_metadata_expire(DnfRepo *repo, guint metadata_expire)
-     priv->repo->getConfig()->metadata_expire().set(libdnf::Option::Priority::RUNTIME, metadata_expire);
- }
- 
--/**
-- *  dnf_repo_parse_time_from_str
-- *  @expression: a expression to be parsed
-- *  @out_parsed_time: (out): return location for parsed time
-- *  @error: error item
-- *
-- *  Parse String into an integer value of seconds, or a human
-- *  readable variation specifying days, hours, minutes or seconds
-- *  until something happens. Note that due to historical president
-- *  -1 means "never", so this accepts that and allows
-- *  the word never, too.
-- *
-- *  Valid inputs: 100, 1.5m, 90s, 1.2d, 1d, 0xF, 0.1, -1, never.
-- *  Invalid inputs: -10, -0.1, 45.6Z, 1d6h, 1day, 1y.
--
-- *  Returns: integer value in seconds
-- **/
--
--static gboolean
--dnf_repo_parse_time_from_str(const gchar *expression, guint *out_parsed_time, GError **error)
--{
--    gint multiplier;
--    gdouble parsed_time;
--    gchar *endptr = NULL;
--
--    if (!g_strcmp0(expression, "")) {
--        g_set_error_literal(error,
--                            DNF_ERROR,
--                            DNF_ERROR_FILE_INVALID,
--                            "no metadata value specified");
--        return FALSE;
--    }
--
--    if (g_strcmp0(expression, "-1") == 0 ||
--        g_strcmp0(expression,"never") == 0) {
--        *out_parsed_time = G_MAXUINT;
--        return TRUE; /* Note early return */
--    }
--
--    gchar last_char = expression[ strlen(expression) - 1 ];
--
--    /* check if the input ends with h, m ,d ,s as units */
--    if (g_ascii_isalpha(last_char)) {
--        if (last_char == 'h')
--            multiplier = 60 * 60;
--        else if (last_char == 's')
--            multiplier = 1;
--        else if (last_char == 'm')
--            multiplier = 60;
--        else if (last_char == 'd')
--            multiplier = 60 * 60 * 24;
--        else {
--            g_set_error(error, DNF_ERROR, DNF_ERROR_FILE_INVALID,
--                        "unknown unit %c", last_char);
--            return FALSE;
--        }
--    }
--    else
--        multiplier = 1;
--
--    /* convert expression into a double*/
--    parsed_time = g_ascii_strtod(expression, &endptr);
--
--    /* failed to parse */
--    if (expression == endptr) {
--        g_set_error(error, DNF_ERROR, DNF_ERROR_INTERNAL_ERROR,
--                    "failed to parse time: %s", expression);
--        return FALSE;
--    }
--
--    /* time can not be below zero */
--    if (parsed_time < 0) {
--        g_set_error(error, DNF_ERROR, DNF_ERROR_INTERNAL_ERROR,
--                    "seconds value must not be negative %s",expression );
--        return FALSE;
--    }
--
--    /* time too large */
--    if (parsed_time > G_MAXDOUBLE || (parsed_time * multiplier) > G_MAXUINT){
--        g_set_error(error, DNF_ERROR, DNF_ERROR_INTERNAL_ERROR,
--                    "time too large");
--        return FALSE;
--    }
--
--    *out_parsed_time = (guint) (parsed_time * multiplier);
--    return TRUE;
--}
- /**
-  * dnf_repo_get_username_password_string:
-  */
-@@ -1005,8 +918,6 @@ static gboolean
- dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
- {
-     DnfRepoPrivate *priv = GET_PRIVATE(repo);
--    guint cost;
--    g_autofree gchar *metadata_expire_str = NULL;
-     g_autofree gchar *mirrorlist = NULL;
-     g_autofree gchar *mirrorlisturl = NULL;
-     g_autofree gchar *metalinkurl = NULL;
-@@ -1024,11 +935,6 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-     // Reload repository configuration from keyfile.
-     dnf_repo_conf_from_gkeyfile(*conf, repoId, priv->keyfile);
- 
--    /* cost is optional */
--    cost = g_key_file_get_integer(priv->keyfile, repoId, "cost", NULL);
--    if (cost != 0)
--        dnf_repo_set_cost(repo, cost);
--
-     /* baseurl is optional; if missing, unset it */
-     g_auto(GStrv) baseurls = NULL;
-     auto & repoBaseurls = conf->baseurl().getValue();
-@@ -1042,15 +948,6 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-     if (!lr_handle_setopt(priv->repo_handle, error, LRO_URLS, baseurls))
-         return FALSE;
- 
--    /* metadata_expire is optional, if shown, we parse the string to add the time */
--    metadata_expire_str = g_key_file_get_string(priv->keyfile, repoId, "metadata_expire", NULL);
--    if (metadata_expire_str) {
--        guint metadata_expire;
--        if (!dnf_repo_parse_time_from_str(metadata_expire_str, &metadata_expire, error))
--            return FALSE;
--        dnf_repo_set_metadata_expire(repo, metadata_expire);
--    }
--
-     /* the "mirrorlist" entry could be either a real mirrorlist, or a metalink entry */
-     mirrorlist = g_key_file_get_string(priv->keyfile, repoId, "mirrorlist", NULL);
-     if (mirrorlist) {
-
-From b11ac5204dc4c7048a7b6880813f2f9b1d8eb242 Mon Sep 17 00:00:00 2001
-From: Jaroslav Rohel <jrohel@redhat.com>
-Date: Wed, 2 Dec 2020 13:21:35 +0100
-Subject: [PATCH 6/9] [context] Fix: username, password, proxy, proxy_username,
- proxy_password
-
-- Uses global configuration options when they are not defined
-  in the repository configuration.
-- proxy_username and proxy_password is urlEncoded before passing to librepo.
----
- libdnf/dnf-repo.cpp | 78 ++++++++++++++++++++++++++-------------------
- 1 file changed, 46 insertions(+), 32 deletions(-)
-
-diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp
-index 61d496750..005721ef6 100644
---- a/libdnf/dnf-repo.cpp
-+++ b/libdnf/dnf-repo.cpp
-@@ -817,18 +817,22 @@ dnf_repo_set_metadata_expire(DnfRepo *repo, guint metadata_expire)
- }
- 
- /**
-- * dnf_repo_get_username_password_string:
-- */
--static gchar *
--dnf_repo_get_username_password_string(const gchar *user, const gchar *pass)
--{
--    if (user == NULL && pass == NULL)
--        return NULL;
--    if (user != NULL && pass == NULL)
--        return g_strdup(user);
--    if (user == NULL && pass != NULL)
--        return g_strdup_printf(":%s", pass);
--    return g_strdup_printf("%s:%s", user, pass);
-+* @brief Format user password string
-+*
-+* Returns user and password in user:password form. If encode is True,
-+* special characters in user and password are URL encoded.
-+*
-+* @param user Username
-+* @param passwd Password
-+* @param encode If quote is True, special characters in user and password are URL encoded.
-+* @return User and password in user:password form
-+*/
-+static std::string formatUserPassString(const std::string & user, const std::string & passwd, bool encode)
-+{
-+    if (encode)
-+        return libdnf::urlEncode(user) + ":" + libdnf::urlEncode(passwd);
-+    else
-+        return user + ":" + passwd;
- }
- 
- static gboolean
-@@ -921,11 +925,8 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-     g_autofree gchar *mirrorlist = NULL;
-     g_autofree gchar *mirrorlisturl = NULL;
-     g_autofree gchar *metalinkurl = NULL;
--    g_autofree gchar *proxy = NULL;
--    g_autofree gchar *pwd = NULL;
--    g_autofree gchar *usr = NULL;
--    g_autofree gchar *usr_pwd = NULL;
--    g_autofree gchar *usr_pwd_proxy = NULL;
-+    std::string tmp_str;
-+    const char *tmp_cstr;
- 
-     auto repoId = priv->repo->getId().c_str();
-     g_debug("setting keyfile data for %s", repoId);
-@@ -1054,26 +1055,39 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-         priv->exclude_packages = NULL;
-     }
- 
--    /* proxy is optional */
--    proxy = g_key_file_get_string(priv->keyfile, repoId, "proxy", NULL);
--    auto repoProxy = proxy ? (strcasecmp(proxy, "_none_") == 0 ? NULL : proxy)
--        : dnf_context_get_http_proxy(priv->context);
--    if (!lr_handle_setopt(priv->repo_handle, error, LRO_PROXY, repoProxy))
-+    tmp_str = conf->proxy().getValue();
-+    tmp_cstr = tmp_str.empty() ? dnf_context_get_http_proxy(priv->context) : tmp_str.c_str();
-+    if (!lr_handle_setopt(priv->repo_handle, error, LRO_PROXY, tmp_cstr))
-         return FALSE;
- 
--    /* both parts of the proxy auth are optional */
--    usr = g_key_file_get_string(priv->keyfile, repoId, "proxy_username", NULL);
--    pwd = g_key_file_get_string(priv->keyfile, repoId, "proxy_password", NULL);
--    usr_pwd_proxy = dnf_repo_get_username_password_string(usr, pwd);
--    if (!lr_handle_setopt(priv->repo_handle, error, LRO_PROXYUSERPWD, usr_pwd_proxy))
-+    // setup proxy username and password
-+    tmp_cstr = NULL;
-+    if (!conf->proxy_username().empty()) {
-+        tmp_str = conf->proxy_username().getValue();
-+        if (!tmp_str.empty()) {
-+            if (conf->proxy_password().empty()) {
-+                g_set_error(error, DNF_ERROR, DNF_ERROR_FILE_INVALID,
-+                            "repo '%s': 'proxy_username' is set but not 'proxy_password'", repoId);
-+                return FALSE;
-+            }
-+            tmp_str = formatUserPassString(tmp_str, conf->proxy_password().getValue(), true);
-+            tmp_cstr = tmp_str.c_str();
-+        }
-+    }
-+    if (!lr_handle_setopt(priv->repo_handle, error, LRO_PROXYUSERPWD, tmp_cstr))
-         return FALSE;
- 
--    /* both parts of the HTTP auth are optional */
--    usr = g_key_file_get_string(priv->keyfile, repoId, "username", NULL);
--    pwd = g_key_file_get_string(priv->keyfile, repoId, "password", NULL);
--    usr_pwd = dnf_repo_get_username_password_string(usr, pwd);
--    if (!lr_handle_setopt(priv->repo_handle, error, LRO_USERPWD, usr_pwd))
-+    // setup username and password
-+    tmp_cstr = NULL;
-+    tmp_str = conf->username().getValue();
-+    if (!tmp_str.empty()) {
-+        // TODO Use URL encoded form, needs support in librepo
-+        tmp_str = formatUserPassString(tmp_str, conf->password().getValue(), false);
-+        tmp_cstr = tmp_str.c_str();
-+    }
-+    if (!lr_handle_setopt(priv->repo_handle, error, LRO_USERPWD, tmp_cstr))
-         return FALSE;
-+
-     return TRUE;
- }
- 
-
-From fd07b29ccaec2648cfc050122e16e4846d7ac4be Mon Sep 17 00:00:00 2001
-From: Jaroslav Rohel <jrohel@redhat.com>
-Date: Wed, 2 Dec 2020 13:53:45 +0100
-Subject: [PATCH 7/9] [context] Add support for options: minrate, throttle,
- bandwidth, timeout
-
----
- libdnf/dnf-repo.cpp | 29 +++++++++++++++++++++++++++++
- 1 file changed, 29 insertions(+)
-
-diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp
-index 005721ef6..c6dd027be 100644
---- a/libdnf/dnf-repo.cpp
-+++ b/libdnf/dnf-repo.cpp
-@@ -1055,6 +1055,35 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-         priv->exclude_packages = NULL;
-     }
- 
-+    auto minrate = conf->minrate().getValue();
-+    if (!lr_handle_setopt(priv->repo_handle, error, LRO_LOWSPEEDLIMIT, static_cast<long>(minrate)))
-+        return FALSE;
-+
-+    auto maxspeed = conf->throttle().getValue();
-+    if (maxspeed > 0 && maxspeed <= 1)
-+        maxspeed *= conf->bandwidth().getValue();
-+    if (maxspeed != 0 && maxspeed < minrate) {
-+        g_set_error_literal(error, DNF_ERROR, DNF_ERROR_FILE_INVALID,
-+                            "Maximum download speed is lower than minimum. "
-+                            "Please change configuration of minrate or throttle");
-+        return FALSE;
-+    }
-+    if (!lr_handle_setopt(priv->repo_handle, error, LRO_MAXSPEED, static_cast<int64_t>(maxspeed)))
-+        return FALSE;
-+
-+    long timeout = conf->timeout().getValue();
-+    if (timeout > 0) {
-+        if (!lr_handle_setopt(priv->repo_handle, error, LRO_CONNECTTIMEOUT, timeout))
-+            return FALSE;
-+        if (!lr_handle_setopt(priv->repo_handle, error, LRO_LOWSPEEDTIME, timeout))
-+            return FALSE;
-+    } else {
-+        if (!lr_handle_setopt(priv->repo_handle, error, LRO_CONNECTTIMEOUT, LRO_CONNECTTIMEOUT_DEFAULT))
-+            return FALSE;
-+        if (!lr_handle_setopt(priv->repo_handle, error, LRO_LOWSPEEDTIME, LRO_LOWSPEEDTIME_DEFAULT))
-+            return FALSE;
-+    }
-+
-     tmp_str = conf->proxy().getValue();
-     tmp_cstr = tmp_str.empty() ? dnf_context_get_http_proxy(priv->context) : tmp_str.c_str();
-     if (!lr_handle_setopt(priv->repo_handle, error, LRO_PROXY, tmp_cstr))
-
-From c484de218699dff834fb32133cf502b2d0c64162 Mon Sep 17 00:00:00 2001
-From: Jaroslav Rohel <jrohel@redhat.com>
-Date: Thu, 3 Dec 2020 10:55:02 +0100
-Subject: [PATCH 8/9] [context] Remove g_key_file_get_string() from
- dnf_repo_set_keyfile_data()
-
-Removes the remaining usage of g_key_file_get_string() from
-dnf_repo_set_keyfile_data(). Use the values from ConfigRepo instead.
----
- libdnf/dnf-repo.cpp | 23 +++++++++++------------
- 1 file changed, 11 insertions(+), 12 deletions(-)
-
-diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp
-index c6dd027be..c5c50d55c 100644
---- a/libdnf/dnf-repo.cpp
-+++ b/libdnf/dnf-repo.cpp
-@@ -922,9 +922,6 @@ static gboolean
- dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
- {
-     DnfRepoPrivate *priv = GET_PRIVATE(repo);
--    g_autofree gchar *mirrorlist = NULL;
--    g_autofree gchar *mirrorlisturl = NULL;
--    g_autofree gchar *metalinkurl = NULL;
-     std::string tmp_str;
-     const char *tmp_cstr;
- 
-@@ -949,20 +946,22 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-     if (!lr_handle_setopt(priv->repo_handle, error, LRO_URLS, baseurls))
-         return FALSE;
- 
-+    const char *mirrorlisturl = NULL;
-+    const char *metalinkurl = NULL;
-+
-     /* the "mirrorlist" entry could be either a real mirrorlist, or a metalink entry */
--    mirrorlist = g_key_file_get_string(priv->keyfile, repoId, "mirrorlist", NULL);
--    if (mirrorlist) {
--        if (strstr(mirrorlist, "metalink"))
--            metalinkurl = static_cast<gchar *>(g_steal_pointer(&mirrorlist));
-+    tmp_cstr = conf->mirrorlist().empty() ? NULL : conf->mirrorlist().getValue().c_str();
-+    if (tmp_cstr) {
-+        if (strstr(tmp_cstr, "metalink"))
-+            metalinkurl = tmp_cstr;
-         else /* it really is a mirrorlist */
--            mirrorlisturl = static_cast<gchar *>(g_steal_pointer(&mirrorlist));
-+            mirrorlisturl = tmp_cstr;
-     }
- 
-     /* let "metalink" entry override metalink-as-mirrorlist entry */
--    if (g_key_file_has_key(priv->keyfile, repoId, "metalink", NULL)) {
--        g_free(metalinkurl);
--        metalinkurl = g_key_file_get_string(priv->keyfile, repoId, "metalink", NULL);
--    }
-+    tmp_cstr = conf->metalink().empty() ? NULL : conf->metalink().getValue().c_str();
-+    if (tmp_cstr)
-+        metalinkurl = tmp_cstr;
- 
-     /* now set the final values (or unset them) */
-     if (!lr_handle_setopt(priv->repo_handle, error, LRO_MIRRORLISTURL, mirrorlisturl))
-
-From ce44d3dced4b800e3b7f80556fac1daf7e7fa49d Mon Sep 17 00:00:00 2001
-From: Jaroslav Rohel <jrohel@redhat.com>
-Date: Thu, 3 Dec 2020 11:43:18 +0100
-Subject: [PATCH 9/9] [context] Remove the extra gpgkey member from
- DnfRepoPrivate
-
-The value stored in ConfigRepo can be used directly.
----
- libdnf/dnf-repo.cpp | 81 ++++++++++++++++++---------------------------
- 1 file changed, 33 insertions(+), 48 deletions(-)
-
-diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp
-index c5c50d55c..193999902 100644
---- a/libdnf/dnf-repo.cpp
-+++ b/libdnf/dnf-repo.cpp
-@@ -63,7 +63,6 @@
- typedef struct
- {
-     DnfRepoEnabled   enabled;
--    gchar          **gpgkeys;
-     gchar          **exclude_packages;
-     gchar           *filename;      /* /etc/yum.repos.d/updates.repo */
-     gchar           *location;      /* /var/cache/PackageKit/metadata/fedora */
-@@ -97,7 +96,6 @@ dnf_repo_finalize(GObject *object)
-     DnfRepoPrivate *priv = GET_PRIVATE(repo);
- 
-     g_free(priv->filename);
--    g_strfreev(priv->gpgkeys);
-     g_strfreev(priv->exclude_packages);
-     g_free(priv->location_tmp);
-     g_free(priv->location);
-@@ -225,16 +223,13 @@ gchar **
- dnf_repo_get_public_keys(DnfRepo *repo)
- {
-     DnfRepoPrivate *priv = GET_PRIVATE(repo);
--    g_autoptr(GPtrArray) ret = g_ptr_array_new();
--    for (char **iter = priv->gpgkeys; iter && *iter; iter++) {
--        const char *key = *iter;
--        g_autofree gchar *key_bn = g_path_get_basename(key);
--        /* transfer ownership to ptrarray */
--        g_ptr_array_add(ret, g_build_filename(priv->location, key_bn, NULL));
-+    const auto & keys = priv->repo->getConfig()->gpgkey().getValue();
-+    gchar **ret = g_new0(gchar *, keys.size() + 1);
-+    for (size_t i = 0; i < keys.size(); ++i) {
-+        g_autofree gchar *key_bn = g_path_get_basename(keys[i].c_str());
-+        ret[i] = g_build_filename(priv->location, key_bn, NULL);
-     }
--    g_ptr_array_add(ret, NULL);
--    /* transfer ownership of container and elements to caller */
--    return (gchar**)g_ptr_array_free(static_cast<GPtrArray *>(g_steal_pointer(&ret)), FALSE);
-+    return ret;
- }
- 
- /**
-@@ -1014,22 +1009,9 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-         dnf_repo_set_location_tmp(repo, tmp->str);
-     }
- 
--    // Sync priv->gpgkeys
--    g_strfreev(priv->gpgkeys);
--    auto & repoGpgkeys = conf->gpgkey().getValue();
--    if (!repoGpgkeys.empty()){
--        auto len = repoGpgkeys.size();
--        priv->gpgkeys = g_new0(char *, len + 1);
--        for (size_t i = 0; i < len; ++i) {
--            priv->gpgkeys[i] = g_strdup(repoGpgkeys[i].c_str());
--        }
--    } else {
--        priv->gpgkeys = NULL;
--    }
--
-     /* gpgkey is optional for gpgcheck=1, but required for repo_gpgcheck=1 */
--    auto gpgcheck_md = priv->repo->getConfig()->repo_gpgcheck().getValue();
--    if (gpgcheck_md && priv->gpgkeys == NULL) {
-+    auto repo_gpgcheck = conf->repo_gpgcheck().getValue();
-+    if (repo_gpgcheck && conf->gpgkey().getValue().empty()) {
-         g_set_error_literal(error,
-                             DNF_ERROR,
-                             DNF_ERROR_FILE_INVALID,
-@@ -1038,7 +1020,7 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error)
-     }
- 
-     /* XXX: setopt() expects a long, so we need a long on the stack */
--    if (!lr_handle_setopt(priv->repo_handle, error, LRO_GPGCHECK, (long)gpgcheck_md))
-+    if (!lr_handle_setopt(priv->repo_handle, error, LRO_GPGCHECK, (long)repo_gpgcheck))
-         return FALSE;
- 
-     // Sync priv->exclude_packages
-@@ -1750,28 +1732,31 @@ dnf_repo_update(DnfRepo *repo,
-         goto out;
-     }
- 
--    if (priv->gpgkeys &&
--        (priv->repo->getConfig()->repo_gpgcheck().getValue() || priv->repo->getConfig()->gpgcheck().getValue())) {
--        for (char **iter = priv->gpgkeys; iter && *iter; iter++) {
--            const char *gpgkey = *iter;
--            g_autofree char *gpgkey_name = g_path_get_basename(gpgkey);
--            g_autofree char *key_tmp = g_build_filename(priv->location_tmp, gpgkey_name, NULL);
--
--            /* download and import public key */
--            if ((g_str_has_prefix(gpgkey, "https://") ||
--                  g_str_has_prefix(gpgkey, "file://"))) {
--                g_debug("importing public key %s", gpgkey);
--
--                ret = dnf_repo_download_import_public_key(repo, gpgkey, key_tmp, error);
--                if (!ret)
--                    goto out;
--            }
-+    {
-+        const auto & gpgkeys = priv->repo->getConfig()->gpgkey().getValue();
-+        if (!gpgkeys.empty() &&
-+            (priv->repo->getConfig()->repo_gpgcheck().getValue() || priv->repo->getConfig()->gpgcheck().getValue())) {
-+            for (const auto & key : gpgkeys) {
-+                const char *gpgkey = key.c_str();
-+                g_autofree char *gpgkey_name = g_path_get_basename(gpgkey);
-+                g_autofree char *key_tmp = g_build_filename(priv->location_tmp, gpgkey_name, NULL);
-+
-+                /* download and import public key */
-+                if ((g_str_has_prefix(gpgkey, "https://") ||
-+                    g_str_has_prefix(gpgkey, "file://"))) {
-+                    g_debug("importing public key %s", gpgkey);
-+
-+                    ret = dnf_repo_download_import_public_key(repo, gpgkey, key_tmp, error);
-+                    if (!ret)
-+                        goto out;
-+                }
- 
--            /* do we autoimport this into librpm? */
--            if ((flags & DNF_REPO_UPDATE_FLAG_IMPORT_PUBKEY) > 0) {
--                ret = dnf_repo_add_public_key(repo, key_tmp, error);
--                if (!ret)
--                    goto out;
-+                /* do we autoimport this into librpm? */
-+                if ((flags & DNF_REPO_UPDATE_FLAG_IMPORT_PUBKEY) > 0) {
-+                    ret = dnf_repo_add_public_key(repo, key_tmp, error);
-+                    if (!ret)
-+                        goto out;
-+                }
-             }
-         }
-     }
diff --git a/SOURCES/0005-Allow-loading-incomplete-cache-and-loading-ext-solv-files-without-its-repodata.patch b/SOURCES/0005-Allow-loading-incomplete-cache-and-loading-ext-solv-files-without-its-repodata.patch
deleted file mode 100644
index 30421d4..0000000
--- a/SOURCES/0005-Allow-loading-incomplete-cache-and-loading-ext-solv-files-without-its-repodata.patch
+++ /dev/null
@@ -1,134 +0,0 @@
-From 816d18d826dc7134e553eae28f4aaca9a27e2307 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
-Date: Mon, 2 Nov 2020 11:43:19 +0100
-Subject: [PATCH 1/2] Allow loading ext metadata even if only cache (solv) is
- present
-
-If we have a valid (checksum matches with repomd) solv file for
-requested type of metadata allow using it even if we no longer have the
-original xml metadata.
----
- libdnf/dnf-sack.cpp | 22 +++++++++++-----------
- 1 file changed, 11 insertions(+), 11 deletions(-)
-
-diff --git a/libdnf/dnf-sack.cpp b/libdnf/dnf-sack.cpp
-index 6a43f01e3..608103d18 100644
---- a/libdnf/dnf-sack.cpp
-+++ b/libdnf/dnf-sack.cpp
-@@ -371,20 +371,9 @@ load_ext(DnfSack *sack, HyRepo hrepo, _hy_repo_repodata which_repodata,
-     auto repoImpl = libdnf::repoGetImpl(hrepo);
-     Repo *repo = repoImpl->libsolvRepo;
-     const char *name = repo->name;
--    auto fn = hrepo->getMetadataPath(which_filename);
-     FILE *fp;
-     gboolean done = FALSE;
- 
--    /* nothing set */
--    if (fn.empty()) {
--        g_set_error (error,
--                     DNF_ERROR,
--                     DNF_ERROR_NO_CAPABILITY,
--                     _("no %1$s string for %2$s"),
--                     which_filename, name);
--        return FALSE;
--    }
--
-     char *fn_cache =  dnf_sack_give_cache_fn(sack, name, suffix);
-     fp = fopen(fn_cache, "r");
-     assert(libdnf::repoGetImpl(hrepo)->checksum);
-@@ -416,6 +405,17 @@ load_ext(DnfSack *sack, HyRepo hrepo, _hy_repo_repodata which_repodata,
-     if (done)
-         return TRUE;
- 
-+    auto fn = hrepo->getMetadataPath(which_filename);
-+    /* nothing set */
-+    if (fn.empty()) {
-+        g_set_error (error,
-+                     DNF_ERROR,
-+                     DNF_ERROR_NO_CAPABILITY,
-+                     _("no %1$s string for %2$s"),
-+                     which_filename, name);
-+        return FALSE;
-+    }
-+
-     fp = solv_xfopen(fn.c_str(), "r");
-     if (fp == NULL) {
-         g_set_error (error,
-
-From aa2a372158f1b264708f960f387218deea17ef2a Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
-Date: Thu, 10 Dec 2020 14:21:03 +0100
-Subject: [PATCH 2/2] Extend repo loadCache method with ignoreMissing parameter
-
-This allows loading even incomplete cache of xml files, only repomd.xml
-is requried.
-
-= changelog =
-msg: Extend repo loadCache method with ignoreMissing parameter to allow
-loading incomplete xml cache (repomd.xml is required).
-type: enhancement
-resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1865803
----
- VERSION.cmake                | 2 +-
- libdnf.spec                  | 2 +-
- libdnf/repo/Repo-private.hpp | 2 +-
- libdnf/repo/Repo.cpp         | 8 ++++++--
- libdnf/repo/Repo.hpp         | 2 +-
- 5 files changed, 10 insertions(+), 6 deletions(-)
-
-diff --git a/libdnf/repo/Repo-private.hpp b/libdnf/repo/Repo-private.hpp
-index 1e4ea4d20..c2ce369dc 100644
---- a/libdnf/repo/Repo-private.hpp
-+++ b/libdnf/repo/Repo-private.hpp
-@@ -111,7 +111,7 @@ class Repo::Impl {
-     ~Impl();
- 
-     bool load();
--    bool loadCache(bool throwExcept);
-+    bool loadCache(bool throwExcept, bool ignoreMissing=false);
-     void downloadMetadata(const std::string & destdir);
-     bool isInSync();
-     void fetch(const std::string & destdir, std::unique_ptr<LrHandle> && h);
-diff --git a/libdnf/repo/Repo.cpp b/libdnf/repo/Repo.cpp
-index 34539e1ee..84702c294 100644
---- a/libdnf/repo/Repo.cpp
-+++ b/libdnf/repo/Repo.cpp
-@@ -379,7 +379,7 @@ std::string Repo::getLocalBaseurl() const
- }
- 
- bool Repo::load() { return pImpl->load(); }
--bool Repo::loadCache(bool throwExcept) { return pImpl->loadCache(throwExcept); }
-+bool Repo::loadCache(bool throwExcept, bool ignoreMissing) { return pImpl->loadCache(throwExcept, ignoreMissing); }
- void Repo::downloadMetadata(const std::string & destdir) { pImpl->downloadMetadata(destdir); }
- bool Repo::getUseIncludes() const { return pImpl->useIncludes; }
- void Repo::setUseIncludes(bool enabled) { pImpl->useIncludes = enabled; }
-@@ -963,11 +963,15 @@ std::unique_ptr<LrResult> Repo::Impl::lrHandlePerform(LrHandle * handle, const s
-     return result;
- }
- 
--bool Repo::Impl::loadCache(bool throwExcept)
-+bool Repo::Impl::loadCache(bool throwExcept, bool ignoreMissing)
- {
-     std::unique_ptr<LrHandle> h(lrHandleInitLocal());
-     std::unique_ptr<LrResult> r;
- 
-+    if (ignoreMissing) {
-+        handleSetOpt(h.get(), LRO_IGNOREMISSING, 1L);
-+    }
-+
-     // Fetch data
-     try {
-         r = lrHandlePerform(h.get(), getCachedir(), conf->repo_gpgcheck().getValue());
-diff --git a/libdnf/repo/Repo.hpp b/libdnf/repo/Repo.hpp
-index eeec651c3..be376f60c 100644
---- a/libdnf/repo/Repo.hpp
-+++ b/libdnf/repo/Repo.hpp
-@@ -167,7 +167,7 @@ struct Repo {
-     * @return true if fresh metadata were downloaded, false otherwise.
-     */
-     bool load();
--    bool loadCache(bool throwExcept);
-+    bool loadCache(bool throwExcept, bool ignoreMissing=false);
-     void downloadMetadata(const std::string & destdir);
-     bool getUseIncludes() const;
-     void setUseIncludes(bool enabled);
diff --git a/SOURCES/0005-Revert-Report-a-new-type-of-the-module-resolve-error.patch b/SOURCES/0005-Revert-Report-a-new-type-of-the-module-resolve-error.patch
new file mode 100644
index 0000000..664ef01
--- /dev/null
+++ b/SOURCES/0005-Revert-Report-a-new-type-of-the-module-resolve-error.patch
@@ -0,0 +1,89 @@
+From ce301450c39ebbd9fc5ec0897af2df766015e1bd Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:53 +0200
+Subject: [PATCH 05/19] Revert "Report a new type of the module resolve error"
+
+This reverts commit 9235436672fa413d5ac94f52a534b5abe90b5c7f.
+---
+ libdnf/dnf-context.cpp                   |  4 ----
+ libdnf/module/ModulePackageContainer.cpp | 17 ++++++++++++-----
+ libdnf/module/ModulePackageContainer.hpp | 10 ++++------
+ 3 files changed, 16 insertions(+), 15 deletions(-)
+
+diff --git a/libdnf/dnf-context.cpp b/libdnf/dnf-context.cpp
+index ccb6fe83..55af2b26 100644
+--- a/libdnf/dnf-context.cpp
++++ b/libdnf/dnf-context.cpp
+@@ -3252,10 +3252,6 @@ report_problems(const std::vector<std::tuple<libdnf::ModulePackageContainer::Mod
+             case libdnf::ModulePackageContainer::ModuleErrorType::ERROR_IN_DEFAULTS:
+                 logger->warning(tfm::format(_("Modular dependency problem with Defaults: %s"), report.c_str()));
+                 break;
+-            case libdnf::ModulePackageContainer::ModuleErrorType::ERROR_IN_LATEST:
+-                logger->warning(tfm::format(_("Modular dependency problem with the lates modules: %s"),
+-                                            report.c_str()));
+-                break;
+             case libdnf::ModulePackageContainer::ModuleErrorType::ERROR:
+                 logger->error(tfm::format(_("Modular dependency problem: %s"), report.c_str()));
+                 return_error = true;
+diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
+index 1bfdd8c1..ee90056c 100644
+--- a/libdnf/module/ModulePackageContainer.cpp
++++ b/libdnf/module/ModulePackageContainer.cpp
+@@ -725,16 +725,23 @@ ModulePackageContainer::Impl::moduleSolve(const std::vector<ModulePackage *> & m
+                     goal2name_query(goalWeak, query);
+                     activatedModules.reset(new PackageSet(*query.runSet()));
+                 }
+-                return make_pair(problems, problemType);
++            } else {
++                problemType = ModulePackageContainer::ModuleErrorType::ERROR_IN_DEFAULTS;
++                Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
++                goal2name_query(goal, query);
++                activatedModules.reset(new PackageSet(*query.runSet()));
+             }
+-            problemType = ModulePackageContainer::ModuleErrorType::ERROR_IN_LATEST;
+         } else {
+             problemType = ModulePackageContainer::ModuleErrorType::ERROR_IN_DEFAULTS;
++            Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
++            goal2name_query(goal, query);
++            activatedModules.reset(new PackageSet(*query.runSet()));
+         }
++    } else {
++        Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
++        goal2name_query(goal, query);
++        activatedModules.reset(new PackageSet(*query.runSet()));
+     }
+-    Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
+-    goal2name_query(goal, query);
+-    activatedModules.reset(new PackageSet(*query.runSet()));
+     return make_pair(problems, problemType);
+ }
+ 
+diff --git a/libdnf/module/ModulePackageContainer.hpp b/libdnf/module/ModulePackageContainer.hpp
+index f19c60fd..99fc0677 100644
+--- a/libdnf/module/ModulePackageContainer.hpp
++++ b/libdnf/module/ModulePackageContainer.hpp
+@@ -48,17 +48,15 @@ public:
+     enum class ModuleErrorType {
+         NO_ERROR = 0,
+         INFO,
+-        /// Error in module defaults detected during resolvement of module dependencies
++        /// Error in module defaults detected during resovement of module dependencies
+         ERROR_IN_DEFAULTS,
+-        /// Error detected during resolvement of module dependencies
++        /// Error detected during resovement of module dependencies
+         ERROR,
+-        /// Error detected during resolvement of module dependencies - Unexpected error!!!
++        /// Error detected during resovement of module dependencies - Unexpected error!!!
+         CANNOT_RESOLVE_MODULES,
+         CANNOT_RESOLVE_MODULE_SPEC,
+         CANNOT_ENABLE_MULTIPLE_STREAMS,
+-        CANNOT_MODIFY_MULTIPLE_TIMES_MODULE_STATE,
+-        /// Problem with latest modules during resolvement of module dependencies
+-        ERROR_IN_LATEST
++        CANNOT_MODIFY_MULTIPLE_TIMES_MODULE_STATE
+     };
+     
+     struct Exception : public std::runtime_error
+-- 
+2.31.1
+
diff --git a/SOURCES/0006-Add-new-option-module-stream-switch.patch b/SOURCES/0006-Add-new-option-module-stream-switch.patch
deleted file mode 100644
index 1a9cfd9..0000000
--- a/SOURCES/0006-Add-new-option-module-stream-switch.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-From a1c96ecae6f2052407345a66293710109323de3a Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
-Date: Tue, 21 Jul 2020 15:37:05 +0200
-Subject: [PATCH] Add new option module_stream_switch
-
-= changelog =
-msg: Add new options module_stream_switch
-type: enhancement
----
- libdnf/conf/ConfigMain.cpp | 3 +++
- libdnf/conf/ConfigMain.hpp | 1 +
- 2 files changed, 4 insertions(+)
-
-diff --git a/libdnf/conf/ConfigMain.cpp b/libdnf/conf/ConfigMain.cpp
-index 1ffd3b336..abfc2082b 100644
---- a/libdnf/conf/ConfigMain.cpp
-+++ b/libdnf/conf/ConfigMain.cpp
-@@ -278,6 +278,7 @@ class ConfigMain::Impl {
-     OptionBool downloadonly{false}; // runtime only option
-     OptionBool ignorearch{false};
-     OptionString module_platform_id{nullptr};
-+    OptionBool module_stream_switch{false};
- 
-     OptionString user_agent{getUserAgent()};
-     OptionBool countme{false};
-@@ -434,6 +435,7 @@ ConfigMain::Impl::Impl(Config & owner)
-     owner.optBinds().add("comment", comment);
-     owner.optBinds().add("ignorearch", ignorearch);
-     owner.optBinds().add("module_platform_id", module_platform_id);
-+    owner.optBinds().add("module_stream_switch", module_stream_switch);
-     owner.optBinds().add("user_agent", user_agent);
-     owner.optBinds().add("countme", countme);
-     owner.optBinds().add("protect_running_kernel", protect_running_kernel);
-@@ -569,6 +571,7 @@ OptionBool & ConfigMain::downloadonly() { return pImpl->downloadonly; }
- OptionBool & ConfigMain::ignorearch() { return pImpl->ignorearch; }
- 
- OptionString & ConfigMain::module_platform_id() { return pImpl->module_platform_id; }
-+OptionBool & ConfigMain::module_stream_switch() { return pImpl->module_stream_switch; }
- OptionString & ConfigMain::user_agent() { return pImpl->user_agent; }
- OptionBool & ConfigMain::countme() { return pImpl->countme; }
- OptionBool & ConfigMain::protect_running_kernel() {return pImpl->protect_running_kernel; }
-diff --git a/libdnf/conf/ConfigMain.hpp b/libdnf/conf/ConfigMain.hpp
-index 226c74d50..835e1fc65 100644
---- a/libdnf/conf/ConfigMain.hpp
-+++ b/libdnf/conf/ConfigMain.hpp
-@@ -125,6 +125,7 @@ class ConfigMain : public Config {
-     OptionBool & ignorearch();
- 
-     OptionString & module_platform_id();
-+    OptionBool & module_stream_switch();
-     OptionString & user_agent();
-     OptionBool & countme();
-     OptionBool & protect_running_kernel();
diff --git a/SOURCES/0006-Revert-Add-additional-fallback-for-module-resolve.patch b/SOURCES/0006-Revert-Add-additional-fallback-for-module-resolve.patch
new file mode 100644
index 0000000..cecce8c
--- /dev/null
+++ b/SOURCES/0006-Revert-Add-additional-fallback-for-module-resolve.patch
@@ -0,0 +1,62 @@
+From 15a06ef27466f42a8dc39823385f0ca655e80b12 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:53 +0200
+Subject: [PATCH 06/19] Revert "Add additional fallback for module resolve"
+
+This reverts commit fc98ce725181a77bbe0ab157d40443467612c0c0.
+---
+ libdnf/module/ModulePackageContainer.cpp | 32 ++++++++----------------
+ 1 file changed, 11 insertions(+), 21 deletions(-)
+
+diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
+index ee90056c..e19db08b 100644
+--- a/libdnf/module/ModulePackageContainer.cpp
++++ b/libdnf/module/ModulePackageContainer.cpp
+@@ -702,33 +702,23 @@ ModulePackageContainer::Impl::moduleSolve(const std::vector<ModulePackage *> & m
+     std::vector<std::vector<std::string>> problems;
+     auto problemType = ModulePackageContainer::ModuleErrorType::NO_ERROR;
+     if (ret) {
+-        // Goal run ignor problem in defaults
+         problems = goal.describeAllProblemRules(false);
+         ret = goal.run(DNF_FORCE_BEST);
+         if (ret) {
+-            // Goal run ignor problem in defaults and in latest
+-            ret = goal.run(DNF_NONE);
++            // Conflicting modules has to be removed otherwice it could result than one of them will
++            // be active
++            auto conflictingPkgs = goal.listConflictPkgs(DNF_PACKAGE_STATE_AVAILABLE);
++            dnf_sack_add_excludes(moduleSack, conflictingPkgs.get());
++            ret = goalWeak.run(DNF_NONE);
+             if (ret) {
+-                // Conflicting modules has to be removed otherwice it could result than one of them will
+-                // be active
+-                auto conflictingPkgs = goal.listConflictPkgs(DNF_PACKAGE_STATE_AVAILABLE);
+-                dnf_sack_add_excludes(moduleSack, conflictingPkgs.get());
+-                ret = goalWeak.run(DNF_NONE);
+-                if (ret) {
+-                    auto logger(Log::getLogger());
+-                    logger->critical("Modularity filtering totally broken\n");
+-                    problemType = ModulePackageContainer::ModuleErrorType::CANNOT_RESOLVE_MODULES;
+-                    activatedModules.reset();
+-                } else {
+-                    problemType = ModulePackageContainer::ModuleErrorType::ERROR;
+-                    Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
+-                    goal2name_query(goalWeak, query);
+-                    activatedModules.reset(new PackageSet(*query.runSet()));
+-                }
++                auto logger(Log::getLogger());
++                logger->critical("Modularity filtering totally broken\n");
++                problemType = ModulePackageContainer::ModuleErrorType::CANNOT_RESOLVE_MODULES;
++                activatedModules.reset();
+             } else {
+-                problemType = ModulePackageContainer::ModuleErrorType::ERROR_IN_DEFAULTS;
++                problemType = ModulePackageContainer::ModuleErrorType::ERROR;
+                 Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
+-                goal2name_query(goal, query);
++                goal2name_query(goalWeak, query);
+                 activatedModules.reset(new PackageSet(*query.runSet()));
+             }
+         } else {
+-- 
+2.31.1
+
diff --git a/SOURCES/0007-Fix-removal-step-during-modular-enable-in-context-part.patch b/SOURCES/0007-Fix-removal-step-during-modular-enable-in-context-part.patch
deleted file mode 100644
index d43bfcc..0000000
--- a/SOURCES/0007-Fix-removal-step-during-modular-enable-in-context-part.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From 831d023c3c6fb4a28903cb3170efdd9f85645e1a Mon Sep 17 00:00:00 2001
-From: Jaroslav Mracek <jmracek@redhat.com>
-Date: Fri, 20 Nov 2020 16:30:17 +0100
-Subject: [PATCH] Fix removal step during modular enable in context part
-
-It resolves `free(): double free detected in tcache 2`
----
- libdnf/dnf-context.cpp | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/libdnf/dnf-context.cpp b/libdnf/dnf-context.cpp
-index 069267119..bc4a15b68 100644
---- a/libdnf/dnf-context.cpp
-+++ b/libdnf/dnf-context.cpp
-@@ -3087,7 +3087,7 @@ static std::vector<std::tuple<libdnf::ModulePackageContainer::ModuleErrorType, s
-             }
-             for (auto iter = stream_dict.begin(); iter != stream_dict.end(); ) {
-                 if (iter->first != enabledOrDefaultStream) {
--                    stream_dict.erase(iter);
-+                    stream_dict.erase(iter++);
-                 } else {
-                     ++iter;
-                 }
diff --git a/SOURCES/0007-Revert-Decide-how-to-handle-context-according-to-sta.patch b/SOURCES/0007-Revert-Decide-how-to-handle-context-according-to-sta.patch
new file mode 100644
index 0000000..3b596fa
--- /dev/null
+++ b/SOURCES/0007-Revert-Decide-how-to-handle-context-according-to-sta.patch
@@ -0,0 +1,27 @@
+From 0a92554dc2df3d2241b289bb796bc997c2959aaa Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:53 +0200
+Subject: [PATCH 07/19] Revert "Decide how to handle context according to
+ static_context value"
+
+This reverts commit 66439ed5a57373dfd106379637a9400b107e160c.
+---
+ libdnf/module/modulemd/ModuleMetadata.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libdnf/module/modulemd/ModuleMetadata.cpp b/libdnf/module/modulemd/ModuleMetadata.cpp
+index ee6834c6..07817ce1 100644
+--- a/libdnf/module/modulemd/ModuleMetadata.cpp
++++ b/libdnf/module/modulemd/ModuleMetadata.cpp
+@@ -142,7 +142,7 @@ std::vector<ModulePackage *> ModuleMetadata::getAllModulePackages(DnfSack * modu
+         //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<ModulemdModuleStream *>(g_ptr_array_index(streams, i));
+-            if (modulemd_module_stream_v2_is_static_context((ModulemdModuleStreamV2 *) moduleMdStream)) {
++            if (modulemd_module_stream_get_mdversion(moduleMdStream) > 2) {
+                 result.push_back(new ModulePackage(moduleSack, repo, moduleMdStream, repoID));
+             } else {
+                 g_object_ref(moduleMdStream);
+-- 
+2.31.1
+
diff --git a/SOURCES/0008-Revert-Fix-load-update-FailSafe.patch b/SOURCES/0008-Revert-Fix-load-update-FailSafe.patch
new file mode 100644
index 0000000..f700d85
--- /dev/null
+++ b/SOURCES/0008-Revert-Fix-load-update-FailSafe.patch
@@ -0,0 +1,76 @@
+From 140168ce29d2425ebf2b4b5b25926611a189cd84 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:53 +0200
+Subject: [PATCH 08/19] Revert "Fix load/update FailSafe"
+
+This reverts commit 244a37d772fcd5a5969085edab544fb1e7b68aad.
+---
+ libdnf/module/ModulePackageContainer.cpp | 38 ++++++++++++++++++------
+ 1 file changed, 29 insertions(+), 9 deletions(-)
+
+diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
+index e19db08b..97c84c01 100644
+--- a/libdnf/module/ModulePackageContainer.cpp
++++ b/libdnf/module/ModulePackageContainer.cpp
+@@ -1641,7 +1641,6 @@ ModulePackageContainer::Impl::ModulePersistor::getRemovedProfiles()
+ 
+ void ModulePackageContainer::loadFailSafeData()
+ {
+-    pImpl->addVersion2Modules();
+     auto persistor = pImpl->persistor->configs;
+ 
+     std::map<std::string, std::pair<std::string, bool>> enabledStreams;
+@@ -1696,21 +1695,42 @@ void ModulePackageContainer::loadFailSafeData()
+ 
+ std::vector<ModulePackage *> ModulePackageContainer::Impl::getLatestActiveEnabledModules()
+ {
+-    Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
+-    query.addFilter(HY_PKG, HY_EQ, activatedModules.get());
+-    query.addFilter(HY_PKG_REPONAME, HY_NEQ, HY_SYSTEM_REPO_NAME);
+-    query.addFilter(HY_PKG_LATEST_PER_ARCH, HY_EQ, 1);
+-    auto set = query.runSet();
+-
+     std::vector<ModulePackage *> activeModules;
+     Id moduleId = -1;
+-    while ((moduleId = set->next(moduleId)) != -1) {
++    while ((moduleId = activatedModules->next(moduleId)) != -1) {
+         auto modulePackage = modules.at(moduleId).get();
+         if (isEnabled(modulePackage->getName(), modulePackage->getStream())) {
+             activeModules.push_back(modulePackage);
+         }
+     }
+-    return activeModules;
++    if (activeModules.empty()) {
++        return {};
++    }
++    auto sack = moduleSack;
++    std::sort(activeModules.begin(), activeModules.end(),
++              [sack](const ModulePackage * first, const ModulePackage * second)
++              {return modulePackageLatestSorter(sack, first, second);});
++
++    auto packageFirst = activeModules[0];
++    std::vector<ModulePackage *> latest;
++    auto vectorSize = activeModules.size();
++    latest.push_back(packageFirst);
++    auto name = packageFirst->getNameCStr();
++    auto stream = packageFirst->getStreamCStr();
++    auto arch = packageFirst->getArchCStr();
++
++    for (unsigned int index = 1; index < vectorSize; ++index) {
++        auto & package = activeModules[index];
++        if (g_strcmp0(package->getNameCStr(), name) != 0 ||
++            g_strcmp0(package->getStreamCStr(), stream) != 0 ||
++            g_strcmp0(package->getArchCStr(), arch) != 0) {
++            name = package->getNameCStr();
++            stream = package->getStreamCStr();
++            arch = package->getArchCStr();
++            latest.push_back(package);
++        }
++    }
++    return latest;
+ }
+ 
+ void ModulePackageContainer::Impl::addVersion2Modules()
+-- 
+2.31.1
+
diff --git a/SOURCES/0009-Revert-Change-mechanism-of-module-conflicts.patch b/SOURCES/0009-Revert-Change-mechanism-of-module-conflicts.patch
new file mode 100644
index 0000000..7b583b3
--- /dev/null
+++ b/SOURCES/0009-Revert-Change-mechanism-of-module-conflicts.patch
@@ -0,0 +1,78 @@
+From e43ef244e78d8563eb3cb7ff6a6074946f60c877 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:53 +0200
+Subject: [PATCH 09/19] Revert "Change mechanism of module conflicts"
+
+This reverts commit 49600ba05b474bc29651aa122a9116b5ada69f4d.
+---
+ libdnf/dnf-sack.cpp                      | 1 +
+ libdnf/module/ModulePackage.cpp          | 2 --
+ libdnf/module/ModulePackage.hpp          | 1 -
+ libdnf/module/ModulePackageContainer.cpp | 1 -
+ libdnf/module/ModulePackageContainer.hpp | 1 -
+ 5 files changed, 1 insertion(+), 5 deletions(-)
+
+diff --git a/libdnf/dnf-sack.cpp b/libdnf/dnf-sack.cpp
+index b5c7edc0..b9baeaef 100644
+--- a/libdnf/dnf-sack.cpp
++++ b/libdnf/dnf-sack.cpp
+@@ -2297,6 +2297,7 @@ void readModuleMetadataFromRepo(DnfSack * sack, libdnf::ModulePackageContainer *
+     modulePackages->add(sack);
+     modulePackages->loadFailSafeData();
+     if (!modulePackages->empty()) {
++        modulePackages->createConflictsBetweenStreams();
+         // TODO remove hard-coded path
+         try {
+             std::vector<std::string> paths{"/etc/os-release", "/usr/lib/os-release"};
+diff --git a/libdnf/module/ModulePackage.cpp b/libdnf/module/ModulePackage.cpp
+index d0017877..d644eca6 100644
+--- a/libdnf/module/ModulePackage.cpp
++++ b/libdnf/module/ModulePackage.cpp
+@@ -75,8 +75,6 @@ static void setSovable(Pool * pool, Solvable * solvable, const std::string & nam
+     ss << "module(" << name << ")";
+     auto depId = pool_str2id(pool, ss.str().c_str(), 1);
+     solvable_add_deparray(solvable, SOLVABLE_PROVIDES, depId, -1);
+-    // create Conflicts: module($name)
+-    solvable_add_deparray(solvable, SOLVABLE_CONFLICTS, depId, 0);
+ 
+     // create Provide: module($name:$stream)
+     ss.str(std::string());
+diff --git a/libdnf/module/ModulePackage.hpp b/libdnf/module/ModulePackage.hpp
+index b618df58..145c6d63 100644
+--- a/libdnf/module/ModulePackage.hpp
++++ b/libdnf/module/ModulePackage.hpp
+@@ -71,7 +71,6 @@ public:
+ 
+     std::vector<ModuleDependencies> getModuleDependencies() const;
+ 
+-    ///DEPRECATED
+     void addStreamConflict(const ModulePackage * package);
+ 
+     Id getId() const { return id; };
+diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
+index 97c84c01..893b839a 100644
+--- a/libdnf/module/ModulePackageContainer.cpp
++++ b/libdnf/module/ModulePackageContainer.cpp
+@@ -204,7 +204,6 @@ private:
+     /// solvable.arch = <moduleArch>
+     /// solvable.summary = <moduleContext>
+     /// solvable.description = <moduleName>:<moduleStream>
+-    /// solvable.conflicts = module(<moduleName>)
+     DnfSack * moduleSack;
+     std::unique_ptr<PackageSet> activatedModules;
+     std::string installRoot;
+diff --git a/libdnf/module/ModulePackageContainer.hpp b/libdnf/module/ModulePackageContainer.hpp
+index 99fc0677..c1001fce 100644
+--- a/libdnf/module/ModulePackageContainer.hpp
++++ b/libdnf/module/ModulePackageContainer.hpp
+@@ -115,7 +115,6 @@ public:
+     Id addPlatformPackage(const std::string &osReleasePath, const char *  platformModule);
+     Id addPlatformPackage(DnfSack * sack,
+         const std::vector<std::string> & osReleasePath, const char * platformModule);
+-    /// DEPRECATED
+     void createConflictsBetweenStreams();
+ 
+     /**
+-- 
+2.31.1
+
diff --git a/SOURCES/0010-Revert-Call-addVersion2Modules-as-late-as-possible.patch b/SOURCES/0010-Revert-Call-addVersion2Modules-as-late-as-possible.patch
new file mode 100644
index 0000000..67c720e
--- /dev/null
+++ b/SOURCES/0010-Revert-Call-addVersion2Modules-as-late-as-possible.patch
@@ -0,0 +1,214 @@
+From 058b6112374f5feb5ee57488ac3fdbc7666a2016 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:53 +0200
+Subject: [PATCH 10/19] Revert "Call addVersion2Modules(); as late as possible"
+
+This reverts commit fe27dba67384e549a3be2a91c4a6cf1151113157.
+---
+ libdnf/module/ModulePackageContainer.cpp | 28 +++---------------------
+ 1 file changed, 3 insertions(+), 25 deletions(-)
+
+diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
+index 893b839a..6ee2b68f 100644
+--- a/libdnf/module/ModulePackageContainer.cpp
++++ b/libdnf/module/ModulePackageContainer.cpp
+@@ -346,6 +346,7 @@ ModulePackageContainer::add(DnfSack * sack)
+                             exception.what()));
+         }
+     }
++    pImpl->addVersion2Modules();
+ }
+ 
+ void ModulePackageContainer::addDefaultsFromDisk()
+@@ -427,7 +428,6 @@ void ModulePackageContainer::createConflictsBetweenStreams()
+ 
+ bool ModulePackageContainer::empty() const noexcept
+ {
+-    pImpl->addVersion2Modules();
+     return pImpl->modules.empty();
+ }
+ 
+@@ -521,13 +521,11 @@ bool ModulePackageContainer::isDisabled(const ModulePackage * module)
+ std::vector<std::string> ModulePackageContainer::getDefaultProfiles(std::string moduleName,
+     std::string moduleStream)
+ {
+-    pImpl->addVersion2Modules();
+     return pImpl->moduleMetadata.getDefaultProfiles(moduleName, moduleStream);
+ }
+ 
+ const std::string & ModulePackageContainer::getDefaultStream(const std::string &name) const
+ {
+-    pImpl->addVersion2Modules();
+     auto it = pImpl->moduleDefaults.find(name);
+     if (it == pImpl->moduleDefaults.end()) {
+         return EMPTY_RESULT;
+@@ -537,7 +535,6 @@ const std::string & ModulePackageContainer::getDefaultStream(const std::string &
+ 
+ const std::string & ModulePackageContainer::getEnabledStream(const std::string &name)
+ {
+-    pImpl->addVersion2Modules();
+     return pImpl->persistor->getStream(name);
+ }
+ 
+@@ -547,7 +544,6 @@ const std::string & ModulePackageContainer::getEnabledStream(const std::string &
+ bool
+ ModulePackageContainer::enable(const std::string &name, const std::string & stream, const bool count)
+ {
+-    pImpl->addVersion2Modules();
+     if (count) {
+         pImpl->persistor->getEntry(name).second.streamChangesNum++;
+     }
+@@ -573,7 +569,6 @@ ModulePackageContainer::enable(const ModulePackage * module, const bool count)
+  */
+ void ModulePackageContainer::disable(const std::string & name, const bool count)
+ {
+-    pImpl->addVersion2Modules();
+     if (count) {
+         pImpl->persistor->getEntry(name).second.streamChangesNum++;
+     }
+@@ -594,11 +589,11 @@ void ModulePackageContainer::disable(const ModulePackage * module, const bool co
+  */
+ void ModulePackageContainer::reset(const std::string & name, const bool count)
+ {
+-    pImpl->addVersion2Modules();
+     if (count) {
+         pImpl->persistor->getEntry(name).second.streamChangesNum++;
+     }
+     pImpl->persistor->changeState(name, ModuleState::UNKNOWN);
++
+     pImpl->persistor->changeStream(name, "");
+     auto & profiles = pImpl->persistor->getEntry(name).second.profiles;
+     profiles.clear();
+@@ -638,7 +633,6 @@ bool ModulePackageContainer::isChanged()
+ void ModulePackageContainer::install(const std::string &name, const std::string &stream,
+     const std::string &profile)
+ {
+-    pImpl->addVersion2Modules();
+     for (const auto &iter : pImpl->modules) {
+         auto modulePackage = iter.second.get();
+         if (modulePackage->getName() == name && modulePackage->getStream() == stream) {
+@@ -656,7 +650,6 @@ void ModulePackageContainer::install(const ModulePackage * module, const std::st
+ void ModulePackageContainer::uninstall(const std::string &name, const std::string &stream,
+     const std::string &profile)
+ {
+-    pImpl->addVersion2Modules();
+     for (const auto &iter : pImpl->modules) {
+         auto modulePackage = iter.second.get();
+         if (modulePackage->getName() == name && modulePackage->getStream() == stream) {
+@@ -744,7 +737,6 @@ ModulePackageContainer::query(Nsvcap& moduleNevra)
+ std::vector<ModulePackage *>
+ ModulePackageContainer::query(std::string subject)
+ {
+-    pImpl->addVersion2Modules();
+     // Alternatively a search using module provides could be performed
+     std::vector<ModulePackage *> result;
+     Query query(pImpl->moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
+@@ -765,7 +757,6 @@ std::vector<ModulePackage *>
+ ModulePackageContainer::query(std::string name, std::string stream, std::string version,
+     std::string context, std::string arch)
+ {
+-    pImpl->addVersion2Modules();
+     // Alternatively a search using module provides could be performed
+     std::vector<ModulePackage *> result;
+     Query query(pImpl->moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
+@@ -847,7 +838,6 @@ ModulePackageContainer::getModuleState(const std::string& name)
+ 
+ std::set<std::string> ModulePackageContainer::getInstalledPkgNames()
+ {
+-    pImpl->addVersion2Modules();
+     auto moduleNames = pImpl->persistor->getAllModuleNames();
+     std::set<std::string> pkgNames;
+     for (auto & moduleName: moduleNames) {
+@@ -1029,7 +1019,6 @@ std::vector<std::vector<std::vector<ModulePackage *>>>
+ ModulePackageContainer::getLatestModulesPerRepo(ModuleState moduleFilter,
+     std::vector<ModulePackage *> modulePackages)
+ {
+-    pImpl->addVersion2Modules();
+     if (modulePackages.empty()) {
+         return {};
+     }
+@@ -1113,7 +1102,6 @@ ModulePackageContainer::getLatestModulesPerRepo(ModuleState moduleFilter,
+ std::pair<std::vector<std::vector<std::string>>, ModulePackageContainer::ModuleErrorType>
+ ModulePackageContainer::resolveActiveModulePackages(bool debugSolver)
+ {
+-    pImpl->addVersion2Modules();
+     dnf_sack_reset_excludes(pImpl->moduleSack);
+     std::vector<ModulePackage *> packages;
+ 
+@@ -1164,7 +1152,6 @@ bool ModulePackageContainer::isModuleActive(const ModulePackage * modulePackage)
+ 
+ std::vector<ModulePackage *> ModulePackageContainer::getModulePackages()
+ {
+-    pImpl->addVersion2Modules();
+     std::vector<ModulePackage *> values;
+     const auto & modules = pImpl->modules;
+     std::transform(
+@@ -1186,56 +1173,47 @@ void ModulePackageContainer::rollback()
+ 
+ std::map<std::string, std::string> ModulePackageContainer::getEnabledStreams()
+ {
+-    pImpl->addVersion2Modules();
+     return pImpl->persistor->getEnabledStreams();
+ }
+ 
+ std::vector<std::string> ModulePackageContainer::getDisabledModules()
+ {
+-    pImpl->addVersion2Modules();
+     return pImpl->persistor->getDisabledModules();
+ }
+ 
+ std::map<std::string, std::string> ModulePackageContainer::getDisabledStreams()
+ {
+-    pImpl->addVersion2Modules();
+     return pImpl->persistor->getDisabledStreams();
+ }
+ 
+ std::vector<std::string> ModulePackageContainer::getResetModules()
+ {
+-    pImpl->addVersion2Modules();
+     return pImpl->persistor->getResetModules();
+ }
+ 
+ std::map<std::string, std::string> ModulePackageContainer::getResetStreams()
+ {
+-    pImpl->addVersion2Modules();
+     return pImpl->persistor->getResetStreams();
+ }
+ 
+ std::map<std::string, std::pair<std::string, std::string>>
+ ModulePackageContainer::getSwitchedStreams()
+ {
+-    pImpl->addVersion2Modules();
+     return pImpl->persistor->getSwitchedStreams();
+ }
+ 
+ std::map<std::string, std::vector<std::string>> ModulePackageContainer::getInstalledProfiles()
+ {
+-    pImpl->addVersion2Modules();
+     return pImpl->persistor->getInstalledProfiles();
+ }
+ 
+ std::vector<std::string> ModulePackageContainer::getInstalledProfiles(std::string moduleName)
+ {
+-    pImpl->addVersion2Modules();
+     return pImpl->persistor->getProfiles(moduleName);
+ }
+ 
+ std::map<std::string, std::vector<std::string>> ModulePackageContainer::getRemovedProfiles()
+ {
+-    pImpl->addVersion2Modules();
+     return pImpl->persistor->getRemovedProfiles();
+ }
+ const std::string &
+@@ -1641,7 +1619,7 @@ ModulePackageContainer::Impl::ModulePersistor::getRemovedProfiles()
+ void ModulePackageContainer::loadFailSafeData()
+ {
+     auto persistor = pImpl->persistor->configs;
+-
++    
+     std::map<std::string, std::pair<std::string, bool>> enabledStreams;
+     for (auto & nameConfig: persistor) {
+         if (nameConfig.second.second.state == ModuleState::ENABLED) {
+-- 
+2.31.1
+
diff --git a/SOURCES/0011-Revert-Fix-modular-queries-with-the-new-solver.patch b/SOURCES/0011-Revert-Fix-modular-queries-with-the-new-solver.patch
new file mode 100644
index 0000000..261dbed
--- /dev/null
+++ b/SOURCES/0011-Revert-Fix-modular-queries-with-the-new-solver.patch
@@ -0,0 +1,108 @@
+From 83703689de978cbb5e38f04fb1d9f554026de5ba Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:53 +0200
+Subject: [PATCH 11/19] Revert "Fix modular queries with the new solver"
+
+This reverts commit a9f99a4969831f5d0e21d0f2b2b088ff6546604b.
+---
+ libdnf/module/ModulePackage.cpp          | 17 ++++-------------
+ libdnf/module/ModulePackageContainer.cpp | 13 ++-----------
+ libdnf/module/ModulePackageContainer.hpp |  2 +-
+ 3 files changed, 7 insertions(+), 25 deletions(-)
+
+diff --git a/libdnf/module/ModulePackage.cpp b/libdnf/module/ModulePackage.cpp
+index d644eca6..63ee1656 100644
+--- a/libdnf/module/ModulePackage.cpp
++++ b/libdnf/module/ModulePackage.cpp
+@@ -52,7 +52,7 @@ namespace libdnf {
+  *   Provides: module($name:$stream)
+  */
+ static void setSovable(Pool * pool, Solvable * solvable, const std::string & name,
+-    const std::string & stream, const std::string & version, const std::string & context, const char * arch, const std::string & original_context)
++    const std::string & stream, const std::string & version, const std::string & context, const char * arch)
+ {
+     std::ostringstream ss;
+     //   Name: $name:$stream:$context
+@@ -62,14 +62,6 @@ static void setSovable(Pool * pool, Solvable * solvable, const std::string & nam
+     // TODO Test can be remove when modules will be always with arch
+     solvable_set_str(solvable, SOLVABLE_ARCH, arch ? arch : "noarch");
+ 
+-    // store original context in summary
+-    solvable_set_str(solvable, SOLVABLE_SUMMARY, original_context.c_str());
+-
+-    // store original name:stream in description
+-    ss.str(std::string());
+-    ss << name << ":" << stream;
+-    solvable_set_str(solvable, SOLVABLE_DESCRIPTION, ss.str().c_str());
+-
+     // create Provide: module($name)
+     ss.str(std::string());
+     ss << "module(" << name << ")";
+@@ -105,9 +97,8 @@ ModulePackage::ModulePackage(DnfSack * moduleSack, LibsolvRepo * repo,
+     Pool * pool = dnf_sack_get_pool(moduleSack);
+     id = repo_add_solvable(repo);
+     Solvable *solvable = pool_id2solvable(pool, id);
+-    std::string original_context = getContext();
+-    setSovable(pool, solvable, getName(), getStream(), getVersion(), context.empty() ? original_context : context,
+-               getArchCStr(), original_context);
++
++    setSovable(pool, solvable, getName(), getStream(), getVersion(), context.empty() ? getContext() : context, getArchCStr());
+     createDependencies(solvable);
+     HyRepo hyRepo = static_cast<HyRepo>(repo->appdata);
+     libdnf::repoGetImpl(hyRepo)->needs_internalizing = 1;
+@@ -649,7 +640,7 @@ ModulePackage::createPlatformSolvable(DnfSack * sack, DnfSack * moduleSack,
+     repoImpl->needs_internalizing = 1;
+     Id id = repo_add_solvable(repo);
+     Solvable *solvable = pool_id2solvable(pool, id);
+-    setSovable(pool, solvable, name, stream, version, context, "noarch", context);
++    setSovable(pool, solvable, name, stream, version, context, "noarch");
+     repoImpl->needs_internalizing = 1;
+     dnf_sack_set_provides_not_ready(moduleSack);
+     dnf_sack_set_considered_to_update(moduleSack);
+diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
+index 6ee2b68f..3f30037e 100644
+--- a/libdnf/module/ModulePackageContainer.cpp
++++ b/libdnf/module/ModulePackageContainer.cpp
+@@ -197,13 +197,6 @@ private:
+     class ModulePersistor;
+     std::unique_ptr<ModulePersistor> persistor;
+     std::map<Id, std::unique_ptr<ModulePackage>> modules;
+-    /// Internal sack with module solvables
+-    /// resolveContext = <moduleContext> if moduleMdVersion > 2, else generated from requires
+-    /// solvable.name = <moduleName>:<moduleStream>:<resolveContext>
+-    /// solvable.evr = <moduleVersion>
+-    /// solvable.arch = <moduleArch>
+-    /// solvable.summary = <moduleContext>
+-    /// solvable.description = <moduleName>:<moduleStream>
+     DnfSack * moduleSack;
+     std::unique_ptr<PackageSet> activatedModules;
+     std::string installRoot;
+@@ -764,10 +757,8 @@ ModulePackageContainer::query(std::string name, std::string stream, std::string
+     query.available();
+     std::ostringstream ss;
+     ss << stringFormater(name) << ":" << stringFormater(stream);
+-    query.addFilter(HY_PKG_DESCRIPTION, HY_GLOB, ss.str().c_str());
+-    if (!context.empty()) {
+-        query.addFilter(HY_PKG_SUMMARY, HY_GLOB, context.c_str());
+-    }
++    ss << ":" << stringFormater(context);
++    query.addFilter(HY_PKG_NAME, HY_GLOB, ss.str().c_str());
+     if (!arch.empty()) {
+         query.addFilter(HY_PKG_ARCH, HY_GLOB, arch.c_str());
+     }
+diff --git a/libdnf/module/ModulePackageContainer.hpp b/libdnf/module/ModulePackageContainer.hpp
+index c1001fce..7e5071b2 100644
+--- a/libdnf/module/ModulePackageContainer.hpp
++++ b/libdnf/module/ModulePackageContainer.hpp
+@@ -270,7 +270,7 @@ public:
+     */
+     std::vector<ModulePackage *> query(libdnf::Nsvcap & moduleNevra);
+     /**
+-    * @brief Requiers subject in format <name>, <name>:<stream>, or <name>:<stream>:<contex>
++    * @brief Requiers subject in format <name>, <name>:<stream>, or <name>:<stream>:<version>
+     *
+     * @param subject p_subject:...
+     * @return std::vector<ModulePackage *>
+-- 
+2.31.1
+
diff --git a/SOURCES/0012-Revert-Add-compatible-layer-for-MdDocuments-v2.patch b/SOURCES/0012-Revert-Add-compatible-layer-for-MdDocuments-v2.patch
new file mode 100644
index 0000000..a214d34
--- /dev/null
+++ b/SOURCES/0012-Revert-Add-compatible-layer-for-MdDocuments-v2.patch
@@ -0,0 +1,171 @@
+From 833966d8a8a6c87a3d51447f2adf2aa76190ecd8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+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<std::string> & 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<ModulePackage *> & modules, bool debugSolver);
+     bool insert(const std::string &moduleName, const char *path);
+     std::vector<ModulePackage *> 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<std::string, std::string> moduleDefaults;
+-    std::vector<std::tuple<LibsolvRepo *, ModulemdModuleStream *, std::string>> 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<ModulePackage *> packages = md.getAllModulePackages(pImpl->moduleSack, r, repoID);
+             for(auto const& modulePackagePtr: packages) {
+                 std::unique_ptr<ModulePackage> modulePackage(modulePackagePtr);
+                 pImpl->modules.insert(std::make_pair(modulePackage->getId(), std::move(modulePackage)));
+@@ -1701,50 +1679,6 @@ std::vector<ModulePackage *> ModulePackageContainer::Impl::getLatestActiveEnable
+     return latest;
+ }
+ 
+-void ModulePackageContainer::Impl::addVersion2Modules()
+-{
+-    if (modulesV2.empty()) {
+-        return;
+-    }
+-    std::map<std::string, std::map<std::string, std::vector<ModulePackage *>>> 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> 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> 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<ModulePackage *> ModuleMetadata::getAllModulePackages(DnfSack * moduleSack,
+                                                                   LibsolvRepo * repo,
+-                                                                  const std::string & repoID,
+-                                                                  std::vector<std::tuple<LibsolvRepo *, ModulemdModuleStream *, std::string>> & modulesV2)
++                                                                  const std::string & repoID)
+ {
+     std::vector<ModulePackage *> result;
+     if (!resultingModuleIndex)
+@@ -141,13 +140,7 @@ std::vector<ModulePackage *> 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<ModulemdModuleStream *>(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<ModulePackage *> getAllModulePackages(DnfSack * moduleSack, LibsolvRepo * repo, const std::string & repoID, std::vector<std::tuple<LibsolvRepo *, ModulemdModuleStream *, std::string>> & modulesV2);
++    std::vector<ModulePackage *> getAllModulePackages(DnfSack * moduleSack, LibsolvRepo * repo, const std::string & repoID);
+     std::map<std::string, std::string> getDefaultStreams();
+     std::vector<std::string> getDefaultProfiles(std::string moduleName, std::string moduleStream);
+     ModulemdObsoletes * getNewestActiveObsolete(ModulePackage *p);
+-- 
+2.31.1
+
diff --git a/SOURCES/0013-Revert-Add-an-alternative-constructor-for-ModulePack.patch b/SOURCES/0013-Revert-Add-an-alternative-constructor-for-ModulePack.patch
new file mode 100644
index 0000000..ce0d347
--- /dev/null
+++ b/SOURCES/0013-Revert-Add-an-alternative-constructor-for-ModulePack.patch
@@ -0,0 +1,77 @@
+From b1ed6e111ce05f8f1fe7b35afc1a3ef6f0731f7c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:53 +0200
+Subject: [PATCH 13/19] Revert "Add an alternative constructor for
+ ModulePackage"
+
+This reverts commit d05bb263de6822c13ac4bd5cca3628318f5c7ce7.
+---
+ libdnf/module/ModulePackage.cpp | 24 ++++++++++++------------
+ libdnf/module/ModulePackage.hpp |  2 +-
+ 2 files changed, 13 insertions(+), 13 deletions(-)
+
+diff --git a/libdnf/module/ModulePackage.cpp b/libdnf/module/ModulePackage.cpp
+index 63ee1656..8126bcaa 100644
+--- a/libdnf/module/ModulePackage.cpp
++++ b/libdnf/module/ModulePackage.cpp
+@@ -43,16 +43,16 @@ extern "C" {
+ 
+ namespace libdnf {
+ 
+-/**
+- * @brief create solvable with:
+- *   Name: $name:$stream:$context
+- *   Version: $version
+- *   Arch: $arch (If arch is not defined, set "noarch")
+- *   Provides: module($name)
+- *   Provides: module($name:$stream)
+- */
+-static void setSovable(Pool * pool, Solvable * solvable, const std::string & name,
+-    const std::string & stream, const std::string & version, const std::string & context, const char * arch)
++    /**
++     * @brief create solvable with:
++     *   Name: $name:$stream:$context
++     *   Version: $version
++     *   Arch: $arch (If arch is not defined, set "noarch")
++     *   Provides: module($name)
++     *   Provides: module($name:$stream)
++     */
++    static void setSovable(Pool * pool, Solvable *solvable, std::string & name,
++    std::string & stream, std::string & version, std::string & context, const char * arch)
+ {
+     std::ostringstream ss;
+     //   Name: $name:$stream:$context
+@@ -86,7 +86,7 @@ static std::pair<std::string, std::string> parsePlatform(const std::string & pla
+ }
+ 
+ ModulePackage::ModulePackage(DnfSack * moduleSack, LibsolvRepo * repo,
+-    ModulemdModuleStream * mdStream, const std::string & repoID, const std::string & context)
++    ModulemdModuleStream * mdStream, const std::string & repoID)
+         : mdStream(mdStream)
+         , moduleSack(moduleSack)
+         , repoID(repoID)
+@@ -98,7 +98,7 @@ ModulePackage::ModulePackage(DnfSack * moduleSack, LibsolvRepo * repo,
+     id = repo_add_solvable(repo);
+     Solvable *solvable = pool_id2solvable(pool, id);
+ 
+-    setSovable(pool, solvable, getName(), getStream(), getVersion(), context.empty() ? getContext() : context, getArchCStr());
++    setSovable(pool, solvable, getName(), getStream(), getVersion(), getContext(), getArchCStr());
+     createDependencies(solvable);
+     HyRepo hyRepo = static_cast<HyRepo>(repo->appdata);
+     libdnf::repoGetImpl(hyRepo)->needs_internalizing = 1;
+diff --git a/libdnf/module/ModulePackage.hpp b/libdnf/module/ModulePackage.hpp
+index 145c6d63..47cc995c 100644
+--- a/libdnf/module/ModulePackage.hpp
++++ b/libdnf/module/ModulePackage.hpp
+@@ -95,7 +95,7 @@ private:
+     friend struct ModuleMetadata;
+ 
+     ModulePackage(DnfSack * moduleSack, LibsolvRepo * repo,
+-        ModulemdModuleStream * mdStream, const std::string & repoID, const std::string & context = {});
++        ModulemdModuleStream * mdStream, const std::string & repoID);
+ 
+     ModulePackage(const ModulePackage & mpkg);
+     ModulePackage & operator=(const ModulePackage & mpkg);
+-- 
+2.31.1
+
diff --git a/SOURCES/0014-Revert-Adjust-modular-solver-to-new-context-type.patch b/SOURCES/0014-Revert-Adjust-modular-solver-to-new-context-type.patch
new file mode 100644
index 0000000..99bed9d
--- /dev/null
+++ b/SOURCES/0014-Revert-Adjust-modular-solver-to-new-context-type.patch
@@ -0,0 +1,113 @@
+From 6c9540be5ac3e3bc3f9a60133b402945705b934f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:53 +0200
+Subject: [PATCH 14/19] Revert "Adjust modular solver to new context type"
+
+This reverts commit 921d4db62cda41f7999aff67882ad0c01c766916.
+---
+ libdnf/module/ModulePackageContainer.cpp | 46 +++++-------------------
+ 1 file changed, 8 insertions(+), 38 deletions(-)
+
+diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
+index 6e6134d2..c0ad1260 100644
+--- a/libdnf/module/ModulePackageContainer.cpp
++++ b/libdnf/module/ModulePackageContainer.cpp
+@@ -49,28 +49,6 @@ extern "C" {
+ #include "modulemd/ModuleMetadata.hpp"
+ #include "modulemd/ModuleProfile.hpp"
+ 
+-
+-namespace {
+-
+-/// Requires resolved goal
+-/// Takes listInstalls() from goal and keep solvables with the solvable-name (<name>:<stream>:<context>) in query 
+-void goal2name_query(libdnf::Goal & goal, libdnf::Query & query)
+-{
+-    auto pool = dnf_sack_get_pool(goal.getSack());
+-    auto installList = goal.listInstalls();
+-    std::vector<const char *> module_names;
+-    Id id = -1;
+-    while ((id = installList.next(id)) != -1) {
+-        Solvable * s = pool_id2solvable(pool, id);
+-        const char * name = pool_id2str(pool, s->name);
+-        module_names.push_back(name);
+-    }
+-    module_names.push_back(nullptr);
+-    query.addFilter(HY_PKG_NAME, HY_EQ, module_names.data());
+-}
+-
+-}
+-
+ namespace std {
+ 
+ template<>
+@@ -651,14 +629,14 @@ ModulePackageContainer::Impl::moduleSolve(const std::vector<ModulePackage *> & m
+     for (const auto &module : modules) {
+         std::ostringstream ss;
+         auto name = module->getName();
+-        ss << "module(" << name << ":" << module->getStream() << ")";
++        ss << "module(" << name << ":" << module->getStream() << ":" << module->getVersion() << ")";
+         Selector selector(moduleSack);
+         bool optional = persistor->getState(name) == ModuleState::DEFAULT;
+         selector.set(HY_PKG_PROVIDES, HY_EQ, ss.str().c_str());
+         goal.install(&selector, optional);
+         goalWeak.install(&selector, true);
+     }
+-    auto ret = goal.run(static_cast<DnfGoalActions>(DNF_IGNORE_WEAK | DNF_FORCE_BEST));
++    auto ret = goal.run(DNF_IGNORE_WEAK);
+     if (debugSolver) {
+         goal.writeDebugdata("debugdata/modules");
+     }
+@@ -666,7 +644,7 @@ ModulePackageContainer::Impl::moduleSolve(const std::vector<ModulePackage *> & m
+     auto problemType = ModulePackageContainer::ModuleErrorType::NO_ERROR;
+     if (ret) {
+         problems = goal.describeAllProblemRules(false);
+-        ret = goal.run(DNF_FORCE_BEST);
++        ret = goal.run(DNF_NONE);
+         if (ret) {
+             // Conflicting modules has to be removed otherwice it could result than one of them will
+             // be active
+@@ -680,20 +658,14 @@ ModulePackageContainer::Impl::moduleSolve(const std::vector<ModulePackage *> & m
+                 activatedModules.reset();
+             } else {
+                 problemType = ModulePackageContainer::ModuleErrorType::ERROR;
+-                Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
+-                goal2name_query(goalWeak, query);
+-                activatedModules.reset(new PackageSet(*query.runSet()));
++                activatedModules.reset(new PackageSet(std::move(goalWeak.listInstalls())));
+             }
+         } else {
+             problemType = ModulePackageContainer::ModuleErrorType::ERROR_IN_DEFAULTS;
+-            Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
+-            goal2name_query(goal, query);
+-            activatedModules.reset(new PackageSet(*query.runSet()));
++            activatedModules.reset(new PackageSet(std::move(goal.listInstalls())));
+         }
+     } else {
+-        Query query(moduleSack, Query::ExcludeFlags::IGNORE_EXCLUDES);
+-        goal2name_query(goal, query);
+-        activatedModules.reset(new PackageSet(*query.runSet()));
++        activatedModules.reset(new PackageSet(std::move(goal.listInstalls())));
+     }
+     return make_pair(problems, problemType);
+ }
+@@ -735,14 +707,12 @@ ModulePackageContainer::query(std::string name, std::string stream, std::string
+     query.available();
+     std::ostringstream ss;
+     ss << stringFormater(name) << ":" << stringFormater(stream);
+-    ss << ":" << stringFormater(context);
++    ss << ":" << stringFormater(version) << ":";
++    ss << stringFormater(context);
+     query.addFilter(HY_PKG_NAME, HY_GLOB, ss.str().c_str());
+     if (!arch.empty()) {
+         query.addFilter(HY_PKG_ARCH, HY_GLOB, arch.c_str());
+     }
+-    if (!version.empty()) {
+-        query.addFilter(HY_PKG_VERSION, HY_GLOB, version.c_str());
+-    }
+     auto pset = query.runSet();
+     Id moduleId = -1;
+     while ((moduleId = pset->next(moduleId)) != -1) {
+-- 
+2.31.1
+
diff --git a/SOURCES/0015-Revert-Change-usage-of-context-and-version-in-modula.patch b/SOURCES/0015-Revert-Change-usage-of-context-and-version-in-modula.patch
new file mode 100644
index 0000000..6cfd63c
--- /dev/null
+++ b/SOURCES/0015-Revert-Change-usage-of-context-and-version-in-modula.patch
@@ -0,0 +1,65 @@
+From 50aa9f29dbfc1523a3b6aea41c6caa37f30c1bf0 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Sun, 25 Apr 2021 19:47:53 +0200
+Subject: [PATCH 15/19] Revert "Change usage of context and version in modular
+ solver"
+
+This reverts commit 1f4c5b2a37ec333b23a12b882b046fac858155aa.
+---
+ libdnf/module/ModulePackage.cpp | 28 ++++++++++++++--------------
+ 1 file changed, 14 insertions(+), 14 deletions(-)
+
+diff --git a/libdnf/module/ModulePackage.cpp b/libdnf/module/ModulePackage.cpp
+index 8126bcaa..eea4a8b5 100644
+--- a/libdnf/module/ModulePackage.cpp
++++ b/libdnf/module/ModulePackage.cpp
+@@ -43,25 +43,19 @@ extern "C" {
+ 
+ namespace libdnf {
+ 
+-    /**
+-     * @brief create solvable with:
+-     *   Name: $name:$stream:$context
+-     *   Version: $version
+-     *   Arch: $arch (If arch is not defined, set "noarch")
+-     *   Provides: module($name)
+-     *   Provides: module($name:$stream)
+-     */
+-    static void setSovable(Pool * pool, Solvable *solvable, std::string & name,
+-    std::string & stream, std::string & version, std::string & context, const char * arch)
++static void setSovable(Pool * pool, Solvable *solvable, std::string name,
++    std::string stream, std::string version, std::string context, const char * arch)
+ {
+     std::ostringstream ss;
+-    //   Name: $name:$stream:$context
+-    ss << name << ":" << stream << ":" << context;
++    // create solvable with:
++    //   Name: $name:$stream:$version:$context
++    //   Version: 0
++    //   Arch: $arch
++    ss << name << ":" << stream << ":" << version << ":" << context;
+     solvable_set_str(solvable, SOLVABLE_NAME, ss.str().c_str());
+-    solvable_set_str(solvable, SOLVABLE_EVR, version.c_str());
++    solvable_set_str(solvable, SOLVABLE_EVR, "0");
+     // TODO Test can be remove when modules will be always with arch
+     solvable_set_str(solvable, SOLVABLE_ARCH, arch ? arch : "noarch");
+-
+     // create Provide: module($name)
+     ss.str(std::string());
+     ss << "module(" << name << ")";
+@@ -73,6 +67,12 @@ namespace libdnf {
+     ss << "module(" << name << ":" << stream << ")";
+     depId = pool_str2id(pool, ss.str().c_str(), 1);
+     solvable_add_deparray(solvable, SOLVABLE_PROVIDES, depId, -1);
++
++    // create Provide: module($name:$stream:$version)
++    ss.str(std::string());
++    ss << "module(" << name << ":" << stream << ":" << version << ")";
++    depId = pool_str2id(pool, ss.str().c_str(), 1);
++    solvable_add_deparray(solvable, SOLVABLE_PROVIDES, depId, -1);
+ }
+ 
+ 
+-- 
+2.31.1
+
diff --git a/SOURCES/0016-Fix-failing-unittest-caused-by-the-revert-of-new-mod.patch b/SOURCES/0016-Fix-failing-unittest-caused-by-the-revert-of-new-mod.patch
new file mode 100644
index 0000000..6ea0adf
--- /dev/null
+++ b/SOURCES/0016-Fix-failing-unittest-caused-by-the-revert-of-new-mod.patch
@@ -0,0 +1,34 @@
+From faaa64a51445b6edffe6f1e65c465dea63f11bf7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
+Date: Tue, 27 Apr 2021 10:24:53 +0200
+Subject: [PATCH 16/19] Fix failing unittest, caused by the revert of new
+ modular implementation
+
+The problem is not caused by advisory filtering which we are testing
+here, the `query` is already created with just one package.
+---
+ tests/libdnf/sack/QueryTest.cpp | 5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/tests/libdnf/sack/QueryTest.cpp b/tests/libdnf/sack/QueryTest.cpp
+index ee9eeaf4..7c3a22af 100644
+--- a/tests/libdnf/sack/QueryTest.cpp
++++ b/tests/libdnf/sack/QueryTest.cpp
+@@ -139,13 +139,10 @@ void QueryTest::testQueryFilterAdvisory()
+     dnf_sack_filter_modules_v2(sack, modules, nullptr, tmpdir, nullptr, true, false, false);
+     query = new libdnf::Query(sack);
+     query->addFilter(HY_PKG_ADVISORY_TYPE, HY_EQ, "enhancement");
+-    CPPUNIT_ASSERT(query->size() == 2);
++    CPPUNIT_ASSERT(query->size() == 1);
+     libdnf::PackageSet pset2 = *(query->getResultPset());
+     pkg = dnf_package_new(sack, pset2[0]);
+     CPPUNIT_ASSERT(!g_strcmp0(dnf_package_get_name(pkg), "test-perl-DBI"));
+     g_object_unref(pkg);
+-    pkg = dnf_package_new(sack, pset2[1]);
+-    CPPUNIT_ASSERT(!g_strcmp0(dnf_package_get_name(pkg), "test-perl-DBI"));
+-    g_object_unref(pkg);
+     delete query;
+ }
+-- 
+2.31.1
+
diff --git a/SOURCES/0017-Modify-unit-test-after-change-of-handling-advisories.patch b/SOURCES/0017-Modify-unit-test-after-change-of-handling-advisories.patch
new file mode 100644
index 0000000..e4e2f5b
--- /dev/null
+++ b/SOURCES/0017-Modify-unit-test-after-change-of-handling-advisories.patch
@@ -0,0 +1,274 @@
+From a61b0105aafeea8487902463f789e6ed00021eb3 Mon Sep 17 00:00:00 2001
+From: Jaroslav Mracek <jmracek@redhat.com>
+Date: Wed, 5 May 2021 15:55:43 +0200
+Subject: [PATCH 17/19] Modify unit test after change of handling advisories
+
+The patch modifies also yaml with multicollection situation by adding
+module requires.
+---
+ data/tests/advisories/modules.yaml            |   6 +++++
+ .../tests/advisories/repodata/modules.yaml.gz | Bin 300 -> 332 bytes
+ data/tests/advisories/repodata/primary.xml.gz | Bin 743 -> 743 bytes
+ data/tests/advisories/repodata/repomd.xml     |  24 +++++++++---------
+ tests/libdnf/sack/AdvisoryTest.cpp            |  22 ++++++----------
+ tests/libdnf/sack/QueryTest.cpp               |  24 ++++++++----------
+ 6 files changed, 37 insertions(+), 39 deletions(-)
+
+diff --git a/data/tests/advisories/modules.yaml b/data/tests/advisories/modules.yaml
+index 6db5053a..b5f23f7d 100644
+--- a/data/tests/advisories/modules.yaml
++++ b/data/tests/advisories/modules.yaml
+@@ -32,6 +32,9 @@ data:
+   license:
+     module:
+     - MIT
++  dependencies:
++  - requires:
++      perl: ["5.23"]
+   profiles:
+     default:
+       rpms: ["test-perl-DBI"]
+@@ -52,6 +55,9 @@ data:
+   license:
+     module:
+     - MIT
++  dependencies:
++  - requires:
++      perl: ["5.25"]
+   profiles:
+     default:
+       rpms: ["test-perl-DBI"]
+diff --git a/data/tests/advisories/repodata/modules.yaml.gz b/data/tests/advisories/repodata/modules.yaml.gz
+index 7158e6c515720c87373762d722e9c438ac7fd8d3..ed39532dfcdec084a661d51d86e07bd3e4246f69 100644
+GIT binary patch
+literal 332
+zcmV-S0ki%eiwFP!000001I>{=Ps1<}hWGr6Q`gE7ag#Rnz<^jfATh8ZR2}w3Sc;us
+zJE;77+&V2`Kt&yZ?cV$H`F$8;nd;<V$OZwXQ$tHeWpCuX?yLZwDGVqw0E>nM^yJzo
+zd~k$Dz^uyoVipspfg%do*+9Fv4>2lq@<qU|UT&A=esnMf-MfJMv`UeePWRz3ea&J9
+zj-^&hvYx~tmu^cjgS*W`jC$8Kx+R~oiW(f+kOYA1jX%Z=0{Otk>(K?>pbTUAvvJbK
+zu0;G>$%;HZyrs6DS4GX|H7^S!#q;q?d7fwN0vp-w&1Pz)K_AF{F_TZt<j-f!92b6P
+z=vY2$s-m8(A}e(=mVu+!K|4CRxxZe(<DUJ~g%rkPencX+Mj8d<QxwapUd`9_YK@Jn
+eejSDUe<-TIL$NBWgd)&lisAzcI?AeD1ONa}51~l_
+
+literal 300
+zcmV+{0n`2;iwFP!000001Kp56Ps1<}#rJ%QQ`g85ar4LZz<^jfATh94hka2a*-2zO
+zsC;`&okAE82nhzZd++X^&p*akrbjhf8iE8n>e-Oh*%LY6kAnoBX$&YcfB`K@n8=wZ
+zd~k$T!lo|xb`y=ag)#~?4uMWF4>2lq>L}qPnnP2)uFlq?dzNsYqBMEs`YD{ZuUT~9
+z(lWiG!IM0D>9$lexZ6L(YI0-O8}iB3)ZuJG5&&+p{!%jt<O5r-M;H1IRan~ZgR3!i
+zCF9>JRu<{u0~wLmrQo^XRf(i|v3#j0ij4gLBfGuXuTfg`f!qg}d<~O7egSg{{0!*Q
+y{uQW8_P4;s(FnI>d`-5gMVs$LyTi`ae@<5YXR>WoC$fRIYqBpd!@UUm0{{Tgm5(X_
+
+diff --git a/data/tests/advisories/repodata/primary.xml.gz b/data/tests/advisories/repodata/primary.xml.gz
+index da9ffaf08328659c47be8721a9c478ff64ba0a4d..96cbaa2a5a2361b1e5cd59ddb7de937339982c5f 100644
+GIT binary patch
+literal 743
+zcmV<D0vP=tiwFP!000001Lao9Zrd;rz2_?ko>~O9B%0I`ND2@%1#&3RBI%*0fTBhg
+zVQr-(BktFi)Dqj>k`zsgpnzeM!#6X0Z#V;o=XYg+wxC*BR}prWHbzj1I+fKr!XIzm
+zE_{3*pM)iJJmnon8eX*#&bzKTv#df^{oOL{H?V}Xw`P<j>awgWJfhE3Q$FaSF&H&m
+zZ1@^<e1dh-X^XmD0}(ce_ynP_;w8i#wB4csRV?0IT!q$PGlyJ>JihbYTbG8`urbz&
+zAcCeAd4x4dZP9cwQc&n@%d$@U0&b!3PhIAFr-APUJW~u?gTKf@Y}&q@uF~e5FjwDq
+zvzBRuKV4qqc$Eb!8hEKs2%}j*IQ0ebAY}{^!F=%3#H9{l`Y>@gB?&m5V>{r|AoIZ2
+zx1Ey=8TD_;)o$Ra)1ddG7NIpC7*GnWP_pSXwfN*Fmo3sCj%Hbqah^pDts}Jdo(@zT
+zTK7w1?^U5q=G*K#Spv#rp=moVv3)HJ)zp(-7Mi-ld=@yAIAl_)m0w^^8DZD<DMqqt
+zJ6;r!4$7ON$gK%S=;Tz?f}3lhTtOD$quMT<#m~#L94oyvZ(|IV)vDy3S?Y~8pA}L-
+z)k6I4>L#=f4SUEIs<bvT9BlTdYgPA6e7$QsDA8rLm8z~vs5<L{w=nvQkiE+wPF}ZN
+zY?u{hH3IhsdvII#N`PL)PvG4uVMvcr_Yw9{bKohch2oWNAT7V@B21Z0O?#)NFw`Cu
+zoA8aQw^F~5(KHz~OSMC$x4tO~Mp?nvx=$}Z;NNYkhqJuW)m^ys^`FT$YIV$W$gkjY
+zFV$nH|LP)aIX~w))nVMwnjhwUv;DgP=TSDQ)4}TT1CDdwag)qW1VF|-lF*b;;bZ|1
+zAaQI#T&4p%e8n;rxT^$g0fA4l#Lc{bQ1?X-INM$QwE=fnp8sjU9r1o~1Md5#dd>m&
+ZqioMV;M}JUxcmQi@mJ$x7+z@#006pgY0dxu
+
+literal 743
+zcmV<D0vP=tiwFP!000001LamrZ`&{ozV}xMI&CNtTZ-gIVY@)F4(MUPhIWUY3R$LO
+zBYsV`gJ!>ek{?a7SKDFTPz(qXk^D&NBSj*?`CVC{EvPoHs}Pf=jS*C`PV#CU;*U3P
+z7al&3PJ$9Tk%&$p4X@e|XI<BvSyqu({oOL@H?V}Hw`P<j>$0pXJfhE3Q$FaSF&H&M
+zZp0dNe2R6_NkrYQfe;%+bb?S&i4vj?+HTQ+Di&`pt^#Y&8KY1#i|#z<)?tA)2u3>*
+zM9|bS3$Z4tHJUC)3JRTVS=LEkz%3Nsslz?@)c0Ipq>5u}@Ru3LP1~2#RoYBY?&$k&
+z)_D@*PnXv?TBZJq`EKG-%311D!8}P_NH~XBau2*Db{L^t8)G6Eje)qtCg3nXb-~lO
+zos$e1^=~QEZs4iYp!Z`f0&6xHPy($~dDCfX(aBAgw@7~kn#+QW^IX)xIznsj$)KXZ
+zx<49yuL`X)-$v^45>T2Knl^C=^<0m+ntI&lg{Drp$9=*mp;M*W{0qz}L+scd!zi!X
+zP80<sL*-3V@~sI++2mBzQkZL@OhFprquwsa;^*yIj-6hbw=srFYgLNQ9JQd;XGJcd
+zY9V@ebrV>JialftRZ^QW90+^sTGf3MUGLfsN_1Imb5&O*RGoDpS{Qvs$lhfrPFA;F
+zWSAA^Gy?aAJ-DrVB|)E}C-82SG^EF<`w07}8HfbbLWxQbkS@RKLd>|$%y=iJG0Yw-
+zHsKppZ*%=ZM%AR$EY%K~+4`m_7^Q_+>p8vrfPZ(W9?tSgcX#2i*MBD4SgT{6Lw*IH
+z`&>PS`mZj+m-BO;Qys<)todQy58J<6a4zFxbvjr*e!&Uh5hqUVSOTQnr7=q=lO*+p
+z4>7SNb+`^p#EPffcUCdj5`2%Qv6H$!WzLIUaJIAhYYXnMJ^#~!JL3J~7Totk^_&at
+ZN7<f#!8uP|aQFZ3qOUfbJ%VWp006EqV{!lh
+
+diff --git a/data/tests/advisories/repodata/repomd.xml b/data/tests/advisories/repodata/repomd.xml
+index 21630e04..c9468e82 100644
+--- a/data/tests/advisories/repodata/repomd.xml
++++ b/data/tests/advisories/repodata/repomd.xml
+@@ -1,11 +1,11 @@
+ <?xml version="1.0" encoding="UTF-8"?>
+ <repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
+-  <revision>1612879414</revision>
++  <revision>1620890113</revision>
+   <data type="primary">
+-    <checksum type="sha256">b69e4467719314fdb155872cf9c8e895d5b169c0506c5180c512d693c48f0f4b</checksum>
+-    <open-checksum type="sha256">8606d1f777859f167f7bd0bf8a1d532abedcb4db143b719e631e1040800fd1f0</open-checksum>
++    <checksum type="sha256">f2f306a22a157730d2f13f09fc36c425b9bedfc0ecaf74d8b60d98222ebb3274</checksum>
++    <open-checksum type="sha256">ef20a9175429f9f223c4bdcd634fc218bdd85799095438d349efea159cfd2bdf</open-checksum>
+     <location href="repodata/primary.xml.gz"/>
+-    <timestamp>1612879414</timestamp>
++    <timestamp>1620890113</timestamp>
+     <size>743</size>
+     <open-size>2665</open-size>
+   </data>
+@@ -13,7 +13,7 @@
+     <checksum type="sha256">efbf7f021163a3c7698a257351e327102c60bb39a7bdceee77c421f064205e99</checksum>
+     <open-checksum type="sha256">ca5620e2734574d04d3c01ae5a72f865313369954698d71776076b9cbd831bbd</open-checksum>
+     <location href="repodata/filelists.xml.gz"/>
+-    <timestamp>1612879414</timestamp>
++    <timestamp>1620890113</timestamp>
+     <size>311</size>
+     <open-size>511</open-size>
+   </data>
+@@ -21,23 +21,23 @@
+     <checksum type="sha256">6673953e1f28f55b9d4c3f38a9e3c0e0ff88ad06fb693b7f15eb241a81b80d71</checksum>
+     <open-checksum type="sha256">0997c242bf1b96372d7a625a73de23dced68cae9375baff0c73215a07693b3f4</open-checksum>
+     <location href="repodata/other.xml.gz"/>
+-    <timestamp>1612879414</timestamp>
++    <timestamp>1620890113</timestamp>
+     <size>310</size>
+     <open-size>507</open-size>
+   </data>
+   <data type="modules">
+-    <checksum type="sha256">a815d0669b15b97dd6260713405c79045eeda10aedb6460a0f742b86cc236cca</checksum>
+-    <open-checksum type="sha256">0d1063b74e3a7cb4c7cdc3b2080b1901c347693140765534f8c5c3d8b964778a</open-checksum>
++    <checksum type="sha256">df1abc1ab7dacc6ea2bc16c2b14abeb32d0ec9d9ed01378488cec22540f9607b</checksum>
++    <open-checksum type="sha256">f088c4096bfc4acad99a20e06d0d4381872c10f0f27ff8bbfe1bada658ff7afd</open-checksum>
+     <location href="repodata/modules.yaml.gz"/>
+-    <timestamp>1612879414</timestamp>
+-    <size>300</size>
+-    <open-size>1019</open-size>
++    <timestamp>1620890113</timestamp>
++    <size>332</size>
++    <open-size>1117</open-size>
+   </data>
+   <data type="updateinfo">
+     <checksum type="sha256">9d791d16c2adc2d7d4c85b45f2a704edac62a926b09fc20df73207f4190acd49</checksum>
+     <open-checksum type="sha256">3cf7df860860ac7a4a8e64a1a2d71c1ec43225dacbfe09a0cff80f28be3825da</open-checksum>
+     <location href="repodata/updateinfo.xml.gz"/>
+-    <timestamp>1612879414</timestamp>
++    <timestamp>1620890113</timestamp>
+     <size>708</size>
+     <open-size>2414</open-size>
+   </data>
+diff --git a/tests/libdnf/sack/AdvisoryTest.cpp b/tests/libdnf/sack/AdvisoryTest.cpp
+index 805c35da..1abf1a95 100644
+--- a/tests/libdnf/sack/AdvisoryTest.cpp
++++ b/tests/libdnf/sack/AdvisoryTest.cpp
+@@ -97,11 +97,9 @@ void AdvisoryTest::testGetApplicablePackagesModulesNotSetup()
+ 
+     // When modules are not setup all advisory collections are applicable and we get all packages
+     advisory->getApplicablePackages(pkgsvector);
+-    CPPUNIT_ASSERT(pkgsvector.size() == 4);
++    CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(pkgsvector.size()));
+     CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "test-perl-DBI"));
+-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "test-perl-DBI-new-collection-override"));
+-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[2].getNameString(), "test-perl-DBI"));
+-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[3].getNameString(), "not-present"));
++    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "not-present"));
+ }
+ 
+ void AdvisoryTest::testGetApplicablePackagesModulesSetupNoneEnabled()
+@@ -122,16 +120,14 @@ void AdvisoryTest::testGetApplicablePackagesOneApplicableCollection()
+ {
+     std::vector<libdnf::AdvisoryPkg> pkgsvector;
+ 
+-    // When I keep enabled only perl-DBI module I get packages from all collections that contain that module
++    // When I keep enabled only perl module I get packages from all collections that contain that module
+     libdnf::ModulePackageContainer * modules = dnf_sack_get_module_container(sack);
+-    modules->reset("perl");
++    modules->reset("perl-DBI");
+     dnf_sack_filter_modules_v2(sack, modules, nullptr, tmpdir, nullptr, true, false, false);
+ 
+     advisory->getApplicablePackages(pkgsvector);
+-    CPPUNIT_ASSERT(pkgsvector.size() == 3);
+-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "test-perl-DBI"));
+-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "test-perl-DBI-new-collection-override"));
+-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[2].getNameString(), "test-perl-DBI"));
++    CPPUNIT_ASSERT(pkgsvector.size() == 1);
++    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "not-present"));
+ }
+ 
+ void AdvisoryTest::testGetApplicablePackagesMultipleApplicableCollections()
+@@ -141,11 +137,9 @@ void AdvisoryTest::testGetApplicablePackagesMultipleApplicableCollections()
+     // When I enable modules from multiple collections -> I get packages from all applicable collections
+     // Enabled - "perl-DBI:master", "perl:5.23"
+     advisory->getApplicablePackages(pkgsvector);
+-    CPPUNIT_ASSERT(pkgsvector.size() == 4);
++    CPPUNIT_ASSERT(pkgsvector.size() == 2);
+     CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "test-perl-DBI"));
+-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "test-perl-DBI-new-collection-override"));
+-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[2].getNameString(), "test-perl-DBI"));
+-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[3].getNameString(), "not-present"));
++    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "not-present"));
+ }
+ 
+ void AdvisoryTest::testGetModules()
+diff --git a/tests/libdnf/sack/QueryTest.cpp b/tests/libdnf/sack/QueryTest.cpp
+index 7c3a22af..d4cc28c2 100644
+--- a/tests/libdnf/sack/QueryTest.cpp
++++ b/tests/libdnf/sack/QueryTest.cpp
+@@ -59,12 +59,13 @@ void QueryTest::testQueryGetAdvisoryPkgs()
+     HyQuery query = new libdnf::Query(sack);
+     std::vector<libdnf::AdvisoryPkg> advisoryPkgs;
+ 
+-    // When modules are not setup all advisory collections are applicable
++    // Apply advisory only from active context - receave advisory package only from releted collection
+     query->getAdvisoryPkgs(HY_EQ, advisoryPkgs);
+-    CPPUNIT_ASSERT(advisoryPkgs.size() == 2);
+-    // We get test-perl-DBI twice because its in two collections
+-    CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[0].getNameString(), "test-perl-DBI"));
+-    CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[1].getNameString(), "test-perl-DBI"));
++    CPPUNIT_ASSERT(advisoryPkgs.size() == 1);
++
++    CPPUNIT_ASSERT_EQUAL(std::string("test-perl-DBI"), std::string(advisoryPkgs[0].getNameString()));
++    CPPUNIT_ASSERT_EQUAL(std::string("1-2.module_el8+6587+9879afr5"), std::string(advisoryPkgs[0].getEVRString()));
++    //CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[1].getNameString(), "test-perl-DBI"));
+ 
+     // When modules are setup but none are enabled all collections are not applicable - no enabled module
+     libdnf::ModulePackageContainer * modules = dnf_sack_get_module_container(sack);
+@@ -84,15 +85,15 @@ void QueryTest::testQueryGetAdvisoryPkgs()
+     query->getAdvisoryPkgs(HY_EQ, advisoryPkgs);
+     CPPUNIT_ASSERT(advisoryPkgs.size() == 0);
+ 
+-    // When I enable a module from multiple collections that contain a present package I get them
++    // When I enable a module with multiple collections I will receave advisory packages only for active context
+     CPPUNIT_ASSERT(modules->enable("perl-DBI", "master", false));
+     dnf_sack_filter_modules_v2(sack, modules, nullptr, tmpdir, nullptr, true, false, false);
+ 
+     advisoryPkgs.clear();
+     query->getAdvisoryPkgs(HY_EQ, advisoryPkgs);
+-    CPPUNIT_ASSERT(advisoryPkgs.size() == 2);
+-    CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[0].getNameString(), "test-perl-DBI"));
+-    CPPUNIT_ASSERT(!g_strcmp0(advisoryPkgs[1].getNameString(), "test-perl-DBI"));
++    CPPUNIT_ASSERT(advisoryPkgs.size() == 1);
++    CPPUNIT_ASSERT_EQUAL(std::string("test-perl-DBI"), std::string(advisoryPkgs[0].getNameString()));
++    CPPUNIT_ASSERT_EQUAL(std::string("1-2.module_el8+6587+9879afr5"), std::string(advisoryPkgs[0].getEVRString()));
+ 
+     delete query;
+ }
+@@ -102,16 +103,13 @@ void QueryTest::testQueryFilterAdvisory()
+     // When modules are not setup all advisory collections are applicable and there is no modular filtering
+     HyQuery query = new libdnf::Query(sack);
+     query->addFilter(HY_PKG_ADVISORY_TYPE, HY_EQ, "enhancement");
+-    CPPUNIT_ASSERT(query->size() == 2);
++    CPPUNIT_ASSERT(query->size() == 1);
+ 
+     // We get test-perl-DBI twice because its in two collections
+     libdnf::PackageSet pset = *(query->getResultPset());
+     DnfPackage *pkg = dnf_package_new(sack, pset[0]);
+     CPPUNIT_ASSERT(!g_strcmp0(dnf_package_get_name(pkg), "test-perl-DBI"));
+     g_object_unref(pkg);
+-    pkg = dnf_package_new(sack, pset[1]);
+-    CPPUNIT_ASSERT(!g_strcmp0(dnf_package_get_name(pkg), "test-perl-DBI"));
+-    g_object_unref(pkg);
+     delete query;
+ 
+     // When module are setup but none are enabled all collections are not applicable - no enabled module
+-- 
+2.31.1
+
diff --git a/SOURCES/0018-Adjust-module-error-formatting-function-for-original.patch b/SOURCES/0018-Adjust-module-error-formatting-function-for-original.patch
new file mode 100644
index 0000000..17ad066
--- /dev/null
+++ b/SOURCES/0018-Adjust-module-error-formatting-function-for-original.patch
@@ -0,0 +1,34 @@
+From c7f0b13bf32cfba63a2db6257c50ae1ba5c8f9ba Mon Sep 17 00:00:00 2001
+From: Jaroslav Mracek <jmracek@redhat.com>
+Date: Thu, 6 May 2021 11:18:20 +0200
+Subject: [PATCH 18/19] Adjust module error formatting function for original
+ modular solver
+
+The new solver uses libsolv solvable by another way. The revert requires
+also change in formatting function.
+---
+ libdnf/goal/Goal.cpp | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+diff --git a/libdnf/goal/Goal.cpp b/libdnf/goal/Goal.cpp
+index a6f11a4f..6b2f91a2 100644
+--- a/libdnf/goal/Goal.cpp
++++ b/libdnf/goal/Goal.cpp
+@@ -58,12 +58,8 @@ std::string moduleSolvid2str(Pool * pool, Id source)
+ {
+     std::ostringstream ss;
+     auto * solvable = pool_id2solvable(pool, source);
+-    // Add name:stream
+-    ss << solvable_lookup_str(solvable, SOLVABLE_DESCRIPTION);
+-    //Add version
+-    ss << ":" << pool_id2str(pool, solvable->evr);
+-    // Add original context
+-    ss << ":" << solvable_lookup_str(solvable, SOLVABLE_SUMMARY);
++    // Add name:stream:version:context
++    ss << pool_id2str(pool, solvable->name);
+     ss << "." << pool_id2str(pool, solvable->arch);
+     return ss.str();
+ }
+-- 
+2.31.1
+
diff --git a/SOURCES/0019-Remove-redundant-test.patch b/SOURCES/0019-Remove-redundant-test.patch
new file mode 100644
index 0000000..0b2441c
--- /dev/null
+++ b/SOURCES/0019-Remove-redundant-test.patch
@@ -0,0 +1,57 @@
+From eb7217d0a71b92ac0d8c3773caa1a2d3a2c20071 Mon Sep 17 00:00:00 2001
+From: Jaroslav Mracek <jmracek@redhat.com>
+Date: Thu, 13 May 2021 09:10:42 +0200
+Subject: [PATCH 19/19] Remove redundant test
+
+The test is identical to
+testGetApplicablePackagesMultipleApplicableCollections().
+---
+ tests/libdnf/sack/AdvisoryTest.cpp | 11 -----------
+ tests/libdnf/sack/AdvisoryTest.hpp |  2 --
+ 2 files changed, 13 deletions(-)
+
+diff --git a/tests/libdnf/sack/AdvisoryTest.cpp b/tests/libdnf/sack/AdvisoryTest.cpp
+index 1abf1a95..f5892634 100644
+--- a/tests/libdnf/sack/AdvisoryTest.cpp
++++ b/tests/libdnf/sack/AdvisoryTest.cpp
+@@ -91,17 +91,6 @@ void AdvisoryTest::testGetPackages()
+     CPPUNIT_ASSERT(pkgsvector.size() == 4);
+ }
+ 
+-void AdvisoryTest::testGetApplicablePackagesModulesNotSetup()
+-{
+-    std::vector<libdnf::AdvisoryPkg> pkgsvector;
+-
+-    // When modules are not setup all advisory collections are applicable and we get all packages
+-    advisory->getApplicablePackages(pkgsvector);
+-    CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(pkgsvector.size()));
+-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[0].getNameString(), "test-perl-DBI"));
+-    CPPUNIT_ASSERT(!g_strcmp0(pkgsvector[1].getNameString(), "not-present"));
+-}
+-
+ void AdvisoryTest::testGetApplicablePackagesModulesSetupNoneEnabled()
+ {
+     std::vector<libdnf::AdvisoryPkg> pkgsvector;
+diff --git a/tests/libdnf/sack/AdvisoryTest.hpp b/tests/libdnf/sack/AdvisoryTest.hpp
+index 6eb25a57..cb0d8c05 100644
+--- a/tests/libdnf/sack/AdvisoryTest.hpp
++++ b/tests/libdnf/sack/AdvisoryTest.hpp
+@@ -19,7 +19,6 @@ class AdvisoryTest : public CppUnit::TestCase
+         CPPUNIT_TEST(testGetSeverity);
+         CPPUNIT_TEST(testGetTitle);
+         CPPUNIT_TEST(testGetPackages);
+-        CPPUNIT_TEST(testGetApplicablePackagesModulesNotSetup);
+         CPPUNIT_TEST(testGetApplicablePackagesModulesSetupNoneEnabled);
+         CPPUNIT_TEST(testGetApplicablePackagesOneApplicableCollection);
+         CPPUNIT_TEST(testGetApplicablePackagesMultipleApplicableCollections);
+@@ -38,7 +37,6 @@ public:
+     void testGetSeverity();
+     void testGetTitle();
+     void testGetPackages();
+-    void testGetApplicablePackagesModulesNotSetup();
+     void testGetApplicablePackagesModulesSetupNoneEnabled();
+     void testGetApplicablePackagesOneApplicableCollection();
+     void testGetApplicablePackagesMultipleApplicableCollections();
+-- 
+2.31.1
+
diff --git a/SOURCES/0020-Fix-dnf_context_module_install-memory-leaks.patch b/SOURCES/0020-Fix-dnf_context_module_install-memory-leaks.patch
new file mode 100644
index 0000000..ea8bcf0
--- /dev/null
+++ b/SOURCES/0020-Fix-dnf_context_module_install-memory-leaks.patch
@@ -0,0 +1,28 @@
+From 4a8a3f410552c58dfafb384bb361c6e40bebff1d Mon Sep 17 00:00:00 2001
+From: Jaroslav Rohel <jrohel@redhat.com>
+Date: Wed, 21 Jul 2021 11:01:32 +0200
+Subject: [PATCH] Fix: dnf_context_module_install: memory leaks
+
+---
+ libdnf/dnf-context.cpp | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/libdnf/dnf-context.cpp b/libdnf/dnf-context.cpp
+index 55af2b2..6cb0011 100644
+--- a/libdnf/dnf-context.cpp
++++ b/libdnf/dnf-context.cpp
+@@ -3486,7 +3486,10 @@ dnf_context_module_install(DnfContext * context, const char ** module_specs, GEr
+                         }
+                         for (const auto &nevra : modpkg->getArtifacts()) {
+                             int epoch;
+-                            char *name, *version, *release, *arch;
++                            g_autofree char *name = nullptr;
++                            g_autofree char *version = nullptr;
++                            g_autofree char *release = nullptr;
++                            g_autofree char *arch = nullptr;
+                             if (hy_split_nevra(nevra.c_str(), &name, &epoch, &version, &release, &arch)) {
+                                 // this really should never happen; unless the modular repodata is corrupted
+                                 g_autofree char *errmsg = g_strdup_printf (_("Failed to parse module artifact NEVRA '%s'"), nevra.c_str());
+--
+libgit2 1.0.1
+
diff --git a/SOURCES/0021-covscan-remove-unused-vars-mark-private-func-static-return-values.patch b/SOURCES/0021-covscan-remove-unused-vars-mark-private-func-static-return-values.patch
new file mode 100644
index 0000000..6dca417
--- /dev/null
+++ b/SOURCES/0021-covscan-remove-unused-vars-mark-private-func-static-return-values.patch
@@ -0,0 +1,91 @@
+From 07416268889f95e1495fb3d7b856de1c502870ba Mon Sep 17 00:00:00 2001
+From: Jaroslav Rohel <jrohel@redhat.com>
+Date: Wed, 21 Jul 2021 11:15:50 +0200
+Subject: [PATCH] covscan: remove unused vars, mark private func static, return values
+
+The `begin` and `end` variables were not used
+in `ModulePackageContainer::updateFailSafeData`. Removed.
+
+The `checksum` in "utils.cpp" is a private (static) function.
+
+Added check of return value of `dnf_copy_recursive` function in unit test.
+
+In the `install` in the "goal-py.cpp" file:
+Explicitly ignores the return values of `hy_goal_install` and
+`hy_goal_install_optional`. The functions always return zero.
+Explicitly ignores the return values of `hy_goal_install_selector` and
+`hy_goal_install_selector_optional`. The `error` argument is used instead.
+---
+ libdnf/module/ModulePackageContainer.cpp           | 2 --
+ libdnf/utils/utils.cpp                             | 2 +-
+ python/hawkey/goal-py.cpp                          | 8 ++++----
+ tests/libdnf/module/ModulePackageContainerTest.cpp | 3 ++-
+ 4 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
+index c0ad126..efab497 100644
+--- a/libdnf/module/ModulePackageContainer.cpp
++++ b/libdnf/module/ModulePackageContainer.cpp
+@@ -1656,8 +1656,6 @@ void ModulePackageContainer::updateFailSafeData()
+     if (pImpl->activatedModules) {
+         std::vector<ModulePackage *> latest = pImpl->getLatestActiveEnabledModules();
+ 
+-        auto begin = fileNames.begin();
+-        auto end = fileNames.end();
+         if (g_mkdir_with_parents(pImpl->persistDir.c_str(), 0755) == -1) {
+             const char * errTxt = strerror(errno);
+             auto logger(Log::getLogger());
+diff --git a/libdnf/utils/utils.cpp b/libdnf/utils/utils.cpp
+index 450718d..15f5275 100644
+--- a/libdnf/utils/utils.cpp
++++ b/libdnf/utils/utils.cpp
+@@ -301,7 +301,7 @@ void decompress(const char * inPath, const char * outPath, mode_t outMode, const
+     fclose(inFile);
+ }
+ 
+-void checksum(const char * type, const char * inPath, const char * checksum_valid, bool * valid_out, gchar ** calculated_out)
++static void checksum(const char * type, const char * inPath, const char * checksum_valid, bool * valid_out, gchar ** calculated_out)
+ {
+     GError * errP{nullptr};
+     gboolean valid;
+diff --git a/python/hawkey/goal-py.cpp b/python/hawkey/goal-py.cpp
+index 2641a1d..5bbb959 100644
+--- a/python/hawkey/goal-py.cpp
++++ b/python/hawkey/goal-py.cpp
+@@ -281,15 +281,15 @@ install(_GoalObject *self, PyObject *args, PyObject *kwds) try
+ 
+     if (flags & HY_WEAK_SOLV) {
+         if (pkg) {
+-            hy_goal_install_optional(self->goal, pkg);
++            (void)hy_goal_install_optional(self->goal, pkg);
+         } else {
+-            hy_goal_install_selector_optional(self->goal, sltr, &error);
++            (void)hy_goal_install_selector_optional(self->goal, sltr, &error);
+         }
+     } else {
+         if (pkg) {
+-            hy_goal_install(self->goal, pkg);
++            (void)hy_goal_install(self->goal, pkg);
+         } else {
+-            hy_goal_install_selector(self->goal, sltr, &error);
++            (void)hy_goal_install_selector(self->goal, sltr, &error);
+         }
+     }
+     return op_error2exc(error);
+diff --git a/tests/libdnf/module/ModulePackageContainerTest.cpp b/tests/libdnf/module/ModulePackageContainerTest.cpp
+index b2cf170..6360a0c 100644
+--- a/tests/libdnf/module/ModulePackageContainerTest.cpp
++++ b/tests/libdnf/module/ModulePackageContainerTest.cpp
+@@ -17,7 +17,8 @@ void ModulePackageContainerTest::setUp()
+     char *retptr = mkdtemp(tmpdir);
+     CPPUNIT_ASSERT(retptr);
+     char * etc_target = g_strjoin(NULL, tmpdir, "/etc", NULL);
+-    dnf_copy_recursive(TESTDATADIR "/modules/etc", etc_target, &error);
++    auto ret = dnf_copy_recursive(TESTDATADIR "/modules/etc", etc_target, &error);
++    g_assert_true(ret);
+     g_assert_no_error(error);
+     g_free(etc_target);
+ 
+--
+libgit2 1.0.1
+
diff --git a/SOURCES/0022-hawkey-surrogateescape-error-handler-to-decode-UTF-8-strings-RhBug1893176.patch b/SOURCES/0022-hawkey-surrogateescape-error-handler-to-decode-UTF-8-strings-RhBug1893176.patch
new file mode 100644
index 0000000..8918c27
--- /dev/null
+++ b/SOURCES/0022-hawkey-surrogateescape-error-handler-to-decode-UTF-8-strings-RhBug1893176.patch
@@ -0,0 +1,32 @@
+From 263eee36afc0ae5c8f342f4b61038e91ee942b21 Mon Sep 17 00:00:00 2001
+From: Marek Blaha <mblaha@redhat.com>
+Date: Thu, 22 Apr 2021 15:19:26 +0200
+Subject: [PATCH] hawkey: surrogateescape error handler to decode UTF-8 strings (RhBug:1893176)
+
+This ensures that libdnf does not raise UnicodeDecodeError when
+accessing package with non UTF-8 file names.
+
+= changelog =
+msg:           DNF does not fail on non UTF-8 file names in a package
+type:          bugfix
+resolves:      https://bugzilla.redhat.com/show_bug.cgi?id=1893176
+---
+ python/hawkey/iutil-py.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/python/hawkey/iutil-py.cpp b/python/hawkey/iutil-py.cpp
+index 56ccafd..57bef57 100644
+--- a/python/hawkey/iutil-py.cpp
++++ b/python/hawkey/iutil-py.cpp
+@@ -285,7 +285,7 @@ strlist_to_pylist(const char **slist)
+         return NULL;
+ 
+     for (const char **iter = slist; *iter; ++iter) {
+-        UniquePtrPyObject str(PyUnicode_FromString(*iter));
++        UniquePtrPyObject str(PyUnicode_DecodeUTF8(*iter, strlen(*iter), "surrogateescape"));
+         if (!str)
+             return NULL;
+         int rc = PyList_Append(list.get(), str.get());
+--
+libgit2 1.0.1
+
diff --git a/SPECS/libdnf.spec b/SPECS/libdnf.spec
index 0fd799b..23dbc8a 100644
--- a/SPECS/libdnf.spec
+++ b/SPECS/libdnf.spec
@@ -1,10 +1,10 @@
-%global libsolv_version 0.7.7
-%global libmodulemd_version 2.5.0
-%global librepo_version 1.12.0
+%global libsolv_version 0.7.17
+%global libmodulemd_version 2.11.2-2
+%global librepo_version 1.13.1
 %global dnf_conflict 4.3.0
 %global swig_version 3.0.12
 %global libdnf_major_version 0
-%global libdnf_minor_version 55
+%global libdnf_minor_version 63
 %global libdnf_micro_version 0
 
 %define __cmake_in_source_build 1
@@ -56,19 +56,33 @@
 
 Name:           libdnf
 Version:        %{libdnf_major_version}.%{libdnf_minor_version}.%{libdnf_micro_version}
-Release:        6%{?dist}
+Release:        2%{?dist}
 Summary:        Library providing simplified C and Python API to libsolv
 License:        LGPLv2+
 URL:            https://github.com/rpm-software-management/libdnf
 Source0:        %{url}/archive/%{version}/%{name}-%{version}.tar.gz
-Patch0:         0001-Better-msgs-if-basecachedir-or-proxy-password-isn-t-set-RhBug-1888946.patch
-Patch1:         0002-modules-Add-special-handling-for-src-artifacts-RhBug-1809314.patch
-Patch2:         0003-Avoid-multilib-file-conflict-in-config.h-RhBug-1918818.patch
-Patch3:         0004-context-improve-retrieving-repository-configuration.patch
-Patch4:         0005-Allow-loading-incomplete-cache-and-loading-ext-solv-files-without-its-repodata.patch
-Patch5:         0006-Add-new-option-module-stream-switch.patch
-Patch6:         0007-Fix-removal-step-during-modular-enable-in-context-part.patch
-
+Patch1:         0001-Revert-Improve-performance-for-module-query.patch
+Patch2:         0002-Revert-Enhance-description-of-modular-solvables.patch
+Patch3:         0003-Revert-Fix-typo-lates-latest.patch
+Patch4:         0004-Revert-Remove-unused-code-bump-version.patch
+Patch5:         0005-Revert-Report-a-new-type-of-the-module-resolve-error.patch
+Patch6:         0006-Revert-Add-additional-fallback-for-module-resolve.patch
+Patch7:         0007-Revert-Decide-how-to-handle-context-according-to-sta.patch
+Patch8:         0008-Revert-Fix-load-update-FailSafe.patch
+Patch9:         0009-Revert-Change-mechanism-of-module-conflicts.patch
+Patch10:        0010-Revert-Call-addVersion2Modules-as-late-as-possible.patch
+Patch11:        0011-Revert-Fix-modular-queries-with-the-new-solver.patch
+Patch12:        0012-Revert-Add-compatible-layer-for-MdDocuments-v2.patch
+Patch13:        0013-Revert-Add-an-alternative-constructor-for-ModulePack.patch
+Patch14:        0014-Revert-Adjust-modular-solver-to-new-context-type.patch
+Patch15:        0015-Revert-Change-usage-of-context-and-version-in-modula.patch
+Patch16:        0016-Fix-failing-unittest-caused-by-the-revert-of-new-mod.patch
+Patch17:        0017-Modify-unit-test-after-change-of-handling-advisories.patch
+Patch18:        0018-Adjust-module-error-formatting-function-for-original.patch
+Patch19:        0019-Remove-redundant-test.patch
+Patch20:        0020-Fix-dnf_context_module_install-memory-leaks.patch
+Patch21:        0021-covscan-remove-unused-vars-mark-private-func-static-return-values.patch
+Patch22:        0022-hawkey-surrogateescape-error-handler-to-decode-UTF-8-strings-RhBug1893176.patch
 
 BuildRequires:  cmake
 BuildRequires:  gcc
@@ -98,9 +112,9 @@ BuildRequires:  gettext
 BuildRequires:  gpgme-devel
 
 %if %{with sanitizers}
-BuildRequires:  libasan-static
-BuildRequires:  liblsan-static
-BuildRequires:  libubsan-static
+BuildRequires:  libasan
+BuildRequires:  liblsan
+BuildRequires:  libubsan
 %endif
 
 Requires:       libmodulemd%{?_isa} >= %{libmodulemd_version}
@@ -166,11 +180,6 @@ Python 3 bindings for the libdnf library.
 Summary:        Python 2 bindings for the hawkey library
 %{?python_provide:%python_provide python2-hawkey}
 BuildRequires:  python2-devel
-%if 0%{?rhel} && 0%{?rhel} <= 7
-BuildRequires:  python-nose
-%else
-BuildRequires:  python2-nose
-%endif
 Requires:       %{name}%{?_isa} = %{version}-%{release}
 Requires:       python2-%{name} = %{version}-%{release}
 # Fix problem with hawkey - dnf version incompatibility
@@ -188,7 +197,6 @@ Python 2 bindings for the hawkey library.
 Summary:        Python 3 bindings for the hawkey library
 %{?python_provide:%python_provide python3-hawkey}
 BuildRequires:  python3-devel
-BuildRequires:  python3-nose
 Requires:       %{name}%{?_isa} = %{version}-%{release}
 Requires:       python3-%{name} = %{version}-%{release}
 # Fix problem with hawkey - dnf version incompatibility
@@ -202,7 +210,7 @@ Python 3 bindings for the hawkey library.
 %endif
 
 %prep
-%autosetup -p1
+%autosetup -S git -p1
 %if %{with python2}
 mkdir build-py2
 %endif
@@ -288,6 +296,9 @@ popd
 %dir %{_libdir}/libdnf/
 %dir %{_libdir}/libdnf/plugins/
 %{_libdir}/libdnf/plugins/README
+%if %{with sanitizers}
+%{_sysconfdir}/profile.d/dnf-sanitizers.sh
+%endif
 
 %files devel
 %doc %{_datadir}/gtk-doc/html/%{name}/
@@ -316,6 +327,37 @@ popd
 %endif
 
 %changelog
+* Tue Jul 27 2021 Pavla Kratochvilova <pkratoch@redhat.com> - 0.63.0-2
+- Fix: dnf_context_module_install: memory leaks
+- covscan: remove unused vars, mark private func static, return values
+- DNF does not fail on non UTF-8 file names in a package
+
+* Wed May 19 2021 Pavla Kratochvilova <pkratoch@redhat.com> - 0.63.0-1
+- Update to 0.62.0
+- Hardening: add signature check with rpmcliVerifySignatures (RhBug:1932079)
+- Support allow_vendor_change setting in dnf context API
+- Add a new option module_obsoletes
+- Add new API applyObsoletes() function to apply modular obsoletes
+- Do not allow 1 as installonly_limit value (RhBug:1926261)
+- Add a config option to check TLS certificate revocation status (using OCSP stapling), defaults to false (RhBug:1814383)
+- Swdb: Add a method to get the current transaction
+- [context,API] Functions for accessing main/global configuration options
+- [context,API] Function for adding setopt
+- Add getter for modular obsoletes from ModuleMetadata
+- Add ModulePackage.getStaticContext() and getRequires()
+- Fix modular queries with the new solver
+- Fix: Fully set ssl in newHandle function
+- [conf] Add options for working with certificates used with proxy
+- Modify module NSVCA parsing - context definition (RhBug:1926771)
+- [context] Fix: dnf_package_is_installonly (RhBug:1928056)
+- Add getApplicablePackages to advisory and isApplicable to advisorymodule
+- Keep isAdvisoryApplicable to preserve API
+- [context] Support config file option "proxy_auth_method", defaults "any"
+- Support main config file options "installonlypkgs" and "protected_packages". Changes behaviour of microdnf and PackageKit.
+- Properly handle multiple collections in updateinfo.xml (RhBug:1804234)
+- Fix a crash when [media] section in .treeinfo is missing for bootable media (RhBug:1946024)
+- Add new dnf_context_module_install() C API
+
 * Fri Feb 12 2021 Nicola Sella <nsella@redhat.com> - 0.55.0-6
 - Fix removal step during modular enable in context part