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:
parent
c118adc705
commit
a042906717
@ -141,10 +141,6 @@ Options
|
|||||||
(*bool*) -- When set to ``False``, the comps files for variants will not
|
(*bool*) -- When set to ``False``, the comps files for variants will not
|
||||||
have their environments filtered to match the variant.
|
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**
|
**tree_arches**
|
||||||
([*str*]) -- list of architectures which should be included; if undefined,
|
([*str*]) -- list of architectures which should be included; if undefined,
|
||||||
all architectures from variants.xml will be included
|
all architectures from variants.xml will be included
|
||||||
|
@ -577,8 +577,7 @@ def _make_schema():
|
|||||||
"default": True,
|
"default": True,
|
||||||
},
|
},
|
||||||
"keep_original_comps": {
|
"keep_original_comps": {
|
||||||
"$ref": "#/definitions/list_of_strings",
|
"deprecated": "no <groups> tag for respective variant in variants XML"
|
||||||
"default": []
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"link_type": {
|
"link_type": {
|
||||||
|
@ -47,12 +47,14 @@ class InitPhase(PhaseBase):
|
|||||||
|
|
||||||
# write variant comps
|
# write variant comps
|
||||||
for variant in self.compose.get_variants():
|
for variant in self.compose.get_variants():
|
||||||
should_preserve = variant.uid in self.compose.conf['keep_original_comps']
|
|
||||||
for arch in variant.arches:
|
for arch in variant.arches:
|
||||||
if should_preserve:
|
if variant.groups:
|
||||||
copy_variant_comps(self.compose, arch, variant)
|
# The variant lists only some groups, run filter.
|
||||||
else:
|
|
||||||
write_variant_comps(self.compose, arch, variant)
|
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?
|
# download variants.xml / product.xml?
|
||||||
|
|
||||||
|
@ -369,22 +369,8 @@ class LiveMediaConfigTestCase(unittest.TestCase):
|
|||||||
self.assertEqual(checks.validate(cfg), [])
|
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):
|
class TestSuggestions(unittest.TestCase):
|
||||||
def test_validate_keep_original_comps_empty(self):
|
def test_with_a_typo(self):
|
||||||
cfg = load_config(PKGSET_REPOS,
|
cfg = load_config(PKGSET_REPOS,
|
||||||
product_pid=None)
|
product_pid=None)
|
||||||
|
|
||||||
|
@ -48,10 +48,9 @@ class TestInitPhase(PungiTestCase):
|
|||||||
@mock.patch('pungi.phases.init.write_prepopulate_file')
|
@mock.patch('pungi.phases.init.write_prepopulate_file')
|
||||||
def test_run_with_preserve(self, write_prepopulate, write_variant, create_comps,
|
def test_run_with_preserve(self, write_prepopulate, write_variant, create_comps,
|
||||||
write_arch, write_global, copy_comps):
|
write_arch, write_global, copy_comps):
|
||||||
compose = DummyCompose(self.topdir, {
|
compose = DummyCompose(self.topdir, {})
|
||||||
'keep_original_comps': ['Everything'],
|
|
||||||
})
|
|
||||||
compose.has_comps = True
|
compose.has_comps = True
|
||||||
|
compose.variants['Everything'].groups = []
|
||||||
phase = init.InitPhase(compose)
|
phase = init.InitPhase(compose)
|
||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
@ -90,6 +89,20 @@ class TestInitPhase(PungiTestCase):
|
|||||||
self.assertItemsEqual(copy_comps.mock_calls, [])
|
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):
|
class TestWriteArchComps(PungiTestCase):
|
||||||
|
|
||||||
@mock.patch('pungi.phases.init.run')
|
@mock.patch('pungi.phases.init.run')
|
||||||
@ -222,19 +235,5 @@ class TestWriteVariantComps(PungiTestCase):
|
|||||||
self.assertEqual(comps.write_comps.mock_calls, [])
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user