grubby-bls: make a copy of the cmdline if is modified for an entry

The BLS entries use a global kernel command line parameters that's set as
kernelopts variable in the grubenv file. But users may want to have custom
parameters for some entries, so make a copy of the current kernelopts and
set the "options" field value to the modified parameters.

Resolves: rhbz#1629054

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2018-10-16 20:06:33 +02:00
parent a5e56a6e7d
commit 84881fb396
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69

View File

@ -367,6 +367,17 @@ update_args() {
echo ${args}
}
get_bls_args() {
if [[ $bootloader = "grub2" && "${bls_options[$i]}" = "\$kernelopts" ]]; then
old_args=$(grub2-editenv list | grep kernelopts)
old_args="${old_args##kernelopts=}"
else
old_args="${bls_options[$i]}"
fi
echo ${old_args}
}
update_bls_fragment() {
local indexes=($(param_to_indexes "$1")) && shift
local remove_args=$1 && shift
@ -379,7 +390,8 @@ update_bls_fragment() {
for i in ${indexes[*]}; do
if [[ -n $remove_args || -n $add_args ]]; then
local new_args="$(update_args "${bls_options[$i]}" "${remove_args}" "${add_args}")"
local old_args="$(get_bls_args "$i")"
local new_args="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
set_bls_value "${bls_file[$i]}" "options" "${new_args}"
fi