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

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