From: Daan De Meyer Date: Wed, 3 Apr 2024 08:24:05 +0000 (+0200) Subject: Make sure multiple image definitions can parse the same include X-Git-Tag: v23~39^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2580%2Fhead;p=thirdparty%2Fmkosi.git Make sure multiple image definitions can parse the same include --- diff --git a/mkosi/config.py b/mkosi/config.py index 019c0410c..54554e074 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -3460,6 +3460,7 @@ def parse_config(argv: Sequence[str] = (), *, resources: Path = Path("/")) -> tu ns_copy = copy.deepcopy(namespace) defaults_copy = copy.deepcopy(defaults) + parsed_includes_copy = copy.deepcopy(parsed_includes) setattr(namespace, "image", name) @@ -3472,6 +3473,7 @@ def parse_config(argv: Sequence[str] = (), *, resources: Path = Path("/")) -> tu namespace = ns_copy defaults = defaults_copy + parsed_includes = parsed_includes_copy if not images: setattr(namespace, "image", None) diff --git a/tests/test_config.py b/tests/test_config.py index dc90d6e2c..10e389b9c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -221,6 +221,43 @@ def test_parse_config(tmp_path: Path) -> None: assert config.split_artifacts is False +def test_parse_includes_once(tmp_path: Path) -> None: + d = tmp_path + + (d / "mkosi.conf").write_text( + """\ + [Content] + Bootable=yes + BuildPackages=abc + """ + ) + (d / "abc.conf").write_text( + """\ + [Content] + BuildPackages=def + """ + ) + + with chdir(d): + _, [config] = parse_config(["--include", "abc.conf", "--include", "abc.conf"]) + assert config.build_packages == ["def", "abc"] + + (d / "mkosi.images").mkdir() + + for n in ("one", "two"): + (d / "mkosi.images" / f"{n}.conf").write_text( + """\ + [Config] + Include=abc.conf + """ + ) + + with chdir(d): + _, [one, two] = parse_config([]) + assert one.build_packages == ["abc", "def"] + assert two.build_packages == ["abc", "def"] + + def test_profiles(tmp_path: Path) -> None: d = tmp_path