def to_efi(self) -> Optional[str]:
return {
- Architecture.x86_64: "x64",
Architecture.x86: "ia32",
- Architecture.arm64: "aa64",
+ Architecture.x86_64: "x64",
Architecture.arm: "arm",
+ Architecture.arm64: "aa64",
+ Architecture.riscv32: "riscv32",
Architecture.riscv64: "riscv64",
Architecture.loongarch64: "loongarch64",
}.get(self) # fmt: skip
return config_match_enum
+def config_match_architecture(match: str, value: Architecture) -> bool:
+ if match == "uefi":
+ return value.to_efi() is not None
+
+ return config_make_enum_matcher(Architecture)(match, value)
+
+
def package_sort_key(package: str) -> tuple[int, str]:
"""Sorts packages: normal first, paths second, conditional third"""
section="Distribution",
specifier="a",
parse=config_make_enum_parser(Architecture),
- match=config_make_enum_matcher(Architecture),
+ match=config_match_architecture,
default=Architecture.native(),
choices=Architecture.choices(),
help="Override the architecture of installation",
assert config.output == "qed"
+def test_match_architecture(tmp_path: Path) -> None:
+ d = tmp_path
+
+ (d / "mkosi.conf").write_text(
+ """\
+ [Match]
+ Architecture=uefi
+
+ [Content]
+ Output=qed
+ """
+ )
+
+ with chdir(d):
+ _, _, [config] = parse_config(["--architecture", "arm64"])
+
+ assert config.output == "qed"
+
+
@pytest.mark.parametrize("image1,image2", itertools.combinations_with_replacement(["image_a", "image_b"], 2))
def test_match_imageid(tmp_path: Path, image1: str, image2: str) -> None:
with chdir(tmp_path):