kernel-install: discard comments in cmdline files

It was quite a surprise to find my comments in a booted kernel cmdline.
This commit is contained in:
rindeal
2024-08-16 02:16:57 +02:00
committed by Yu Watanabe
parent 2701c2f67d
commit 374aa1be7c

View File

@@ -73,12 +73,12 @@ SORT_KEY="$IMAGE_ID"
if [ -n "$KERNEL_INSTALL_CONF_ROOT" ]; then
if [ -f "$KERNEL_INSTALL_CONF_ROOT/cmdline" ]; then
BOOT_OPTIONS="$(tr -s "$IFS" ' ' <"$KERNEL_INSTALL_CONF_ROOT/cmdline")"
BOOT_OPTIONS="$(grep -Gv '^\s*#' "$KERNEL_INSTALL_CONF_ROOT/cmdline" | tr -s "$IFS" ' ')"
fi
elif [ -f /etc/kernel/cmdline ]; then
BOOT_OPTIONS="$(tr -s "$IFS" ' ' </etc/kernel/cmdline)"
BOOT_OPTIONS="$(grep -Gv '^\s*#' /etc/kernel/cmdline | tr -s "$IFS" ' ')"
elif [ -f /usr/lib/kernel/cmdline ]; then
BOOT_OPTIONS="$(tr -s "$IFS" ' ' </usr/lib/kernel/cmdline)"
BOOT_OPTIONS="$(grep -Gv '^\s*#' /usr/lib/kernel/cmdline | tr -s "$IFS" ' ')"
elif ! systemd-detect-virt --container --quiet; then
BOOT_OPTIONS="$(tr -s "$IFS" '\n' </proc/cmdline | grep -ve '^BOOT_IMAGE=' -e '^initrd=' | tr '\n' ' ')"
else