]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add Bootable= match
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 5 May 2023 08:06:44 +0000 (10:06 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 5 May 2023 13:25:48 +0000 (15:25 +0200)
mkosi.md
mkosi/config.py

index dc53154b32a143b01cf1a0aaae188b3ef794a8f8..b5d73a3473db9264bd4db8e09c31e1df6a36187a 100644 (file)
--- 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
 
index 9bc982dbc449cb6054db7765a2e7bf91251c0bae..819ccfa0e9948522aa40e89ca5f240c2791272f3 100644 (file)
@@ -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",