From 09d65ecc1aeede20a8ad568d218042642f84b960 Mon Sep 17 00:00:00 2001 From: Leandro Dorileo Date: Wed, 8 Jan 2020 14:57:40 -0800 Subject: [PATCH] grub2: make it optional We would like to disable grub2 in scenarios/configurations where we know we won't ever use/need it. Signed-off-by: Leandro Dorileo --- meson.build | 6 ++++++ meson_options.txt | 2 ++ src/bootman/bootman.c | 5 +++++ src/meson.build | 7 ++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 11aa8a6f..7c43d5a4 100644 --- a/meson.build +++ b/meson.build @@ -177,6 +177,11 @@ cdata.set_quoted('KERNEL_CONF_DIRECTORY', with_kernel_conf_dir) cdata.set_quoted('VENDOR_KERNEL_CONF_DIRECTORY', with_kernel_vendor_conf_dir) cdata.set_quoted('UEFI_ENTRY_LABEL', with_uefi_entry_label) +with_grub2_backend = get_option('with-grub2-backend') +if with_grub2_backend == true + cdata.set('GRUB2_BACKEND_ENABLED', with_grub2_backend) +endif + # Helps the test suites test_top_dir = meson.current_source_dir() @@ -230,6 +235,7 @@ report = [ '', ' bootloader: @0@'.format(with_bootloader), ' efi variable support: @0@'.format(require_efi), + ' grub backend: @0@'.format(with_grub2_backend), ] # Output some stuff to validate the build config diff --git a/meson_options.txt b/meson_options.txt index 0c518cde..9b1ecf84 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,6 +1,8 @@ # Bootloader to use option('with-bootloader', type: 'combo', choices: ['systemd-boot', 'shim-systemd-boot'], value: 'shim-systemd-boot') +option('with-grub2-backend', type: 'boolean', value: true, + description: 'Enables grub2 backend support.') # Currently we'll only look for gnu-efi when using shim-systemd-boot option('with-gnu-efi', type: 'string', description: 'Location of the gnu-efi headers') diff --git a/src/bootman/bootman.c b/src/bootman/bootman.c index a8a9d44b..f2c73605 100644 --- a/src/bootman/bootman.c +++ b/src/bootman/bootman.c @@ -33,7 +33,10 @@ /** * Total "usable" bootloaders */ +#if defined(GRUB2_BACKEND_ENABLED) extern const BootLoader grub2_bootloader; +#endif + #if defined(HAVE_SHIM_SYSTEMD_BOOT) extern const BootLoader shim_systemd_bootloader; #endif @@ -56,7 +59,9 @@ const BootLoader *bootman_known_loaders[] = #elif defined(HAVE_SYSTEMD_BOOT) &systemd_bootloader, #endif +#if defined(GRUB2_BACKEND_ENABLED) &grub2_bootloader, /**