]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Check MinimumVersion= during config parsing
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 7 Feb 2025 09:08:09 +0000 (10:08 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 7 Feb 2025 10:09:59 +0000 (11:09 +0100)
We fail on unknown settings, so currently if the mkosi version is too
old, we fail during config parsing before we ever get to check if the
current version is older than the minimum version.

Let's fix this by checking the minimum version during config parsing
itself. This means it can't be overridden later on anymore with a lower
version during config parsing but I doubt this will ever happen in the
first place.

mkosi/__init__.py
mkosi/config.py

index f185c02dbed216f009eca509149485b9fdd8a775..997a4fa96063b73c2b280f7c4eb8fb97c94d7a84 100644 (file)
@@ -4815,9 +4815,6 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None:
 
     last = images[-1]
 
-    if (minversion := last.minimum_version) and minversion > __version__:
-        die(f"mkosi {minversion} or newer is required by this configuration (found {__version__})")
-
     if not in_sandbox() and last.tools_tree and last.tools_tree == Path("default"):
         tools = finalize_default_tools(last, resources=resources)
     else:
index 474407b7c225b9356f4da3571b586e7247ba3308..8f6750fd25d3b6e0a80035f64afc5ecd623bbf0d 100644 (file)
@@ -1376,13 +1376,17 @@ def config_parse_vsock_cid(value: Optional[str], old: Optional[int]) -> Optional
 
 
 def config_parse_minimum_version(
-    value: Optional[str], old: Optional[GenericVersion]
+    value: Optional[str],
+    old: Optional[GenericVersion],
 ) -> Optional[GenericVersion]:
     if not value:
         return old
 
     new = GenericVersion(value)
 
+    if new > __version__:
+        die(f"mkosi {new} or newer is required by this configuration (found {__version__})")
+
     if not old:
         return new