init: Keep parent groups in addon comps environments

The environment in comps for a variant can refer to groups in parent
variant (either for addons, or because of other configuration). We
should not remove the groups in this case.

This requires changes in two places:
 * teaching `comps_filter` about groups that should not be removed
 * fixing writing comps so that it does not actually change the data as
   well

JIRA: COMPOSE-2612
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-11-02 12:43:56 +01:00
parent a73099d446
commit 85bf5535bc
8 changed files with 142 additions and 10 deletions

View file

@ -29,6 +29,13 @@ def main():
help="remove all environment sections")
parser.add_argument("--keep-empty-group", default=[], action="append", metavar="GROUPID",
help="keep groups even if they are empty")
parser.add_argument(
"--lookaside-group",
default=[],
action="append",
metavar="GROUPID",
help="keep this group in environments even if they are not defined in the comps",
)
parser.add_argument("--no-cleanup", default=False, action="store_true",
help="don't remove empty groups and categories")
parser.add_argument("--no-reindent", default=False, action="store_true",
@ -46,7 +53,7 @@ def main():
f.filter_environments(opts.arch, opts.variant, opts.arch_only_environments)
if not opts.no_cleanup:
f.cleanup(opts.keep_empty_group)
f.cleanup(opts.keep_empty_group, opts.lookaside_group)
if opts.remove_categories:
f.remove_categories()