From f24781c87b8226be5ec522f02a1833bda9504fe1 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 5 May 2020 11:40:57 +0200 Subject: [PATCH] grubby-bls: add a --no-etc-grub-update option The option makes grubby to not update the GRUB_CMDLINE_LINUX variable in the /etc/default/grub file when the --update-kernel=ALL option is used. Signed-off-by: Javier Martinez Canillas --- grubby-bls | 21 +++++++++++++++------ grubby.8 | 11 ++++++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/grubby-bls b/grubby-bls index 68cea40..0306490 100755 --- a/grubby-bls +++ b/grubby-bls @@ -493,10 +493,14 @@ update_bls_fragment() { fi if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then - local old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})" - opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")" - opts=$(echo $opts | sed -e 's/\//\\\//g') - sed -i -e "s/^GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX=\\\"${opts}\\\"/" "${grub_etc_default}" + local old_args="" + + if [[ -z $no_etc_update ]]; then + old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})" + opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")" + opts=$(echo $opts | sed -e 's/\//\\\//g') + sed -i -e "s/^GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX=\\\"${opts}\\\"/" "${grub_etc_default}" + fi old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")" opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")" @@ -609,6 +613,7 @@ Usage: grubby [OPTION...] --update-kernel=kernel-path updated information for the specified kernel --zipl configure zipl bootloader -b, --bls-directory path to directory containing the BootLoaderSpec fragment files + --no-etc-grub-update don't update the GRUB_CMDLINE_LINUX variable in /etc/default/grub Help options: -?, --help Show this help message @@ -620,7 +625,7 @@ OPTS="$(getopt -o c:i:b:? --long help,add-kernel:,args:,bad-image-okay,\ config-file:,copy-default,default-kernel,default-index,default-title,env:,\ grub2,info:,initrd:,extra-initrd:,make-default,remove-args:,\ remove-kernel:,set-default:,set-default-index:,title:,update-kernel:,zipl,\ -bls-directory:,add-kernel:,add-multiboot:,mbargs:,mounts:,boot-filesystem:,\ +bls-directory:,no-etc-grub-update,add-multiboot:,mbargs:,mounts:,boot-filesystem:,\ bootloader-probe,debug,devtree,devtreedir:,elilo,efi,extlinux,grub,lilo,\ output-file:,remove-mbargs:,remove-multiboot:,silo,yaboot -n ${SCRIPTNAME} -- "$@")" @@ -715,7 +720,11 @@ while [ ${#} -gt 0 ]; do blsdir="${2}" shift ;; - --add-kernel|--add-multiboot|--mbargs|--mounts|--boot-filesystem|\ + --no-etc-grub-update) + no_etc_update=true + shift + ;; + --add-multiboot|--mbargs|--mounts|--boot-filesystem|\ --bootloader-probe|--debug|--devtree|--devtreedir|--elilo|--efi|\ --extlinux|--grub|--lilo|--output-file|--remove-mbargs|--silo|\ --remove-multiboot|--slilo|--yaboot) diff --git a/grubby.8 b/grubby.8 index 143decd..9bcd247 100644 --- a/grubby.8 +++ b/grubby.8 @@ -145,7 +145,10 @@ for the entry. \fB-\-update-kernel\fR=\fIkernel-path\fR The entries for kernels matching \fRkernel-path\fR are updated. Currently the only items that can be updated is the kernel argument list, which is -modified via the \fB-\-args\fR and \fB-\-remove-args\fR options. +modified via the \fB-\-args\fR and \fB-\-remove-args\fR options. If the +\fBALL\fR argument is used the variable \fB GRUB_CMDLINE_LINUX\fR in +\fB/etc/default/grub\fR is updated with the latest kernel argument list, +unless the \fB-\-no-etc-grub-update\fR option is used. .TP \fB-\-zipl\fR @@ -156,6 +159,12 @@ Configure \fBzipl\fR bootloader. Use \fIpath\fR as the directory for the BootLoaderSpec config files rather than the default \fB/boot/loader/entries\fR. +.TP +\fB-\-no-etc-grub-update\fR +Makes grubby to not update the \fBGRUB_CMDLINE_LINUX\fR variable in +\fB/etc/default/grub\fR when the \fB-\-update-kernel\fR option is +used with the \fBALL\fR argument. + .SH "SEE ALSO" .BR zipl (8), .BR mkinitrd (8),