]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Various dnf fixes
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 16 May 2023 09:16:28 +0000 (11:16 +0200)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Tue, 16 May 2023 10:49:58 +0000 (12:49 +0200)
- Put the logs in a subdirectory of the workspace
- Make sure we configure the persistdir to be inside the workspace
as well. Otherwise dnf5 tries to use the system directory which fails
with a permission error
- Use the non-compat dnf5 option names instead of the compat ones

mkosi/distributions/fedora.py

index 909a7b0d2f4338428fe519dacc36fce5815ddfcf..d22888e42e426f6c4d4ab2b58b4cab024532bbe9 100644 (file)
@@ -135,6 +135,8 @@ def invoke_dnf(
         release = state.config.release
 
     state.workspace.joinpath("vars").mkdir(exist_ok=True)
+    state.workspace.joinpath("log").mkdir(exist_ok=True)
+    state.workspace.joinpath("persist").mkdir(exist_ok=True)
 
     dnf = shutil.which("dnf5") or shutil.which("dnf") or "yum"
 
@@ -152,9 +154,10 @@ def invoke_dnf(
         f"--setopt=cachedir={state.cache}",
         f"--setopt=reposdir={' '.join(str(p) for p in state.config.repo_dirs)}",
         f"--setopt=varsdir={state.workspace / 'vars'}",
-        f"--setopt=logdir={state.workspace}",
+        f"--setopt=logdir={state.workspace / 'log'}",
+        f"--setopt=persistdir={state.workspace / 'persist'}",
         "--setopt=check_config_file_age=0",
-        "--noplugins",
+        "--no-plugins" if shutil.which("dnf5") else "--noplugins",
     ]
 
     # Make sure we download filelists so all dependencies can be resolved.
@@ -168,7 +171,8 @@ def invoke_dnf(
         cmdline += ["--nogpgcheck"]
 
     if state.config.repositories:
-        cmdline += [f"--enablerepo={repo}" for repo in state.config.repositories]
+        opt = "--enable-repo" if shutil.which("dnf5") else "--enablerepo"
+        cmdline += [f"{opt}={repo}" for repo in state.config.repositories]
 
     # TODO: this breaks with a local, offline repository created with 'createrepo'
     if state.config.cache_only and not state.config.local_mirror:
@@ -178,7 +182,7 @@ def invoke_dnf(
         cmdline += [f"--forcearch={state.config.architecture}"]
 
     if not state.config.with_docs:
-        cmdline += ["--nodocs"]
+        cmdline += ["--no-docs" if shutil.which("dnf5") else "--nodocs"]
 
     cmdline += sort_packages(packages)