| |
@@ -1,16 +1,22 @@
|
| |
# -*- coding: utf-8 -*-
|
| |
|
| |
+ from collections import defaultdict
|
| |
+ from itertools import chain
|
| |
+
|
| |
from six.moves import configparser
|
| |
|
| |
|
| |
- def write_legacy_composeinfo(ci, file):
|
| |
+ def write_legacy_composeinfo(ci, file, extra_addon_list=None):
|
| |
"""Write a legacy INI-style composeinfo data into `file`."""
|
| |
conf = configparser.SafeConfigParser(dict_type=SortedDict)
|
| |
_serialize_compose(conf, ci.compose)
|
| |
_serialize_product(conf, ci.release, ci.compose)
|
| |
if ci.release.is_layered:
|
| |
_serialize_base_product(conf, ci.base_product)
|
| |
- _serialize_variants(conf, ci.variants)
|
| |
+ extra_addons = defaultdict(set)
|
| |
+ for base, addon in extra_addon_list or []:
|
| |
+ extra_addons[base].add(addon)
|
| |
+ _serialize_variants(conf, ci.variants, extra_addons=extra_addons)
|
| |
conf.write(file)
|
| |
|
| |
|
| |
@@ -88,7 +94,7 @@
|
| |
_set("debuginfo", paths.debug_repository, arch)
|
| |
|
| |
|
| |
- def _serialize_variant(conf, variant):
|
| |
+ def _serialize_variant(conf, variant, extra_addons):
|
| |
section = 'variant-%s' % variant.uid
|
| |
conf.add_section(section)
|
| |
|
| |
@@ -107,19 +113,23 @@
|
| |
|
| |
children = set()
|
| |
for child in variant.variants.values():
|
| |
- _serialize_variant(conf, child)
|
| |
+ _serialize_variant(conf, child, set())
|
| |
children.add(child.uid)
|
| |
|
| |
+ children |= extra_addons
|
| |
+
|
| |
if children:
|
| |
conf.set(section, 'variants', ','.join(sorted(children)))
|
| |
|
| |
|
| |
- def _serialize_variants(conf, variants):
|
| |
- ids = sorted(variants.variants.keys())
|
| |
+ def _serialize_variants(conf, variants, extra_addons):
|
| |
+ ids = sorted(
|
| |
+ set(variants.variants.keys()) - set(chain.from_iterable(extra_addons.values()))
|
| |
+ )
|
| |
conf.set('product', 'variants', ','.join(ids))
|
| |
- for variant_id in ids:
|
| |
+ for variant_id in sorted(variants.variants):
|
| |
variant = variants.variants[variant_id]
|
| |
- _serialize_variant(conf, variant)
|
| |
+ _serialize_variant(conf, variant, extra_addons.get(variant_id, set()))
|
| |
|
| |
|
| |
class SortedDict(dict):
|
| |
Even though two variants can be created as standalone variants, we may want to mark them as addons in the legacy
.composeinfo
to make it possible to import to Beaker.