Skip to content

Commit

Permalink
repomanage: Use modules only from repo they are handling (RhBug:2072441)
Browse files Browse the repository at this point in the history
= changelog =
msg: [repomanage] Modules are used only when they belong to target repo
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2072441
  • Loading branch information
kontura authored and j-mracek committed May 30, 2022
1 parent ccde39a commit 038bd5c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions plugins/repomanage.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def run(self):
keepnum = int(self.opts.keep) # the number of items to keep

try:
repo_conf = self.base.repos.add_new_repo("repomanage_repo", self.base.conf, baseurl=[self.opts.path])
REPOMANAGE_REPOID = "repomanage_repo"
repo_conf = self.base.repos.add_new_repo(REPOMANAGE_REPOID, self.base.conf, baseurl=[self.opts.path])
# Always expire the repo, otherwise repomanage could use cached metadata and give identical results
# for multiple runs even if the actual repo changed in the meantime
repo_conf._repo.expire()
Expand All @@ -84,9 +85,13 @@ def run(self):
module_packages = self.base._moduleContainer.getModulePackages()

for module_package in module_packages:
all_modular_artifacts.update(module_package.getArtifacts())
module_dict.setdefault(module_package.getNameStream(), {}).setdefault(
module_package.getVersionNum(), []).append(module_package)
# Even though we load only REPOMANAGE_REPOID other modules can be loaded from system
# failsafe data automatically, we don't want them affecting repomanage results so ONLY
# use modules from REPOMANAGE_REPOID.
if module_package.getRepoID() == REPOMANAGE_REPOID:
all_modular_artifacts.update(module_package.getArtifacts())
module_dict.setdefault(module_package.getNameStream(), {}).setdefault(
module_package.getVersionNum(), []).append(module_package)

except dnf.exceptions.RepoError:
rpm_list = []
Expand Down

0 comments on commit 038bd5c

Please sign in to comment.