return config_parse_list
-def config_match_image_version(match: str, value: str) -> bool:
- image_version = GenericVersion(value)
+def config_match_version(match: str, value: str) -> bool:
+ version = GenericVersion(value)
for sigil, opfunc in {
"==": operator.eq,
comp_version = GenericVersion(match)
# all constraints must be fulfilled
- if not op(image_version, comp_version):
+ if not op(version, comp_version):
return False
return True
return (value, hashed)
+def match_systemd_version(value: str) -> bool:
+ if not value:
+ return False
+
+ version = run(["systemctl", "--version"], stdout=subprocess.PIPE).stdout.strip().split()[1]
+ return config_match_version(value, version)
+
+
@dataclasses.dataclass(frozen=True)
class MkosiConfigSetting:
dest: str
),
MkosiConfigSetting(
dest="image_version",
- match=config_match_image_version,
+ match=config_match_version,
section="Output",
help="Set version for image",
paths=("mkosi.version",),
name="PathExists",
match=match_path_exists,
),
+ MkosiMatch(
+ name="SystemdVersion",
+ match=match_systemd_version,
+ ),
)
: Matches against the configured image version. Image versions can be prepended by the operators `==`, `!=`,
`>=`, `<=`, `<`, `>` for rich version comparisons according to the UAPI group version format specification.
- If no operator is prepended, the equality operator is assumed by default If this condition is used and no
+ If no operator is prepended, the equality operator is assumed by default. If this condition is used and no
image version has been explicitly configured yet, this condition fails.
`Bootable=`
: Matches against the configured value for the `Format=` option. Takes
an output format (see the `Format=` option).
-| Matcher | Globs | Rich Comparisons | Default |
-|-----------------|-------|------------------|-------------------------|
-| `Distribution=` | no | no | match host distribution |
-| `Release=` | no | no | match host release |
-| `PathExists=` | no | no | match fails |
-| `ImageId=` | yes | no | match fails |
-| `ImageVersion=` | no | yes | match fails |
-| `Bootable=` | no | no | match auto feature |
-| `Format=` | no | no | match default format |
+`SystemdVersion=`
+
+: Matches against the systemd version on the host (as reported by
+ `systemctl --version`). Values can be prepended by the operators `==`,
+ `!=`, `>=`, `<=`, `<`, `>` for rich version comparisons according to
+ the UAPI group version format specification. If no operator is
+ prepended, the equality operator is assumed by default.
+
+| Matcher | Globs | Rich Comparisons | Default |
+|-------------------|-------|------------------|-------------------------|
+| `Distribution=` | no | no | match host distribution |
+| `Release=` | no | no | match host release |
+| `PathExists=` | no | no | match fails |
+| `ImageId=` | yes | no | match fails |
+| `ImageVersion=` | no | yes | match fails |
+| `Bootable=` | no | no | match auto feature |
+| `Format=` | no | no | match default format |
+| `SystemdVersion=` | no | yes | match fails |
### [Preset] Section