From bda17a2acad62c298c37558e932fd80f0fd4c44c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 9 Jan 2024 20:22:59 +0100 Subject: [PATCH] Use the directory mkosi was invoked in as the default for BuildSources= While parsing config, we use chdir(). Also, when a BuildSources= match is found, BuildSources= is initialized to its default value which is Path.cwd(). However, we want the default value to be the top level directory that mkosi was invoked in, not the current working directory that we happen to be in while parsing configuration. Let's fix this by using the directory mkosi was invoked in instead of Path.cwd(). --- mkosi/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkosi/config.py b/mkosi/config.py index 188bd76ba..929fa5e3b 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -945,6 +945,7 @@ def parse_chdir(path: str) -> Optional[Path]: die(f"{path} is not a directory!") except OSError as e: die(f"Cannot change the directory to {path}: {e}") + # Keep track of the current directory return Path.cwd() @@ -1866,7 +1867,7 @@ SETTINGS = ( section="Content", parse=config_make_list_parser(delimiter=",", parse=make_tree_parser(absolute=False)), match=config_match_build_sources, - default_factory=lambda _: [ConfigTree(Path.cwd(), None)], + default_factory=lambda ns: [ConfigTree(ns.directory, None)] if ns.directory else [], help="Path for sources to build", ), ConfigSetting( -- 2.47.2