From: Daan De Meyer Date: Fri, 5 May 2023 08:06:44 +0000 (+0200) Subject: Add Bootable= match X-Git-Tag: v15~179^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be1d37d3e979397bbb642283827459e2ae962873;p=thirdparty%2Fmkosi.git Add Bootable= match --- diff --git a/mkosi.md b/mkosi.md index dc53154b3..b5d73a347 100644 --- a/mkosi.md +++ b/mkosi.md @@ -249,6 +249,12 @@ a boolean argument: either "1", "yes", or "true" to enable, or "0", space-separated list. If multiple image version constraints are specified, all must be satisfied for the match to succeed. +`Bootable=` + +: Matches against the configured value for the `Bootable=` feature. Takes a boolean value or `auto`. Multiple + values may be specified, separated by commas. If multiple values are specified, the condition is satisfied + if the current value of the `Bootable=` feature matches any of the specified values. + | Matcher | Multiple Values | Globs | Rich Comparisons | Default | |-----------------|-----------------|-------|------------------|-------------------------| | `Distribution=` | yes | no | no | match host distribution | @@ -256,6 +262,7 @@ a boolean argument: either "1", "yes", or "true" to enable, or "0", | `PathExists=` | no | no | no | match fails | | `ImageId=` | yes | yes | no | match fails | | `ImageVersion=` | yes | no | yes | match fails | +| `Bootable=` | yes | no | no | match auto feature | ### [Distribution] Section diff --git a/mkosi/config.py b/mkosi/config.py index 9bc982dbc..819ccfa0e 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -141,16 +141,20 @@ def config_match_boolean(dest: str, value: str, namespace: argparse.Namespace) - return cast(bool, getattr(namespace, dest) == parse_boolean(value)) -def config_parse_feature(dest: str, value: Optional[str], namespace: argparse.Namespace) -> ConfigFeature: - if dest in namespace: - return getattr(namespace, dest) # type: ignore - +def parse_feature(value: Optional[str]) -> ConfigFeature: if not value or value == ConfigFeature.auto.value: return ConfigFeature.auto return ConfigFeature.enabled if parse_boolean(value) else ConfigFeature.disabled +def config_parse_feature(dest: str, value: Optional[str], namespace: argparse.Namespace) -> ConfigFeature: + if dest in namespace: + return getattr(namespace, dest) # type: ignore + + return parse_feature(value) + + def config_parse_compression(dest: str, value: Optional[str], namespace: argparse.Namespace) -> Optional[Compression]: if dest in namespace: return getattr(namespace, dest) # type: ignore @@ -895,6 +899,7 @@ class MkosiConfigParser: dest="bootable", section="Content", parse=config_parse_feature, + match=config_make_list_matcher(delimiter=",", parse=parse_feature), ), MkosiConfigSetting( dest="password",