init: Remove keep_original_comps option

The same information can be inferred from definitions in variants.xml:
if the variant has no groups defined, we include packages from all
groups. By the same logic we can also include all groups in the comps
file.

The config validation is updated to give a hint on how to remove the
option from the configuration.

Relates: #29
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-08-19 10:09:40 +02:00
parent c118adc705
commit a042906717
5 changed files with 24 additions and 42 deletions

View File

@ -141,10 +141,6 @@ Options
(*bool*) -- When set to ``False``, the comps files for variants will not
have their environments filtered to match the variant.
**keep_original_comps** [optional]
(*list*) -- List of variants for which the original comps file will be
copied without any modifications. Overwrites `comps_filter_environments`.
**tree_arches**
([*str*]) -- list of architectures which should be included; if undefined,
all architectures from variants.xml will be included

View File

@ -577,8 +577,7 @@ def _make_schema():
"default": True,
},
"keep_original_comps": {
"$ref": "#/definitions/list_of_strings",
"default": []
"deprecated": "no <groups> tag for respective variant in variants XML"
},
"link_type": {

View File

@ -47,12 +47,14 @@ class InitPhase(PhaseBase):
# write variant comps
for variant in self.compose.get_variants():
should_preserve = variant.uid in self.compose.conf['keep_original_comps']
for arch in variant.arches:
if should_preserve:
copy_variant_comps(self.compose, arch, variant)
else:
if variant.groups:
# The variant lists only some groups, run filter.
write_variant_comps(self.compose, arch, variant)
else:
# The variant does not mention any groups, copy
# original file.
copy_variant_comps(self.compose, arch, variant)
# download variants.xml / product.xml?

View File

@ -369,22 +369,8 @@ class LiveMediaConfigTestCase(unittest.TestCase):
self.assertEqual(checks.validate(cfg), [])
class InitConfigTestCase(unittest.TestCase):
def test_validate_keep_original_comps_empty(self):
cfg = load_config(PKGSET_REPOS,
keep_original_comps=[])
self.assertEqual(checks.validate(cfg), [])
def test_validate_keep_original_comps_filled_in(self):
cfg = load_config(PKGSET_REPOS,
keep_original_comps=['Everything'])
self.assertEqual(checks.validate(cfg), [])
class TestSuggestions(unittest.TestCase):
def test_validate_keep_original_comps_empty(self):
def test_with_a_typo(self):
cfg = load_config(PKGSET_REPOS,
product_pid=None)

View File

@ -48,10 +48,9 @@ class TestInitPhase(PungiTestCase):
@mock.patch('pungi.phases.init.write_prepopulate_file')
def test_run_with_preserve(self, write_prepopulate, write_variant, create_comps,
write_arch, write_global, copy_comps):
compose = DummyCompose(self.topdir, {
'keep_original_comps': ['Everything'],
})
compose = DummyCompose(self.topdir, {})
compose.has_comps = True
compose.variants['Everything'].groups = []
phase = init.InitPhase(compose)
phase.run()
@ -90,6 +89,20 @@ class TestInitPhase(PungiTestCase):
self.assertItemsEqual(copy_comps.mock_calls, [])
class TestCopyVariantComps(PungiTestCase):
@mock.patch('shutil.copy')
def test_run(self, copy):
compose = DummyCompose(self.topdir, {})
variant = compose.variants['Server']
init.copy_variant_comps(compose, 'x86_64', variant)
self.assertEqual(copy.mock_calls,
[mock.call(self.topdir + '/work/global/comps/comps-global.xml',
self.topdir + '/work/x86_64/comps/comps-Server.x86_64.xml')])
class TestWriteArchComps(PungiTestCase):
@mock.patch('pungi.phases.init.run')
@ -222,19 +235,5 @@ class TestWriteVariantComps(PungiTestCase):
self.assertEqual(comps.write_comps.mock_calls, [])
class TestCopyVariantComps(PungiTestCase):
@mock.patch('shutil.copy')
def test_run(self, copy):
compose = DummyCompose(self.topdir, {})
variant = compose.variants['Server']
init.copy_variant_comps(compose, 'x86_64', variant)
self.assertEqual(copy.mock_calls,
[mock.call(self.topdir + '/work/global/comps/comps-global.xml',
self.topdir + '/work/x86_64/comps/comps-Server.x86_64.xml')])
if __name__ == "__main__":
unittest.main()