]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
mkosi-initrd: fix vconsole configuration for Ubuntu
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Thu, 3 Apr 2025 05:52:34 +0000 (07:52 +0200)
committerAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Thu, 3 Apr 2025 05:52:34 +0000 (07:52 +0200)
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
```

mkosi/initrd.py

index b292765eefefd45cae72c2dbffde61b85ac4bebb..2ec3717464993cccb2f90f8504edaa347a285ead 100644 (file)
@@ -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)