teknoraver / rpms / systemd

Forked from rpms/systemd a month ago
Clone

Blame SOURCES/0096-kernel-install-only-generate-systemd.boot_id-in-kern.patch

594167
From 5eb855bddaf8270e7274132ded0e36325d8ffbbe Mon Sep 17 00:00:00 2001
aa0848
From: Lennart Poettering <lennart@poettering.net>
aa0848
Date: Wed, 9 Feb 2022 14:44:48 +0100
aa0848
Subject: [PATCH] kernel-install: only generate systemd.boot_id= in kernel
aa0848
 command line if used for naming the boot loader spec files/dirs
aa0848
aa0848
Now that we can distinguish the naming of the boot loader spec
aa0848
dirs/files and the machine ID let's tweak the logic for suffixing the
aa0848
kernel cmdline with systemd.boot_id=: let's only do that when we
aa0848
actually need the boot ID for naming these dirs/files. If we don't,
aa0848
let's not bother.
aa0848
aa0848
This should be beneficial for "golden" images that shall not carry any
aa0848
machine IDs at all, i.e acquire their identity only once the final
aa0848
userspace is actually reached.
aa0848
aa0848
(cherry picked from commit 953b61004c37948dcd897265b56c1613bc73b9f9)
aa0848
aa0848
Related: #2065061
aa0848
---
aa0848
 src/kernel-install/90-loaderentry.install | 18 +++++++++++++-----
aa0848
 1 file changed, 13 insertions(+), 5 deletions(-)
aa0848
aa0848
diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install
aa0848
index 46261a2c11..c1d69aa824 100644
aa0848
--- a/src/kernel-install/90-loaderentry.install
aa0848
+++ b/src/kernel-install/90-loaderentry.install
aa0848
@@ -70,10 +70,15 @@ else
aa0848
     BOOT_OPTIONS="$(tr -s "$IFS" '\n' 
aa0848
 fi
aa0848
 
aa0848
-# Suffix with the machine ID we use, so that the machine ID remains stable,
aa0848
-# even during factory reset, in the initrd (where the system's machine ID is
aa0848
-# not directly accessible yet), and if the root file system is volatile.
aa0848
-BOOT_OPTIONS="${BOOT_OPTIONS% } systemd.machine_id=$MACHINE_ID"
aa0848
+BOOT_OPTIONS="${BOOT_OPTIONS% }"
aa0848
+
aa0848
+# If the boot entries are named after the machine ID, then suffix the kernel
aa0848
+# command line with the machine ID we use, so that the machine ID remains
aa0848
+# stable, even during factory reset, in the initrd (where the system's machine
aa0848
+# ID is not directly accessible yet), and if the root file system is volatile.
aa0848
+if [ "$ENTRY_TOKEN" = "$MACHINE_ID" ]; then
aa0848
+    BOOT_OPTIONS="$BOOT_OPTIONS systemd.machine_id=$MACHINE_ID"
aa0848
+fi
aa0848
 
aa0848
 if [ -r /etc/kernel/tries ]; then
aa0848
     read -r TRIES 
aa0848
@@ -121,7 +126,10 @@ mkdir -p "${LOADER_ENTRY%/*}" || {
aa0848
 {
aa0848
     echo "title      $PRETTY_NAME"
aa0848
     echo "version    $KERNEL_VERSION"
aa0848
-    echo "machine-id $MACHINE_ID"
aa0848
+    if [ "$ENTRY_TOKEN" = "$MACHINE_ID" ]; then
aa0848
+        # See similar logic above for the systemd.machine_id= kernel command line option
aa0848
+        echo "machine-id $MACHINE_ID"
aa0848
+    fi
aa0848
     echo "options    $BOOT_OPTIONS"
aa0848
     echo "linux      $ENTRY_DIR/linux"
aa0848