From: Antonio Alvarez Feijoo Date: Thu, 3 Apr 2025 05:52:34 +0000 (+0200) Subject: mkosi-initrd: fix vconsole configuration for Ubuntu X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6ea9b1431a53873b89118016d3ce73ead48f6df5;p=thirdparty%2Fmkosi.git mkosi-initrd: fix vconsole configuration for Ubuntu Ubuntu (and Debian?) installs `/etc/vconsole.conf` as a dangling symlink to `/etc/default/keyboard`, and that causes the `mkosi-initrd` build to fail. ``` \u2023 Copying in extra file trees\u2026 cp: not writing through dangling symlink '/work/var/tmp/mkosi-workspace-us4prlhz/root/etc/vconsole.conf' \u2023 "cp --recursive --no-dereference --preserve=mode,links --reflink=auto --copy-contents /work/etc/default/keyboard /work/var/tmp/mkosi-workspace-us4prlhz/root/etc/vconsole.conf" returned non-zero exit code 1. bash-5.2# ls -l /work/var/tmp/mkosi-workspace-us4prlhz/root/etc/vconsole.conf lrwxrwxrwx 1 0 0 16 Apr 2 14:49 /work/var/tmp/mkosi-workspace-us4prlhz/root/etc/vconsole.conf -> default/keyboard bash-5.2# ls -l /work/var/tmp/mkosi-workspace-us4prlhz/root/etc/default/keyboard ls: cannot access '/work/var/tmp/mkosi-workspace-us4prlhz/root/etc/default/keyboard': No such file or directory ``` --- diff --git a/mkosi/initrd.py b/mkosi/initrd.py index b292765ee..2ec371746 100644 --- a/mkosi/initrd.py +++ b/mkosi/initrd.py @@ -191,6 +191,12 @@ def add_raid_config() -> list[str]: return cmdline +def vconsole_config() -> list[str]: + return [ + f"--extra-tree={f}:{f}" for f in ("/etc/default/keyboard", "/etc/vconsole.conf") if Path(f).exists() + ] + + def initrd_finalize(staging_dir: Path, output: str, output_dir: Optional[Path]) -> None: if output_dir: with umask(~0o700) if os.getuid() == 0 else cast(umask, contextlib.nullcontext()): @@ -380,8 +386,7 @@ def main() -> None: if Path("/etc/kernel/cmdline").exists(): cmdline += ["--kernel-command-line", Path("/etc/kernel/cmdline").read_text()] - if Path("/etc/vconsole.conf").exists(): - cmdline += ["--extra-tree=/etc/vconsole.conf:/etc/vconsole.conf"] + cmdline += vconsole_config() # Resolve dnf binary to determine which version the host uses by default # (to avoid preferring dnf5 if the host uses dnf4)