]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
`Output=` now has the version appended if unset
authorMichael Ferrari <nekkodroid404@gmail.com>
Wed, 20 Dec 2023 01:12:07 +0000 (02:12 +0100)
committerMichael Ferrari <nekkodroid404@gmail.com>
Wed, 20 Dec 2023 01:37:49 +0000 (02:37 +0100)
Previously `Output=` would only default to `ImageId=` if unset, but the
output files would have the version appended, resulting in `%o` not
returning the actual name of the output files.

This also moves the default handling to a `default_factory`

mkosi/config.py

index d215bc411056df96c8010b921ed9b33e04dc2697..ffbb3eef9a6a9aca576544f9aeb10f96fdac574f 100644 (file)
@@ -525,6 +525,15 @@ def config_default_compression(namespace: argparse.Namespace) -> Compression:
         return Compression.none
 
 
+def config_default_output(namespace: argparse.Namespace) -> str:
+    output = namespace.image_id or namespace.image or "image"
+
+    if namespace.image_version:
+        output += f"_{namespace.image_version}"
+
+    return output
+
+
 def config_default_distribution(namespace: argparse.Namespace) -> Distribution:
     detected = detect_distribution()[0]
 
@@ -1553,6 +1562,8 @@ SETTINGS = (
         section="Output",
         specifier="o",
         parse=config_parse_output,
+        default_factory=config_default_output,
+        default_factory_depends=("image_id", "image_version"),
         help="Output name",
     ),
     MkosiConfigSetting(
@@ -3105,9 +3116,6 @@ def load_config(args: MkosiArgs, config: argparse.Namespace) -> MkosiConfig:
     if config.sign:
         config.checksum = True
 
-    if config.output is None:
-        config.output = config.image_id or config.image or "image"
-
     config.credentials = load_credentials(config)
     config.kernel_command_line_extra = load_kernel_command_line_extra(config)
     config.environment = load_environment(config)