comps: Filter comps groups for optional variants
The optional variant can defined by just adding has_optional=True into variant xml. In such case it has no comps groups and Pungi would copy the original file unmodified. This leads to extra packages being pulled into the optional variant. In this case the correct solution is to filter the comps and remove all groups. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
d9ab899920
commit
8bc65a8be5
@ -46,8 +46,11 @@ class InitPhase(PhaseBase):
|
||||
# write variant comps
|
||||
for variant in self.compose.get_variants():
|
||||
for arch in variant.arches:
|
||||
if variant.groups:
|
||||
# The variant lists only some groups, run filter.
|
||||
if variant.groups or variant.type == 'optional':
|
||||
# The variant lists only some groups, run filter. Other
|
||||
# option is that it's optional variant, in which case
|
||||
# we want to filter everything (unless there was
|
||||
# explicit list in which case it will be used).
|
||||
write_variant_comps(self.compose, arch, variant)
|
||||
else:
|
||||
# The variant does not mention any groups, copy
|
||||
@ -127,6 +130,8 @@ def write_variant_comps(compose, arch, variant):
|
||||
def copy_variant_comps(compose, arch, variant):
|
||||
global_comps = compose.paths.work.comps(arch="global")
|
||||
comps_file = compose.paths.work.comps(arch=arch, variant=variant)
|
||||
msg = "Copying original comps file (arch: %s, variant: %s): %s" % (arch, variant, comps_file)
|
||||
compose.log_debug(msg)
|
||||
shutil.copy(global_comps, comps_file)
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@ class TestInitPhase(PungiTestCase):
|
||||
def test_run(self, write_prepopulate, write_variant, create_comps, write_arch, write_global):
|
||||
compose = DummyCompose(self.topdir, {})
|
||||
compose.has_comps = True
|
||||
compose.setup_optional()
|
||||
phase = init.InitPhase(compose)
|
||||
phase.run()
|
||||
|
||||
@ -38,7 +39,8 @@ class TestInitPhase(PungiTestCase):
|
||||
mock.call(compose, 'amd64', compose.variants['Server']),
|
||||
mock.call(compose, 'amd64', compose.variants['Client']),
|
||||
mock.call(compose, 'x86_64', compose.variants['Everything']),
|
||||
mock.call(compose, 'amd64', compose.variants['Everything'])])
|
||||
mock.call(compose, 'amd64', compose.variants['Everything']),
|
||||
mock.call(compose, 'x86_64', compose.all_variants['Server-optional'])])
|
||||
|
||||
@mock.patch('pungi.phases.init.copy_variant_comps')
|
||||
@mock.patch('pungi.phases.init.write_global_comps')
|
||||
|
Loading…
Reference in New Issue
Block a user