From 2721baa62e414dcbe1fdd3ab2a7f1cf5f2ac4dc4 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Thu, 19 May 2022 16:25:19 +0100 Subject: [PATCH 06/11] boom.bootloader: simplify bootloader integration checks Since Red Hat distributions (since RHEL8/Fedora 30) now default to using BLS for boot loader configuration the boom grub integration scripts (that are run during grub2-mkconfig execution), and the elaborate checks for various details of the integration are unnecessary and lead to misleading output when boom is used on these distributions: # boom create --title "STRATIS SNAP TEST2" --root-device /dev/stratis/p1/fs1-snap WARNING - Boom configuration file missing from '/boot/../etc/default/boom' WARNING - Boom configuration not found in grub.cfg WARNING - Run 'grub2-mkconfig > /boot/grub2/grub.cfg' to enable Created entry with boot_id 0b0a8d0: title STRATIS SNAP TEST2 machine-id 568bd2491ba243d48fcff8f2a2d7f928 version 5.11.12-300.fc34.x86_64 linux /vmlinuz-5.11.12-300.fc34.x86_64 initrd /initramfs-5.11.12-300.fc34.x86_64.img options root=/dev/stratis/p1/fs1-snap ro stratis.rootfs.pool_uuid=7e12536d-ddd5-4042-9d84-fff9846f4603 grub_users $grub_users grub_arg --unrestricted grub_class kernel The WARNING messages are not only misleading but potentially harmful since running grub2-mkconfig may have additional side-effects depending on the system configuration (and may not enable blscfg if for some reason it is not present in the configuration files in /boot). An additional benefit of this simplification is that it now correctly reports the BLS status for systems using EFI. Related: #2 Signed-off-by: Bryn M. Reeves --- boom/bootloader.py | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/boom/bootloader.py b/boom/bootloader.py index b01b7cd..3802ca8 100644 --- a/boom/bootloader.py +++ b/boom/bootloader.py @@ -224,10 +224,6 @@ def boom_entries_path(): #: Private constants for Grub2 integration checks #: Paths outside /boot are referenced relative to /boot. __grub_cfg = "grub2/grub.cfg" -__etc_grub_d = "../etc/grub.d" -__boom_grub_d = "42_boom" -__etc_default = "../etc/default" -__boom_defaults = "boom" def check_bootloader(): @@ -242,33 +238,6 @@ def check_bootloader(): _log_warn("No Grub2 configuration file found") return False - boom_grub_d = path_join(boot_path, __etc_grub_d, __boom_grub_d) - if not path_exists(boom_grub_d): - _log_warn("Boom grub2 script missing from '%s'" % __etc_grub_d) - return False - - defaults_file = path_join(boot_path, __etc_default, __boom_defaults) - if not path_exists(defaults_file): - _log_warn("Boom configuration file missing from '%s'" % defaults_file) - return False - - def is_yes(val): - return val == "y" or val == "yes" - - submenu_enabled = False - with open(defaults_file, "r") as dfile: - for line in dfile: - (name, value) = parse_name_value(line) - if name == "BOOM_ENABLE_GRUB" and not is_yes(value): - _log_warn("Boom grub2 integration is disabled in '%s'" % - defaults_file) - if name == "BOOM_USE_SUBMENU" and is_yes(value): - _log_info("Boom grub2 submenu support enabled") - submenu_enabled = True - if name == "BOOM_SUBMENU_NAME" and submenu_enabled: - _log_info("Boom grub2 submenu name is '%s'" % value) - - found_boom_grub = False found_bls = False blscfg = "blscfg" with open(grub_cfg) as gfile: @@ -276,11 +245,8 @@ def check_bootloader(): if blscfg in line: _log_info("Found BLS import statement in '%s'" % grub_cfg) found_bls = True - if "BEGIN" in line and __boom_grub_d in line: - _log_info("Found Boom Grub2 integration in '%s'" % grub_cfg) - found_boom_grub = True - return found_boom_grub or found_bls + return found_bls class BoomRootDeviceError(BoomError): -- 2.45.2