From 77693cd7eb3309e9ab592f886b7bafdaa0622664 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Tue, 17 Jan 2023 11:33:21 -0500 Subject: [PATCH] Generate /etc/kernel/cmdline if it does not exist Don't fall back to reading /proc/cmdline: that will likely reflect the installer environment which will result in a non-booting kernel entry. See-also: rhbz#1940288 Signed-off-by: Robbie Harwood --- 20-zipl-kernel.install | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/20-zipl-kernel.install b/20-zipl-kernel.install index 4fadd1d..a592380 100755 --- a/20-zipl-kernel.install +++ b/20-zipl-kernel.install @@ -76,16 +76,24 @@ case "$COMMAND" in if [[ ! -f /sbin/new-kernel-pkg || -d "${BLS_DIR}" ]]; then declare -a BOOT_OPTIONS + if [[ ! -f /etc/kernel/cmdline ]]; then + last='' + for entry in "${BLS_DIR}"/*.conf; do + last="$entry" + done + if [[ ! -z "$last" ]]; then + args="$(awk '/options/{$1="";$0=$0;$1=$1;print}' $last)" + echo "$args" > /etc/kernel/cmdline + fi + fi if [[ -f /etc/kernel/cmdline ]]; then read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline fi if ! [[ ${BOOT_OPTIONS[*]} ]]; then - read -r -d '' -a line < /proc/cmdline - for i in "${line[@]}"; do - [[ "${i#initrd=*}" != "$i" || "${i#BOOT_IMAGE=*}" != "$i" ]] && continue - BOOT_OPTIONS+=("$i") - done + echo "Could not determine the kernel command line parameters." >&2 + echo "Please specify the kernel command line in /etc/kernel/cmdline!" >&2 + exit 1 fi [[ -d "$BLS_DIR" ]] || mkdir -m 0700 -p "$BLS_DIR"