]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Make user provided command line take preference over roothash=
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 14 Mar 2025 16:51:57 +0000 (17:51 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 17 Mar 2025 09:39:23 +0000 (10:39 +0100)
If the user provides their own root= or mount.usr= configuration,
let's always have that take preference over the partition roothash=
or usrhash=

This is preparation for adding support for root=dissect in which case
we don't need roothash= or usrhash= on the kernel command line.

mkosi/__init__.py

index 5ee9441a097df9e761b042919e13ca3082157274..0f9cdf06044fa85bb8ac96281fd52a6a3f52d5fe 100644 (file)
@@ -1946,18 +1946,20 @@ def finalize_cmdline(
     else:
         cmdline = []
 
-    if roothash:
-        cmdline += [roothash]
-
     cmdline += context.config.kernel_command_line
 
-    if not roothash:
-        for name in ("root", "mount.usr"):
-            type_prefix = name.removeprefix("mount.")
-            if not (root := next((p.uuid for p in partitions if p.type.startswith(type_prefix)), None)):
-                continue
+    for name in ("root", "mount.usr"):
+        type_prefix = name.removeprefix("mount.")
+        if not (root := next((p.uuid for p in partitions if p.type.startswith(type_prefix)), None)):
+            continue
 
-            cmdline = [f"{name}=PARTUUID={root}" if c == f"{name}=PARTUUID" else c for c in cmdline]
+        cmdline = [f"{name}=PARTUUID={root}" if c == f"{name}=PARTUUID" else c for c in cmdline]
+
+    if roothash and (
+        (roothash.startswith("roothash=") and not any(c.startswith("root=") for c in cmdline))
+        or (roothash.startswith("usrhash=") and not any(c.startswith("mount.usr") for c in cmdline))
+    ):
+        cmdline += [roothash]
 
     return cmdline