From e2c2a19a666137d060c6dc1036cd9a3c40e8a729 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 14 Nov 2022 16:18:39 +0100 Subject: [PATCH] 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. --- mkosi/__init__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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) -- 2.47.2