From: Daan De Meyer Date: Mon, 5 Aug 2024 08:15:11 +0000 (+0200) Subject: Make ImageId= and ImageVersion= overridable by subimages X-Git-Tag: v25~370^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=310da3a75efdfe88fb8f2666094429cd921549ee;p=thirdparty%2Fmkosi.git Make ImageId= and ImageVersion= overridable by subimages Fixes #2938 --- diff --git a/mkosi/config.py b/mkosi/config.py index a3ed1d5b4..63775c23a 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -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", diff --git a/mkosi/resources/mkosi.md b/mkosi/resources/mkosi.md index 47bdad65b..7136a625c 100644 --- a/mkosi/resources/mkosi.md +++ b/mkosi/resources/mkosi.md @@ -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: diff --git a/tests/test_config.py b/tests/test_config.py index 10f510579..4f197caaa 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -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