for name in finalized.get("environment", {}).keys() & finalized.get("pass_environment", [])
}
+ if (p := Path("mkosi.tools.conf").absolute()).exists():
+ with chdir(p if p.is_dir() else Path.cwd()):
+ context.parse_config_one(p, parse_profiles=p.is_dir(), parse_local=p.is_dir())
+
with chdir(resources / "mkosi-tools"):
context.parse_config_one(resources / "mkosi-tools", parse_profiles=True)
any of the extra search paths.
If set to `default`, **mkosi** will automatically add an extra tools tree
- image and use it as the tools tree.
+ image and use it as the tools tree. This image can be further configured
+ using the settings below or with `mkosi.tools.conf` which can either be a
+ file or directory containing extra configuration for the default tools tree.
The following table shows for which distributions default tools tree
packages are defined and which packages are included in those default
import pytest
+import mkosi.resources
from mkosi import expand_kernel_specifiers
from mkosi.config import (
Architecture,
parse_ini,
)
from mkosi.distributions import Distribution, detect_distribution
-from mkosi.util import chdir
+from mkosi.util import chdir, resource_path
def test_compression_enum_creation() -> None:
_, _, [config] = parse_config(["--package", "foo", "--package", ""])
assert config.packages == []
+
+
+def test_tools(tmp_path: Path) -> None:
+ d = tmp_path
+ argv = ["--tools-tree=default"]
+
+ with resource_path(mkosi.resources) as resources, chdir(d):
+ _, tools, _ = parse_config(argv, resources=resources)
+ assert tools
+ host = detect_distribution()[0]
+ assert host
+ assert tools.distribution == host.default_tools_tree_distribution()
+
+ (d / "mkosi.tools.conf").write_text(
+ f"""
+ [Distribution]
+ Distribution=debian
+
+ [Content]
+ PackageDirectories={d}
+ """
+ )
+
+ _, tools, _ = parse_config(argv, resources=resources)
+ assert tools
+ assert tools.distribution == Distribution.debian
+ assert tools.package_directories == [Path(d)]
+
+ _, tools, _ = parse_config(
+ argv + ["--tools-tree-distribution=arch", "--tools-tree-package-directory=/tmp"],
+ resources=resources,
+ )
+ assert tools
+ assert tools.distribution == Distribution.arch
+ assert tools.package_directories == [Path(d), Path("/tmp")]
+
+ _, tools, _ = parse_config(argv + ["--tools-tree-package-directory="], resources=resources)
+ assert tools
+ assert tools.package_directories == []
+
+ (d / "mkosi.conf").write_text(
+ """
+ [Build]
+ ToolsTreeDistribution=arch
+ """
+ )
+
+ _, tools, _ = parse_config(argv, resources=resources)
+ assert tools
+ assert tools.distribution == Distribution.debian