callback=lambda ns, config: ns.distribution.filesystem(),
depends=("distribution",),
),
+ Specifier(
+ char="I",
+ callback=lambda ns, config: ns.image or "",
+ ),
)
SPECIFIERS_LOOKUP_BY_CHAR = {s.char: s for s in SPECIFIERS}
There are also specifiers that are independent of settings:
-| Specifier | Value |
-|-----------|-----------------------------------------|
-| `%C` | Parent directory of current config file |
-| `%P` | Current working directory |
-| `%D` | Directory that mkosi was invoked in |
+| Specifier | Value |
+|-----------|------------------------------------------------|
+| `%C` | Parent directory of current config file |
+| `%P` | Current working directory |
+| `%D` | Directory that mkosi was invoked in |
+| `%I` | Name of the current subimage in `mkosi.images` |
Finally, there are specifiers that are derived from a setting:
(qemu, nspawn, ...), we now keep $PATH entries inside the user's home
intact. Note that this may cause issues if a PATH entry in your home contains
binaries linked against libraries in `/usr` from the host.
+- Introduced new specifier `%I` which resolves to the name of the current
+ subimage when used in a config under `mkosi.images/`. This differs to `%o`
+ as it is always the name of the config file without extension (or the name
+ of the directory).
## v24
Environment=Distribution=%d
Release=%r
Architecture=%a
+ Image=%I
ImageId=%i
ImageVersion=%v
OutputDirectory=%O
"""
)
+ (d / "mkosi.images").mkdir()
+ (d / "mkosi.images/subimage.conf").write_text(
+ """
+ [Build]
+ Environment=Image=%I
+ """
+ )
+
with chdir(d):
- _, [config] = parse_config()
+ _, [subimage, config] = parse_config()
expected = {
"Distribution": "ubuntu",
"Release": "lunar",
"Architecture": "arm64",
+ "Image": "",
"ImageId": "my-image-id",
"ImageVersion": "1.2.3",
"OutputDirectory": str(Path.cwd() / "abcde"),
assert {k: v for k, v in config.environment.items() if k in expected} == expected
+ assert subimage.environment["Image"] == "subimage"
+
def test_kernel_specifiers(tmp_path: Path) -> None:
kver = "13.0.8-5.10.0-1057-oem" # taken from reporter of #1638