import grubby-8.40-37.el8

This commit is contained in:
CentOS Sources 2019-11-05 15:54:05 -05:00 committed by Andrew Lukoshko
parent 108908dc41
commit 8e51a44b5a
2 changed files with 70 additions and 6 deletions

View File

@ -197,7 +197,7 @@ param_to_indexes() {
}
get_prefix() {
if [[ $bootloader = grub2 ]] && grep -q /boot /proc/mounts; then
if [[ $bootloader = grub2 ]] && mountpoint -q /boot; then
echo "/boot"
else
echo ""
@ -218,8 +218,20 @@ expand_var() {
echo $var
}
has_kernelopts()
{
local args=${bls_options[$1]}
local opts=(${args})
for opt in ${opts[*]}; do
[[ $opt = "\$kernelopts" ]] && return 0
done
return 1
}
get_bls_args() {
local args=${bls_options[$i]}
local args=${bls_options[$1]}
local opts=(${args})
for opt in ${opts[*]}; do
@ -305,14 +317,26 @@ grub_class kernel${flavor}
EOF
}
unset_default_bls()
{
if [[ $bootloader = grub2 ]]; then
grub2-editenv "${env}" unset saved_entry
else
sed -i -e "/^default=.*/d" "${zipl_config}"
fi
}
remove_bls_fragment() {
local indexes=($(param_to_indexes "$1"))
if [[ $indexes = "-1" ]]; then
print_error "The param $1 is incorrect"
print_error "The param $(get_prefix)$1 is incorrect"
fi
for i in "${indexes[@]}"; do
if [[ $default_index = $i ]]; then
unset_default_bls
fi
rm -f "${bls_file[$i]}"
done
@ -456,20 +480,37 @@ update_args() {
}
update_bls_fragment() {
local param="$1"
local indexes=($(param_to_indexes "$1")) && shift
local remove_args=$1 && shift
local add_args=$1 && shift
local initrd=$1 && shift
local opts
if [[ $indexes = "-1" ]]; then
print_error "The param $1 is incorrect"
print_error "The param $(get_prefix)${param} is incorrect"
fi
if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then
local old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")"
opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
grub2-editenv "${env}" set kernelopts="${opts}"
elif [[ $bootloader = grub2 ]]; then
opts="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")"
fi
for i in ${indexes[*]}; do
if [[ -n $remove_args || -n $add_args ]]; then
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}"
if [[ $param != "ALL" || ! "$(has_kernelopts "$i")" ]]; then
set_bls_value "${bls_file[$i]}" "options" "${new_args}"
fi
if [[ $bootloader = grub2 && ! "$(has_kernelopts "$i")" && $opts = $new_args ]]; then
set_bls_value "${bls_file[$i]}" "options" "\$kernelopts"
fi
fi
if [[ -n $initrd ]]; then
@ -693,6 +734,10 @@ while [ ${#} -gt 0 ]; do
shift
done
if [[ -z $update_kernel && -z $kernel ]] && [[ -n $args || -n $remove_args ]]; then
print_error "no action specified"
fi
if [[ -z $blsdir ]]; then
blsdir="/boot/loader/entries"
fi

View File

@ -1,6 +1,6 @@
Name: grubby
Version: 8.40
Release: 34%{?dist}
Release: 37%{?dist}
Summary: Command line tool for updating BootLoaderSpec files
License: GPLv2+
URL: https://github.com/rhinstaller/grubby
@ -85,6 +85,7 @@ Requires: grub2-tools
Requires: s390utils-base
%endif
Requires: findutils
Requires: util-linux
%description
This package provides a grubby compatibility script that manages
@ -165,6 +166,24 @@ current boot environment.
%{_mandir}/man8/*.8*
%changelog
* Mon May 20 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-37
- grubby-bls: unset default entry if is the one being removed
Resolves: rhbz#1668329
- grubby-bls: error if args or remove-args is used without update-kernel
Related: rhbz#1690765
- grubby-bls: make --update-kernel ALL to update kernelopts var in grubenv
Resolves: rhbz#1690765
- grubby-bls: fix --add-kernel not working when using the --args option
Related: rhbz#1690765
* Mon May 06 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-36
- grubby-bls: show absolute path when printing error about incorrect param
Related: rhbz#1706091
* Fri May 03 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-35
- Use mountpoint command to check whether /boot is a mount point
Resolves: rhbz#1706091
* Wed Dec 19 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-34
- grubby-bls: expand all variables in options field when updating it
Resolves: rhbz#1660700