Add 'bls' parameter for the bootloader

This commit is contained in:
Alberto Planas 2024-04-25 19:28:29 +02:00
parent f7aa0e5982
commit 8a8190098c
No known key found for this signature in database
GPG Key ID: 2912C9D41F97CD3F
4 changed files with 64 additions and 5 deletions

View File

@ -133,6 +133,7 @@ class BootLoaderConfigGrub2(BootLoaderConfigBase):
self.timeout_style = \
self.xml_state.get_build_type_bootloader_timeout_style()
self.displayname = self.xml_state.xml_data.get_displayname()
self.bls = self.xml_state.get_build_type_bootloader_bls()
self.serial_line_setup = \
self.xml_state.get_build_type_bootloader_serial_line_setup()
self.continue_on_timeout = self.get_continue_on_timeout()
@ -794,7 +795,7 @@ class BootLoaderConfigGrub2(BootLoaderConfigBase):
self._get_grub2_mkconfig_tool()
], raise_on_error=False
)
if enable_blscfg_implemented.returncode == 0:
if self.bls and enable_blscfg_implemented.returncode == 0:
grub_default_entries['GRUB_ENABLE_BLSCFG'] = 'true'
if grub_default_entries:

View File

@ -998,6 +998,19 @@ class XMLState:
return bootloader.get_name() if bootloader else \
Defaults.get_default_bootloader()
def get_build_type_bootloader_bls(self) -> bool:
"""
Return bootloader bls setting for selected build type
:return: True or False
:rtype: bool
"""
bootloader = self.get_build_type_bootloader_section()
if bootloader:
return bootloader.get_bls()
return False
def get_build_type_bootloader_console(self) -> List[str]:
"""
Return bootloader console setting for selected build type

View File

@ -600,7 +600,6 @@ class TestBootLoaderConfigGrub2:
'GRUB_BACKGROUND': '/boot/grub2/themes/openSUSE/background.png',
'GRUB_CMDLINE_LINUX_DEFAULT': '"some-cmdline"',
'GRUB_DISTRIBUTOR': '"Bob"',
'GRUB_ENABLE_BLSCFG': 'true',
'GRUB_ENABLE_CRYPTODISK': 'y',
'GRUB_GFXMODE': '800x600',
'GRUB_SERIAL_COMMAND': '"serial --speed=38400"',
@ -643,7 +642,6 @@ class TestBootLoaderConfigGrub2:
call('GRUB_CMDLINE_LINUX', '"root=LABEL=some-label"'),
call('GRUB_DISABLE_LINUX_UUID', 'true'),
call('GRUB_DISTRIBUTOR', '"Bob"'),
call('GRUB_ENABLE_BLSCFG', 'true'),
call('GRUB_ENABLE_CRYPTODISK', 'y'),
call('GRUB_ENABLE_LINUX_LABEL', 'true'),
call('GRUB_GFXMODE', '800x600'),
@ -688,7 +686,6 @@ class TestBootLoaderConfigGrub2:
call('GRUB_DISABLE_LINUX_PARTUUID', 'false'),
call('GRUB_DISABLE_LINUX_UUID', 'true'),
call('GRUB_DISTRIBUTOR', '"Bob"'),
call('GRUB_ENABLE_BLSCFG', 'true'),
call('GRUB_ENABLE_CRYPTODISK', 'y'),
call('GRUB_GFXMODE', '800x600'),
call(
@ -732,7 +729,6 @@ class TestBootLoaderConfigGrub2:
call('GRUB_CMDLINE_LINUX_DEFAULT', '"abcd console=tty0"'),
call('GRUB_DISABLE_LINUX_UUID', 'true'),
call('GRUB_DISTRIBUTOR', '"Bob"'),
call('GRUB_ENABLE_BLSCFG', 'true'),
call('GRUB_ENABLE_CRYPTODISK', 'y'),
call('GRUB_ENABLE_LINUX_LABEL', 'true'),
call('GRUB_GFXMODE', '800x600'),
@ -748,6 +744,49 @@ class TestBootLoaderConfigGrub2:
call('SUSE_REMOVE_LINUX_ROOT_PARAM', 'true'),
]
@patch('os.path.exists')
@patch('kiwi.bootloader.config.grub2.SysConfig')
@patch('kiwi.bootloader.config.grub2.Command.run')
def test_setup_default_grub_use_of_bls(
self, mock_Command_run, mock_sysconfig, mock_exists
):
grep_grub_option = Mock()
grep_grub_option.returncode = 0
mock_Command_run.return_value = grep_grub_option
mock_exists.return_value = False
grub_default = SysConfig('some-file')
grub_default.write = Mock()
mock_sysconfig.return_value = grub_default
mock_exists.return_value = True
self.bootloader.terminal_input = 'serial'
self.bootloader.terminal_output = 'gfxterm'
self.bootloader.theme = 'openSUSE'
self.bootloader.displayname = 'Bob'
self.bootloader.bls = True
self.firmware.efi_mode.return_value = 'efi'
self.bootloader._setup_default_grub()
mock_sysconfig.assert_called_once_with('root_dir/etc/default/grub')
grub_default.write.assert_called_once_with()
assert grub_default.data_dict == {
'GRUB_BACKGROUND': '/boot/grub2/themes/openSUSE/background.png',
'GRUB_CMDLINE_LINUX_DEFAULT': '"some-cmdline"',
'GRUB_DISTRIBUTOR': '"Bob"',
'GRUB_ENABLE_BLSCFG': 'true',
'GRUB_ENABLE_CRYPTODISK': 'y',
'GRUB_GFXMODE': '800x600',
'GRUB_SERIAL_COMMAND': '"serial --speed=38400"',
'GRUB_TERMINAL_INPUT': '"serial"',
'GRUB_TERMINAL_OUTPUT': '"gfxterm"',
'GRUB_THEME': '/boot/grub2/themes/openSUSE/theme.txt',
'GRUB_TIMEOUT': 10,
'GRUB_TIMEOUT_STYLE': 'countdown',
'SUSE_BTRFS_SNAPSHOT_BOOTING': 'true',
'GRUB_DEFAULT': 'saved'
}
@patch('os.path.exists')
@patch('kiwi.bootloader.config.grub2.SysConfig')
def test_setup_sysconfig_bootloader(self, mock_sysconfig, mock_exists):

View File

@ -58,6 +58,7 @@ class TestXMLState:
self.bootloader.get_timeout.return_value = 'some-timeout'
self.bootloader.get_timeout_style.return_value = 'some-style'
self.bootloader.get_targettype.return_value = 'some-target'
self.bootloader.get_bls.return_value = False
self.bootloader.get_console.return_value = 'some-console'
self.bootloader.get_serial_line.return_value = 'some-serial'
self.bootloader.get_use_disk_password.return_value = True
@ -1037,6 +1038,11 @@ class TestXMLState:
mock_bootloader.return_value = [self.bootloader]
assert self.state.get_build_type_bootloader_use_disk_password() is True
@patch('kiwi.xml_parse.type_.get_bootloader')
def test_get_build_type_bootloader_bls(self, mock_bootloader):
mock_bootloader.return_value = [self.bootloader]
assert self.state.get_build_type_bootloader_bls() is False
@patch('kiwi.xml_parse.type_.get_bootloader')
def test_get_build_type_bootloader_console(self, mock_bootloader):
mock_bootloader.return_value = [self.bootloader]