From: Daan De Meyer Date: Thu, 11 Jul 2024 06:19:21 +0000 (+0200) Subject: Fix --profile X-Git-Tag: v24~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0460e6ffafd679c1d73cb6143b9e445b3f9315c5;p=thirdparty%2Fmkosi.git Fix --profile The attribute might be set on either the cli or the config namespace so don't assume it's set on the config namespace. Fixes #2860 --- diff --git a/mkosi/config.py b/mkosi/config.py index e556428df..fea162500 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -3666,8 +3666,7 @@ def parse_config(argv: Sequence[str] = (), *, resources: Path = Path("/")) -> tu setattr(ParseContext.config, s.dest, s.parse(v, getattr(ParseContext.config, s.dest, None))) if profiles: - finalize_value(SETTINGS_LOOKUP_BY_DEST["profile"]) - profile = getattr(ParseContext.config, "profile") + profile = finalize_value(SETTINGS_LOOKUP_BY_DEST["profile"]) ParseContext.immutable.add("Profile") if profile: diff --git a/tests/test_config.py b/tests/test_config.py index b82d2ab90..6a5b6d591 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -356,6 +356,16 @@ def test_profiles(tmp_path: Path) -> None: assert config.distribution == Distribution.debian assert config.qemu_kvm == ConfigFeature.enabled + (d / "mkosi.conf").unlink() + + with chdir(d): + _, [config] = parse_config(["--profile", "profile"]) + + assert config.profile == "profile" + # mkosi.conf.d/ should override the profile + assert config.distribution == Distribution.debian + assert config.qemu_kvm == ConfigFeature.enabled + def test_override_default(tmp_path: Path) -> None: d = tmp_path