]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Look in both the config file and the cwd for dropin files 1267/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 14 Nov 2022 15:18:39 +0000 (16:18 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 14 Nov 2022 15:45:33 +0000 (16:45 +0100)
A project might have multiple config files in subdirectories that
they use with --default but have shared configuration in the root
of the repository. When loading such a config file with --default,
we should still load shared dropins from the shared location.

mkosi/__init__.py

index 2da48c518c3d31ab7c71063668c307cd78c4ce28..aaf7bc80315ffa5731dfddb2d29be5a090041ce0 100644 (file)
@@ -6030,19 +6030,19 @@ def parse_args_file_group(
 
     d = config_path.parent
 
-    for dropin_dir in (d / "mkosi.conf.d", d / "mkosi.default.d"):
+    dirs = [Path("mkosi.conf.d"), Path("mkosi.default.d")]
+    if not d.samefile(Path.cwd()):
+        dirs += [Path(d / "mkosi.conf.d"), Path(d / "mkosi.default.d")]
+
+    if distribution is not None:
+        dirs += [d / str(distribution) for d in dirs]
+
+    for dropin_dir in dirs:
         if dropin_dir.is_dir():
             for entry in sorted(dropin_dir.iterdir()):
                 if entry.is_file():
                     config_files += [f"{ArgumentParserMkosi.fromfile_prefix_chars}{entry}"]
 
-    if distribution is not None:
-        for distribution_dir in (d / "mkosi.conf.d" / str(distribution), d / "mkosi.default.d" / str(distribution)):
-            if distribution_dir.is_dir():
-                for entry in sorted(distribution_dir.iterdir()):
-                    if entry.is_file():
-                        config_files += [f"{ArgumentParserMkosi.fromfile_prefix_chars}{entry}"]
-
     # Parse all parameters handled by mkosi.
     # Parameters forwarded to subprocesses such as nspawn or qemu end up in cmdline_argv.
     return create_parser().parse_args(config_files + argv)