]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Check if /init and /etc/initrd-release are symlinks
authorMalte Poll <mp@edgeless.systems>
Tue, 19 Sep 2023 13:14:35 +0000 (15:14 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 19 Sep 2023 16:43:32 +0000 (18:43 +0200)
If /init in the image is a symlink to a file that doesn't exist on the host,
.exists() will return False.

Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
mkosi/__init__.py

index 56fd11dfba71728bb8e2a269e8d7842f5fd59652..96acfcabfa0577492d9520c62d04de6dca5195fc 100644 (file)
@@ -1477,13 +1477,13 @@ def configure_ssh(state: MkosiState) -> None:
 
 
 def configure_initrd(state: MkosiState) -> None:
-    if not (state.root / "init").exists() and (state.root / "usr/lib/systemd/systemd").exists():
+    if not (state.root / "init").exists() and not (state.root / "init").is_symlink() and (state.root / "usr/lib/systemd/systemd").exists():
         (state.root / "init").symlink_to("/usr/lib/systemd/systemd")
 
     if not state.config.make_initrd:
         return
 
-    if not (state.root / "etc/initrd-release").exists():
+    if not (state.root / "etc/initrd-release").exists() and not (state.root / "etc/initrd-release").is_symlink():
         (state.root / "etc/initrd-release").symlink_to("/etc/os-release")