Blame SOURCES/0013-repomanage-Use-modules-only-from-repo-they-are-handl.patch

6ca87e
From e80f79b2f5e17a20065617c0b614b272dd53c57c Mon Sep 17 00:00:00 2001
6ca87e
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
6ca87e
Date: Thu, 26 May 2022 07:21:45 +0200
6ca87e
Subject: [PATCH] repomanage: Use modules only from repo they are handling
6ca87e
 (RhBug:2072441)
6ca87e
6ca87e
= changelog =
6ca87e
msg: [repomanage] Modules are used only when they belong to target repo
6ca87e
type: bugfix
6ca87e
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2072441
6ca87e
---
6ca87e
 plugins/repomanage.py | 13 +++++++++----
6ca87e
 1 file changed, 9 insertions(+), 4 deletions(-)
6ca87e
6ca87e
diff --git a/plugins/repomanage.py b/plugins/repomanage.py
6ca87e
index 989bd78..67a6fc7 100644
6ca87e
--- a/plugins/repomanage.py
6ca87e
+++ b/plugins/repomanage.py
6ca87e
@@ -66,7 +66,8 @@ class RepoManageCommand(dnf.cli.Command):
6ca87e
         keepnum = int(self.opts.keep) # the number of items to keep
6ca87e
 
6ca87e
         try:
6ca87e
-            repo_conf = self.base.repos.add_new_repo("repomanage_repo", self.base.conf, baseurl=[self.opts.path])
6ca87e
+            REPOMANAGE_REPOID = "repomanage_repo"
6ca87e
+            repo_conf = self.base.repos.add_new_repo(REPOMANAGE_REPOID, self.base.conf, baseurl=[self.opts.path])
6ca87e
             # Always expire the repo, otherwise repomanage could use cached metadata and give identical results
6ca87e
             # for multiple runs even if the actual repo changed in the meantime
6ca87e
             repo_conf._repo.expire()
6ca87e
@@ -78,9 +79,13 @@ class RepoManageCommand(dnf.cli.Command):
6ca87e
                 module_packages = self.base._moduleContainer.getModulePackages()
6ca87e
 
6ca87e
                 for module_package in module_packages:
6ca87e
-                    all_modular_artifacts.update(module_package.getArtifacts())
6ca87e
-                    module_dict.setdefault(module_package.getNameStream(), {}).setdefault(
6ca87e
-                        module_package.getVersionNum(), []).append(module_package)
6ca87e
+                    # Even though we load only REPOMANAGE_REPOID other modules can be loaded from system
6ca87e
+                    # failsafe data automatically, we don't want them affecting repomanage results so ONLY
6ca87e
+                    # use modules from REPOMANAGE_REPOID.
6ca87e
+                    if module_package.getRepoID() == REPOMANAGE_REPOID:
6ca87e
+                        all_modular_artifacts.update(module_package.getArtifacts())
6ca87e
+                        module_dict.setdefault(module_package.getNameStream(), {}).setdefault(
6ca87e
+                            module_package.getVersionNum(), []).append(module_package)
6ca87e
 
6ca87e
         except dnf.exceptions.RepoError:
6ca87e
             rpm_list = []
6ca87e
-- 
6ca87e
2.36.1
6ca87e