From: Daan De Meyer Date: Tue, 30 Jan 2024 13:19:24 +0000 (+0100) Subject: Debugging improvements X-Git-Tag: v21~77^2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c24431b772ccbfd7352e32f234d5edb95dfbf37;p=thirdparty%2Fmkosi.git Debugging improvements Make sure /var/log from the sandbox is persisted so we can access logs more easily. Also enable dnf debug logging if ARG_DEBUG is set. --- diff --git a/mkosi/context.py b/mkosi/context.py index 4214c421d..43aff6d09 100644 --- a/mkosi/context.py +++ b/mkosi/context.py @@ -35,6 +35,7 @@ class Context: self.staging.mkdir() self.pkgmngr.mkdir() + (self.pkgmngr / "var/log").mkdir(parents=True) self.packages.mkdir() self.install_dir.mkdir(exist_ok=True) self.cache_dir.mkdir(parents=True, exist_ok=True) @@ -84,6 +85,7 @@ class Context: for p in (self.pkgmngr / "etc").iterdir() ), *options, + "--bind", self.pkgmngr / "var/log", "/var/log", *(["--ro-bind", os.fspath(p), os.fspath(p)] if (p := self.pkgmngr / "usr").exists() else []), ], ) + ( diff --git a/mkosi/installer/dnf.py b/mkosi/installer/dnf.py index d195470d0..65c302aa4 100644 --- a/mkosi/installer/dnf.py +++ b/mkosi/installer/dnf.py @@ -6,6 +6,7 @@ from pathlib import Path from mkosi.context import Context from mkosi.installer import finalize_package_manager_mounts from mkosi.installer.rpm import RpmRepository, fixup_rpmdb_location, setup_rpm +from mkosi.log import ARG_DEBUG from mkosi.mounts import finalize_ephemeral_source_mounts from mkosi.run import find_binary, run from mkosi.sandbox import apivfs_cmd @@ -93,6 +94,7 @@ def dnf_cmd(context: Context) -> list[PathString]: f"--releasever={context.config.release}", f"--installroot={context.root}", "--setopt=keepcache=1", + "--setopt=logdir=/var/log", f"--setopt=cachedir=/var/cache/{dnf_subdir(context)}", f"--setopt=persistdir=/var/lib/{dnf_subdir(context)}", f"--setopt=install_weak_deps={int(context.config.with_recommends)}", @@ -101,6 +103,9 @@ def dnf_cmd(context: Context) -> list[PathString]: "--enable-plugin=builddep" if dnf.endswith("dnf5") else "--enableplugin=builddep", ] + if ARG_DEBUG.get(): + cmdline += ["--setopt=debuglevel=10"] + if not context.config.repository_key_check: cmdline += ["--nogpgcheck"] @@ -150,11 +155,12 @@ def invoke_dnf(context: Context, command: str, packages: Iterable[str], apivfs: fixup_rpmdb_location(context) - # 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 (context.root / "var/log").iterdir(): - if any(p.name.startswith(prefix) for prefix in ("dnf", "hawkey", "yum")): - p.unlink() + # dnf interprets the log directory relative to the install root so there's nothing we can do but to remove the log + # files from the install root afterwards. + if (context.root / "var/log").exists(): + for p in (context.root / "var/log").iterdir(): + if any(p.name.startswith(prefix) for prefix in ("dnf", "hawkey", "yum")): + p.unlink() def createrepo_dnf(context: Context) -> None: