grubby-bls: unset default entry if is the one being removed

If the default entry is removed, this can't be set as the default anymore
for zipl. Otherwise the zipl tool will fail since it won't exist an IPL
section for the one set as the default.

For grub2, if the saved_entry doesn't exist it will fallback to the first
entry. But still the correct thing to do is to unset the default there.

Resolves: rhbz#1668329

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2019-02-02 00:59:16 +01:00
parent f742fa15b3
commit a77221432e
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
1 changed files with 12 additions and 0 deletions

View File

@ -305,6 +305,15 @@ 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"))
@ -313,6 +322,9 @@ remove_bls_fragment() {
fi
for i in "${indexes[@]}"; do
if [[ $default_index = $i ]]; then
unset_default_bls
fi
rm -f "${bls_file[$i]}"
done