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 <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2020-05-05 11:40:57 +02:00
parent b1eee22db8
commit f24781c87b
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
2 changed files with 25 additions and 7 deletions

View File

@ -493,10 +493,14 @@ update_bls_fragment() {
fi fi
if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then
local old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})" 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="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
opts=$(echo $opts | sed -e 's/\//\\\//g') opts=$(echo $opts | sed -e 's/\//\\\//g')
sed -i -e "s/^GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX=\\\"${opts}\\\"/" "${grub_etc_default}" 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=//")" old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")"
opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")" 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 --update-kernel=kernel-path updated information for the specified kernel
--zipl configure zipl bootloader --zipl configure zipl bootloader
-b, --bls-directory path to directory containing the BootLoaderSpec fragment files -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 options:
-?, --help Show this help message -?, --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:,\ config-file:,copy-default,default-kernel,default-index,default-title,env:,\
grub2,info:,initrd:,extra-initrd:,make-default,remove-args:,\ grub2,info:,initrd:,extra-initrd:,make-default,remove-args:,\
remove-kernel:,set-default:,set-default-index:,title:,update-kernel:,zipl,\ 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,\ bootloader-probe,debug,devtree,devtreedir:,elilo,efi,extlinux,grub,lilo,\
output-file:,remove-mbargs:,remove-multiboot:,silo,yaboot -n ${SCRIPTNAME} -- "$@")" output-file:,remove-mbargs:,remove-multiboot:,silo,yaboot -n ${SCRIPTNAME} -- "$@")"
@ -715,7 +720,11 @@ while [ ${#} -gt 0 ]; do
blsdir="${2}" blsdir="${2}"
shift 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|\ --bootloader-probe|--debug|--devtree|--devtreedir|--elilo|--efi|\
--extlinux|--grub|--lilo|--output-file|--remove-mbargs|--silo|\ --extlinux|--grub|--lilo|--output-file|--remove-mbargs|--silo|\
--remove-multiboot|--slilo|--yaboot) --remove-multiboot|--slilo|--yaboot)

View File

@ -145,7 +145,10 @@ for the entry.
\fB-\-update-kernel\fR=\fIkernel-path\fR \fB-\-update-kernel\fR=\fIkernel-path\fR
The entries for kernels matching \fRkernel-path\fR are updated. Currently 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 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 .TP
\fB-\-zipl\fR \fB-\-zipl\fR
@ -156,6 +159,12 @@ Configure \fBzipl\fR bootloader.
Use \fIpath\fR as the directory for the BootLoaderSpec config files rather Use \fIpath\fR as the directory for the BootLoaderSpec config files rather
than the default \fB/boot/loader/entries\fR. 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" .SH "SEE ALSO"
.BR zipl (8), .BR zipl (8),
.BR mkinitrd (8), .BR mkinitrd (8),