17094c
From 689454c727c2730b6aa89ee4c4b7676900e07f78 Mon Sep 17 00:00:00 2001
17094c
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
17094c
Date: Fri, 12 Apr 2019 16:26:59 +0200
17094c
Subject: [PATCH] Do not require non-empty kernel cmdline
17094c
17094c
When booting with Fedora-Server-dvd-x86_64-30-20190411.n.0.iso,
17094c
/proc/cmdline is empty (libvirt, qemu host with bios, not sure if that
17094c
matters), after installation to disk, anaconda would "crash" in kernel-core
17094c
%posttrans, after calling kernel-install, because dracut would fail
17094c
with
17094c
> Could not determine the kernel command line parameters.
17094c
> Please specify the kernel command line in /etc/kernel/cmdline!
17094c
17094c
I guess it's legitimate, even if unusual, to have no cmdline parameters.
17094c
Two changes are done in this patch:
17094c
1. do not fail if the cmdline is empty.
17094c
2. if /usr/lib/kernel/cmdline or /etc/kernel/cmdline are present, but
17094c
   empty, ignore /proc/cmdline. If there's explicit configuration to
17094c
   have empty cmdline, don't ignore it.
17094c
17094c
(cherry picked from commit 38b4f4b21c3c6107d7a562fcb432237464440b91)
17094c
17094c
Resolves: #1746069
17094c
---
17094c
 50-dracut.install        |  4 +---
17094c
 51-dracut-rescue.install | 10 +---------
17094c
 2 files changed, 2 insertions(+), 12 deletions(-)
17094c
17094c
diff --git a/50-dracut.install b/50-dracut.install
17094c
index 139ff82e..b897db84 100755
17094c
--- a/50-dracut.install
17094c
+++ b/50-dracut.install
17094c
@@ -35,9 +35,7 @@ case "$COMMAND" in
17094c
             read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline
17094c
         elif [[ -f /usr/lib/kernel/cmdline ]]; then
17094c
             read -r -d '' -a BOOT_OPTIONS < /usr/lib/kernel/cmdline
17094c
-        fi
17094c
-
17094c
-        if ! [[ ${BOOT_OPTIONS[*]} ]]; then
17094c
+        else
17094c
             read -r -d '' -a BOOT_OPTIONS < /proc/cmdline
17094c
         fi
17094c
 
17094c
diff --git a/51-dracut-rescue.install b/51-dracut-rescue.install
17094c
index 0580062f..5ac34ef3 100755
17094c
--- a/51-dracut-rescue.install
17094c
+++ b/51-dracut-rescue.install
17094c
@@ -47,9 +47,7 @@ if [[ -f /etc/kernel/cmdline ]]; then
17094c
     read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline
17094c
 elif [[ -f /usr/lib/kernel/cmdline ]]; then
17094c
     read -r -d '' -a BOOT_OPTIONS < /usr/lib/kernel/cmdline
17094c
-fi
17094c
-
17094c
-if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
17094c
+else
17094c
     read -r -d '' -a line < /proc/cmdline
17094c
     for i in "${line[@]}"; do
17094c
         [[ "${i#initrd=*}" != "$i" ]] && continue
17094c
@@ -57,12 +55,6 @@ if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
17094c
     done
17094c
 fi
17094c
 
17094c
-if ! [[ ${BOOT_OPTIONS[*]} ]]; then
17094c
-    echo "Could not determine the kernel command line parameters." >&2
17094c
-    echo "Please specify the kernel command line in /etc/kernel/cmdline!" >&2
17094c
-    exit 1
17094c
-fi
17094c
-
17094c
 if [[ -d "${BOOT_DIR_ABS%/*}" ]]; then
17094c
     BOOT_DIR="/${MACHINE_ID}/0-rescue"
17094c
     BOOT_ROOT=${BOOT_DIR_ABS%$BOOT_DIR}
17094c