interpreted relative to the parent directory of the config file that the
condition is read from.
+`ImageId=`
+
+: Matches against the configured image ID. If this condition is used and no
+ image ID has been explicitly configured yet, this condition fails. Multiple
+ image IDs may be specified, separated by spaces. If multiple image IDs are
+ specified, the condition is satisfied if the configured image ID equals any of
+ the specified image IDs.
+
### [Distribution] Section
`Distribution=`, `--distribution=`, `-d`
def config_make_list_matcher(
delimiter: str,
+ *,
unescape: bool = False,
all: bool = False,
parse: Callable[[str], Any] = str,
),
MkosiConfigSetting(
dest="image_id",
+ match=config_make_list_matcher(delimiter=" "),
section="Output",
),
MkosiConfigSetting(
if release1 == release2:
assert "testpkg2" in conf.packages
assert "testpkg3" in conf.packages
+
+
+@pytest.mark.parametrize(
+ "image1,image2", itertools.combinations_with_replacement(
+ ["image_a", "image_b", "image_c"], 2
+ )
+)
+def test_match_imageid(image1: str, image2: str) -> None:
+ with cd_temp_dir():
+ parent = Path("mkosi.conf")
+ parent.write_text(
+ dedent(
+ f"""\
+ [Distribution]
+ Distribution=fedora
+ ImageId={image1}
+ """
+ )
+ )
+
+ Path("mkosi.conf.d").mkdir()
+
+ child1 = Path("mkosi.conf.d/child1.conf")
+ child1.write_text(
+ dedent(
+ f"""\
+ [Match]
+ ImageId={image1}
+
+ [Content]
+ Packages=testpkg1
+ """
+ )
+ )
+ child2 = Path("mkosi.conf.d/child2.conf")
+ child2.write_text(
+ dedent(
+ f"""\
+ [Match]
+ ImageId={image2}
+
+ [Content]
+ Packages=testpkg2
+ """
+ )
+ )
+ child3 = Path("mkosi.conf.d/child3.conf")
+ child3.write_text(
+ dedent(
+ f"""\
+ [Match]
+ ImageId={image1} {image2}
+
+ [Content]
+ Packages=testpkg3
+ """
+ )
+ )
+
+ conf = parse([])
+ assert "testpkg1" in conf.packages
+ if image1 == image2:
+ assert "testpkg2" in conf.packages
+ assert "testpkg3" in conf.packages