gather: Make devel modules configurable

By default nothing should change. This patch adds a new config option
that enables all this new craziness:

 * it turns of applying module filters at pkgset level
 * it creates new modules and adds them to the compose

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-10-02 11:09:12 +02:00
parent 06b32b5d80
commit 1a161982c0
5 changed files with 90 additions and 24 deletions

View File

@ -608,6 +608,10 @@ def make_schema():
"type": "boolean",
"default": False,
},
"include_devel_modules": {
"type": "boolean",
"default": False,
},
"pkgset_source": {
"type": "string",

View File

@ -70,24 +70,25 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
arch_mmd = mmd.copy()
variant.arch_mmds[arch][nsvc] = arch_mmd
devel_nsvc = "%s-devel:%s:%s:%s" % (
mmd.peek_name(),
mmd.peek_stream(),
mmd.peek_version(),
mmd.peek_context(),
)
if devel_nsvc not in variant.arch_mmds[arch]:
arch_mmd = mmd.copy()
arch_mmd.set_name(arch_mmd.peek_name() + "-devel")
# Depend on the actual module
for dep in arch_mmd.get_dependencies():
dep.add_requires_single(mmd.peek_name(), mmd.peek_stream())
# Delete API and profiles
arch_mmd.set_rpm_api(Modulemd.SimpleSet())
arch_mmd.clear_profiles()
# Store the new modulemd
variant.arch_mmds[arch][devel_nsvc] = arch_mmd
variant.module_uid_to_koji_tag[devel_nsvc] = variant.module_uid_to_koji_tag.get(nsvc)
if self.compose.conf["include_devel_modules"]:
devel_nsvc = "%s-devel:%s:%s:%s" % (
mmd.peek_name(),
mmd.peek_stream(),
mmd.peek_version(),
mmd.peek_context(),
)
if devel_nsvc not in variant.arch_mmds[arch]:
arch_mmd = mmd.copy()
arch_mmd.set_name(arch_mmd.peek_name() + "-devel")
# Depend on the actual module
for dep in arch_mmd.get_dependencies():
dep.add_requires_single(mmd.peek_name(), mmd.peek_stream())
# Delete API and profiles
arch_mmd.set_rpm_api(Modulemd.SimpleSet())
arch_mmd.clear_profiles()
# Store the new modulemd
variant.arch_mmds[arch][devel_nsvc] = arch_mmd
variant.module_uid_to_koji_tag[devel_nsvc] = variant.module_uid_to_koji_tag.get(nsvc)
# Contains per-module RPMs added to variant.
added_rpms = {}
@ -120,7 +121,7 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
added_rpms[nsvc].append(str(rpm_obj.nevra))
log.write('Adding %s because it is in %s\n'
% (rpm_obj, nsvc))
else:
elif self.compose.conf["include_devel_modules"]:
nsvc_devel = "%s-devel:%s:%s:%s" % (
mmd.peek_name(),
mmd.peek_stream(),

View File

@ -660,7 +660,9 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event):
event,
inherit=should_inherit,
logfile=logfile,
exclude_packages=module_tag_rpm_filter.get(compose_tag),
exclude_packages=module_tag_rpm_filter.get(compose_tag)
if not compose.conf["include_devel_modules"]
else None,
)
for variant in compose.all_variants.values():
if compose_tag in variant_tags[variant]:

View File

@ -740,10 +740,11 @@ class TestCreateVariantRepo(PungiTestCase):
variant = compose.variants['Server']
variant.arch_mmds["x86_64"] = {}
variant.arch_mmds["x86_64"]["test-f27"] = variant.add_fake_module(
variant.arch_mmds["x86_64"]["test:f27:1:2017"] = variant.add_fake_module(
"test:f27:1:2017", rpm_nvrs=["pkg-0:1.0.0-1.x86_64"])
variant.arch_mmds["x86_64"]["test-f28"] = variant.add_fake_module(
variant.arch_mmds["x86_64"]["test:f28:1:2017"] = variant.add_fake_module(
"test:f28:1:2017", rpm_nvrs=["pkg-0:2.0.0-1.x86_64"])
variant.mmds = list(variant.arch_mmds["x86_64"].values())
def mocked_modifyrepo_cmd(repodir, mmd_path, **kwargs):
modules = Modulemd.Module.new_all_from_file(mmd_path)
@ -784,16 +785,17 @@ class TestCreateVariantRepo(PungiTestCase):
variant = compose.variants['Server']
variant.arch_mmds["x86_64"] = {
"test:f27:2018:cafe": variant.add_fake_module(
"test:f27:1:2017",
"test:f27:2018:cafe",
rpm_nvrs=["bash-0:4.3.30-2.fc21.x86_64"],
with_artifacts=True,
),
"test:f28:2018:beef": variant.add_fake_module(
"test:f28:1:2017",
"test:f28:2018:beef",
rpm_nvrs=["pkg-0:2.0.0-1.x86_64"],
with_artifacts=True,
),
}
variant.mmds = list(variant.arch_mmds["x86_64"].values())
variant.module_uid_to_koji_tag = {
"test:f28:2018:beef": "tag-1",
"test:f27:2018:cafe": "tag-2",

View File

@ -318,6 +318,14 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
peek_context=mock.Mock(return_value="ctx"),
)
}
self.compose.variants["Server"].mmds = [
mock.Mock(
peek_name=mock.Mock(return_value="mod"),
peek_stream=mock.Mock(return_value="master"),
peek_version=mock.Mock(return_value="ver"),
peek_context=mock.Mock(return_value="ctx"),
)
]
po.return_value = (mock.Mock(), mock.Mock())
res = self.phase.run_solver(
@ -351,6 +359,55 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
],
)
def test_with_modules_with_devel(self, run, gc, po):
self.compose.has_comps = False
self.compose.variants["Server"].arch_mmds["x86_64"] = {
"mod:master": mock.Mock(
peek_name=mock.Mock(return_value="mod"),
peek_stream=mock.Mock(return_value="master"),
peek_version=mock.Mock(return_value="ver"),
peek_context=mock.Mock(return_value="ctx"),
),
"mod-devel:master": mock.Mock(
peek_name=mock.Mock(return_value="mod-devel"),
peek_stream=mock.Mock(return_value="master"),
peek_version=mock.Mock(return_value="ver"),
peek_context=mock.Mock(return_value="ctx"),
),
}
po.return_value = (mock.Mock(), mock.Mock())
res = self.phase.run_solver(
self.compose.variants["Server"],
"x86_64",
[],
platform="pl",
)
self.assertEqual(res, po.return_value)
self.assertEqual(po.call_args_list, [mock.call(self.logfile1)])
self.assertEqual(
run.call_args_list,
[
mock.call(
gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY
)
],
)
self.assertEqual(
gc.call_args_list,
[
mock.call(
"x86_64",
[self._repo("repo"), self._repo("module_repo_Server")],
[],
[],
["mod:master", "mod-devel:master"],
platform="pl",
)
],
)
def test_with_comps(self, run, gc, po):
po.return_value = (mock.Mock(), mock.Mock())
res = self.phase.run_solver(