From a77221432e6666fa1b529af89e4f267c6c525889 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 2 Feb 2019 00:59:16 +0100 Subject: [PATCH] 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 --- grubby-bls | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/grubby-bls b/grubby-bls index 92ea61b..2549880 100755 --- a/grubby-bls +++ b/grubby-bls @@ -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