]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Fix logdir handling for dnf
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 14 Jul 2023 13:00:46 +0000 (15:00 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 14 Jul 2023 14:08:41 +0000 (16:08 +0200)
logdir= is always taken relative to the installroot. Let's leave it
at it's default value and remove any log files from the install root
after running dnf.

mkosi/distributions/fedora.py

index f8509e2640182e2d708985442a9b3987cf4c0c12..3be11ae60426a0fdebe2db48a09ad3f82e2d6a02 100644 (file)
@@ -170,7 +170,6 @@ def invoke_dnf(
 
     state.pkgmngr.joinpath("etc/dnf/vars").mkdir(exist_ok=True, parents=True)
     state.pkgmngr.joinpath("etc/yum.repos.d").mkdir(exist_ok=True, parents=True)
-    state.pkgmngr.joinpath("var/log").mkdir(exist_ok=True, parents=True)
     state.pkgmngr.joinpath("var/lib/dnf").mkdir(exist_ok=True, parents=True)
 
     # dnf5 does not support building for foreign architectures yet (missing --forcearch)
@@ -189,7 +188,6 @@ def invoke_dnf(
         f"--setopt=cachedir={state.cache_dir}",
         f"--setopt=reposdir={state.pkgmngr / 'etc/yum.repos.d'}",
         f"--setopt=varsdir={state.pkgmngr / 'etc/dnf/vars'}",
-        f"--setopt=logdir={state.pkgmngr / 'var/log'}",
         f"--setopt=persistdir={state.pkgmngr / 'var/lib/dnf'}",
         "--setopt=check_config_file_age=0",
         "--no-plugins" if dnf.endswith("dnf5") else "--noplugins",
@@ -232,6 +230,12 @@ def invoke_dnf(
 
     fixup_rpmdb_location(state.root)
 
+    # The log directory is always interpreted relative to the install root so there's nothing we can do but
+    # to remove the log files from the install root afterwards.
+    for p in (state.root / "var/log").iterdir():
+        if p.name.startswith("dnf"):
+            p.unlink()
+
 
 def fixup_rpmdb_location(root: Path) -> None:
     distribution, _ = detect_distribution()