From c68126eeb93cac03b3a674ab47604e8381a4e5e2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 9 Feb 2022 14:29:19 +0100 Subject: [PATCH] kernel-install: add a new $ENTRY_TOKEN variable for naming boot entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This cleans up naming of boot loader spec boot entries a bit (i.e. the naming of the .conf snippet files, and the directory in $BOOT where the kernel images and initrds are placed), and isolates it from the actual machine ID concept. Previously there was a sinlge concept for both things, because typically the entries are just named after the machine ID. However one could also use a different identifier, i.e. not a 128bit ID in which cases issues pop up everywhere. For example, the "machine-id" field in the generated snippets would not be a machine ID anymore, and the newly added systemd.machine_id= kernel parameter would possibly get passed invalid data. Hence clean this up: $MACHINE_ID → always a valid 128bit ID. $ENTRY_TOKEN → usually the $MACHINE_ID but can be any other string too. This is used to name the directory to put kernels/initrds in. It's also used for naming the *.conf snippets that implement the Boot Loader Type 1 spec. (cherry picked from commit 3907044ffa568aedf076d0f9807489ec78f87502) Related: #2065061 --- src/kernel-install/90-loaderentry.install | 11 ++++++----- src/kernel-install/kernel-install | 21 +++++++++++++++++---- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install index 046771169c..46261a2c11 100644 --- a/src/kernel-install/90-loaderentry.install +++ b/src/kernel-install/90-loaderentry.install @@ -29,6 +29,7 @@ INITRD_OPTIONS_SHIFT=4 [ "$KERNEL_INSTALL_LAYOUT" = "bls" ] || exit 0 MACHINE_ID="$KERNEL_INSTALL_MACHINE_ID" +ENTRY_TOKEN="$KERNEL_INSTALL_ENTRY_TOKEN" BOOT_ROOT="$KERNEL_INSTALL_BOOT_ROOT" BOOT_MNT="$(stat -c %m "$BOOT_ROOT")" @@ -41,10 +42,10 @@ fi case "$COMMAND" in remove) [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ - echo "Removing $BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION*.conf" + echo "Removing $BOOT_ROOT/loader/entries/$ENTRY_TOKEN-$KERNEL_VERSION*.conf" exec rm -f \ - "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf" \ - "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION+"*".conf" + "$BOOT_ROOT/loader/entries/$ENTRY_TOKEN-$KERNEL_VERSION.conf" \ + "$BOOT_ROOT/loader/entries/$ENTRY_TOKEN-$KERNEL_VERSION+"*".conf" ;; add) ;; @@ -80,9 +81,9 @@ if [ -r /etc/kernel/tries ]; then echo "/etc/kernel/tries does not contain an integer." >&2 exit 1 fi - LOADER_ENTRY="$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION+$TRIES.conf" + LOADER_ENTRY="$BOOT_ROOT/loader/entries/$ENTRY_TOKEN-$KERNEL_VERSION+$TRIES.conf" else - LOADER_ENTRY="$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf" + LOADER_ENTRY="$BOOT_ROOT/loader/entries/$ENTRY_TOKEN-$KERNEL_VERSION.conf" fi if ! [ -d "$ENTRY_DIR_ABS" ]; then diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install index e94aa79bc6..75a31c62d4 100755 --- a/src/kernel-install/kernel-install +++ b/src/kernel-install/kernel-install @@ -97,7 +97,19 @@ fi [ -z "$MACHINE_ID" ] && [ -r /etc/machine-id ] && read -r MACHINE_ID