From 511cad8c14c02c6dc7beaadc9f9da919982cd6b2 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Wed, 12 Jun 2019 13:09:08 +0200 Subject: [PATCH] Check if `buildopts.get_rpm_whitelist()` is really set before using it. This fixes module builds which sets the `buildopts` for something else than the RPM whitelist. Before this commit, when `buildopts` was set, the RPM whitelist was always taken from the buildopts even if it was not defined there. This resulted in empty `rpm_whitelist` and therefore no pkglist set in Koji tag. In this commit, MBS uses whitelist from `buildopts` only if it is really set by the module maintainer. --- module_build_service/builder/KojiModuleBuilder.py | 2 +- tests/test_builder/test_koji.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/module_build_service/builder/KojiModuleBuilder.py b/module_build_service/builder/KojiModuleBuilder.py index 2f82b7ce..6c7c2835 100644 --- a/module_build_service/builder/KojiModuleBuilder.py +++ b/module_build_service/builder/KojiModuleBuilder.py @@ -531,7 +531,7 @@ class KojiModuleBuilder(GenericBuilder): self.tag_name + "-build", self.arches, perm="admin") buildopts = self.mmd.get_buildopts() - if buildopts: + if buildopts and buildopts.get_rpm_whitelist(): rpm_whitelist = buildopts.get_rpm_whitelist() else: rpm_whitelist = self.components diff --git a/tests/test_builder/test_koji.py b/tests/test_builder/test_koji.py index 2f650304..9cca97c2 100644 --- a/tests/test_builder/test_koji.py +++ b/tests/test_builder/test_koji.py @@ -487,6 +487,14 @@ class TestKojiBuilder: opts.add_rpm_to_whitelist("custom2") mmd.set_buildopts(opts) self.module.modulemd = mmd_to_str(mmd) + else: + # Set some irrelevant buildopts options to test that KojiModuleBuilder + # is not confused by this. + mmd = self.module.mmd() + opts = Modulemd.Buildopts() + opts.set_rpm_macros("%my_macro 1") + mmd.set_buildopts(opts) + self.module.modulemd = mmd_to_str(mmd) if repo_include_all is False: mmd = self.module.mmd()