From c1550de84a9d44dbef5946a7138e095f0b5ec898 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Tue, 2 Aug 2022 20:09:04 +0000 Subject: [PATCH] Handle updating /etc/kernel/cmdline Resolves: #1969362 Signed-off-by: Robbie Harwood --- grubby-bls | 24 ++++++++++++++++++++++++ grubby.spec | 6 +++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index af0d82d..0571a0b 100755 --- a/grubby-bls +++ b/grubby-bls @@ -502,6 +502,16 @@ update_bls_fragment() { opts="$(echo "$opts" | sed -e 's/\//\\\//g')" sed -i -e "s/^GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX=\\\"${opts}\\\"/" "${grub_etc_default}" fi + + if [[ -f /etc/kernel/cmdline ]]; then + sed -i "s/\(root=[^ ]*\) .*/\1 ${opts}/" /etc/kernel/cmdline + else + # grub2-mkconfig creates this. Do that now. + grub2-mkconfig -o /etc/grub2.cfg + fi + if [[ ! -f /etc/kernel/cmdline ]]; then + echo "No /etc/kernel/cmdline; please report a bug"; + fi fi old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")" @@ -528,6 +538,20 @@ update_bls_fragment() { fi done + if [[ $param = "ALL" && $bootloader = zipl ]] && [[ -n $remove_args || -n $add_args ]]; then + if [[ ! -f /etc/kernel/cmdline ]]; then + # anaconda could pre-populate this file, but until then, most of + # the time we'll just want the most recent one. This is pretty + # close to the current almost-correct behavior of falling back to + # /proc/cmdline anyhow. + echo "$(get_bls_args -1)" > /etc/kernel/cmdline + fi + + read old_args < /etc/kernel/cmdline + local new_args="$(update_args "${old_args}" "${remove_args}" "${add_args}")" + echo "$new_args" > /etc/kernel/cmdline + fi + update_grubcfg } diff --git a/grubby.spec b/grubby.spec index 3a4eea5..d80cc68 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 59%{?dist} +Release: 60%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Thu Aug 11 2022 Robbie Harwood - 8.40-60 +- Handle updating /etc/kernel/cmdline +- Resolves: #1969362 + * Wed Jul 20 2022 Robbie Harwood - 8.40-59 - Appease upgrade tests by keeping deprecated version in lockstep - Resolves: #2105118