Skip to content

Commit

Permalink
grub2: make it optional
Browse files Browse the repository at this point in the history
We would like to disable grub2 in scenarios/configurations where we
know we won't ever use/need it.

Signed-off-by: Leandro Dorileo <[email protected]>
  • Loading branch information
Leandro Dorileo authored and bryteise committed Jan 8, 2020
1 parent d651b74 commit 09d65ec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
5 changes: 5 additions & 0 deletions src/bootman/bootman.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -56,7 +59,9 @@ const BootLoader *bootman_known_loaders[] =
#elif defined(HAVE_SYSTEMD_BOOT)
&systemd_bootloader,
#endif
#if defined(GRUB2_BACKEND_ENABLED)
&grub2_bootloader, /**<Always place first to allow extlinux to override */
#endif
/* non-systemd-class */
&syslinux_bootloader,
&extlinux_bootloader};
Expand Down
7 changes: 6 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ link_libnica = declare_dependency(
libcbm_sources = [
'bootloaders/systemd-class.c',
'bootloaders/systemd-boot.c',
'bootloaders/grub2.c',
'bootloaders/extlinux.c',
'bootloaders/syslinux.c',
'bootloaders/mbr.c',
Expand All @@ -53,6 +52,12 @@ libcbm_sources = [
'lib/util.c',
]

if with_grub2_backend == true
libcbm_sources += [
'bootloaders/grub2.c',
]
endif

libcbm_includes = [
include_directories('bootloaders'),
include_directories('bootman'),
Expand Down

0 comments on commit 09d65ec

Please sign in to comment.