# were specified on the CLI by copying them to the CLI namespace. Any settings
# that are not marked as "universal" are deleted from the CLI namespace.
for s in SETTINGS:
- if s.scope == SettingScope.universal:
+ if (
+ s.scope == SettingScope.universal and (
+ # For list-based settings, don't pass down empty lists unless it came
+ # explicitly from the config file or the CLI. This makes sure that default
+ # values from subimages are still used if no value is explicitly configured
+ # in the main image or on the CLI.
+ not isinstance(getattr(config, s.dest), (list, dict, set)) or
+ getattr(config, s.dest) or
+ hasattr(context.cli, s.dest) or
+ hasattr(context.config, s.dest)
+ )
+ ):
setattr(context.cli, s.dest, copy.deepcopy(getattr(config, s.dest)))
elif hasattr(context.cli, s.dest):
delattr(context.cli, s.dest)
)
(d / "mkosi.images/two").mkdir()
+ (d / "mkosi.images/two/mkosi.skeleton").mkdir()
(d / "mkosi.images/two/mkosi.conf").write_text(
"""
[Distribution]
assert one.image_version == "1.2.3"
assert two.image_version == "4.5.6"
+ # Default values from subimages should be picked up.
+ assert len(one.package_manager_trees) == 0
+ assert len(two.package_manager_trees) == 1 and two.package_manager_trees[0].source.name == "mkosi.skeleton"
+
with chdir(d):
_, [one, two, config] = parse_config(["--image-version", "7.8.9"])