From: Daan De Meyer Date: Mon, 14 Nov 2022 15:18:39 +0000 (+0100) Subject: Look in both the config file and the cwd for dropin files X-Git-Tag: v15~390^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1267%2Fhead;p=thirdparty%2Fmkosi.git Look in both the config file and the cwd for dropin files 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. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 2da48c518..aaf7bc803 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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)