]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Make ImageId= and ImageVersion= overridable by subimages
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 5 Aug 2024 08:15:11 +0000 (10:15 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 5 Aug 2024 08:42:30 +0000 (10:42 +0200)
Fixes #2938

mkosi/config.py
mkosi/resources/mkosi.md
tests/test_config.py

index a3ed1d5b4b8163c3281017a5cb67cab01bde6998..63775c23a8c5175586ed0bd3a28aded2109a6608 100644 (file)
@@ -2142,7 +2142,7 @@ SETTINGS = (
         help="Set version for image",
         paths=("mkosi.version",),
         path_read_text=True,
-        scope=SettingScope.universal,
+        scope=SettingScope.inherit,
     ),
     ConfigSetting(
         dest="image_id",
@@ -2150,7 +2150,7 @@ SETTINGS = (
         section="Output",
         specifier="i",
         help="Set ID for image",
-        scope=SettingScope.universal,
+        scope=SettingScope.inherit,
     ),
     ConfigSetting(
         dest="split_artifacts",
index 47bdad65b2bd967449f95df96a3344df5be835c2..7136a625cc9c69942a6752a7f84393bc2caae511 100644 (file)
@@ -2491,8 +2491,6 @@ overridden):
 - `CacheDirectory=`
 - `PackageCacheDirectory=`
 - `BuildDirectory=`
-- `ImageId=`
-- `ImageVersion=`
 - `SectorSize=`
 - `RepartOffline=`
 - `UseSubvolumes=`
@@ -2517,6 +2515,13 @@ overridden):
 - `ToolsTree=`
 - `ToolsTreeCertificates=`
 
+There are also settings which are passed down to subimages but can
+be overridden. Currently the following settings are passed down to
+subimages but can be overridden:
+
+- `ImageId=`
+- `ImageVersion=`
+
 Images can refer to outputs of images they depend on. Specifically,
 for the following options, mkosi will only check whether the inputs
 exist just before building the image:
index 10f51057911b7fd9468da2c5975d9ceab5457c7a..4f197caaae2dfd8ed58c46ced43cce0b412e3015 100644 (file)
@@ -262,6 +262,14 @@ def test_parse_config(tmp_path: Path) -> None:
             """
         )
 
+    with (d / "mkosi.images" / "two.conf").open("a") as f:
+        f.write(
+            """
+            [Output]
+            ImageVersion=4.5.6
+            """
+        )
+
     with chdir(d):
         _, [one, two, config] = parse_config(["--package", "qed", "--build-package", "def", "--repositories", "cli"])
 
@@ -285,6 +293,10 @@ def test_parse_config(tmp_path: Path) -> None:
     assert one.repositories == ["append", "epel", "epel-next", "cli"]
     assert two.repositories == ["append", "epel", "epel-next", "cli"]
 
+    # Inherited settings should be passed down to subimages but overridable by subimages.
+    assert one.image_version == "1.2.3"
+    assert two.image_version == "4.5.6"
+
 
 def test_parse_includes_once(tmp_path: Path) -> None:
     d = tmp_path