]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use the directory mkosi was invoked in as the default for BuildSources= 2262/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 9 Jan 2024 19:22:59 +0000 (20:22 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 9 Jan 2024 20:18:45 +0000 (21:18 +0100)
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

index 188bd76ba54fcdc43c1f57fe31ee03984315dec9..929fa5e3bd1f5868544e64b695997092469d0b12 100644 (file)
@@ -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(