]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use slightly better dnf5 check
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 16 May 2023 12:17:58 +0000 (14:17 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 16 May 2023 12:50:42 +0000 (14:50 +0200)
Instead of checking whether dnf5 exists all the time, just reuse
the first check results

mkosi/distributions/fedora.py

index d22888e42e426f6c4d4ab2b58b4cab024532bbe9..e4b885caa4f505aec64de4788eafcaeafc1037d1 100644 (file)
@@ -157,7 +157,7 @@ def invoke_dnf(
         f"--setopt=logdir={state.workspace / 'log'}",
         f"--setopt=persistdir={state.workspace / 'persist'}",
         "--setopt=check_config_file_age=0",
-        "--no-plugins" if shutil.which("dnf5") else "--noplugins",
+        "--no-plugins" if dnf.endswith("dnf5") else "--noplugins",
     ]
 
     # Make sure we download filelists so all dependencies can be resolved.
@@ -171,7 +171,7 @@ def invoke_dnf(
         cmdline += ["--nogpgcheck"]
 
     if state.config.repositories:
-        opt = "--enable-repo" if shutil.which("dnf5") else "--enablerepo"
+        opt = "--enable-repo" if dnf.endswith("dnf5") else "--enablerepo"
         cmdline += [f"{opt}={repo}" for repo in state.config.repositories]
 
     # TODO: this breaks with a local, offline repository created with 'createrepo'
@@ -182,7 +182,7 @@ def invoke_dnf(
         cmdline += [f"--forcearch={state.config.architecture}"]
 
     if not state.config.with_docs:
-        cmdline += ["--no-docs" if shutil.which("dnf5") else "--nodocs"]
+        cmdline += ["--no-docs" if dnf.endswith("dnf5") else "--nodocs"]
 
     cmdline += sort_packages(packages)