Skip to content

Commit

Permalink
Merge pull request #1517 from OSInside/root_dev_fix_for_grub_spec
Browse files Browse the repository at this point in the history
Fixed corrections in BootLoaderSpec grub config
  • Loading branch information
schaefi committed Jul 22, 2020
2 parents 8d384f7 + b9824f7 commit e0a53f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions kiwi/bootloader/config/grub2.py
Expand Up @@ -293,6 +293,19 @@ def setup_disk_image_config(
with open(config_file, 'w') as grub_config_file:
grub_config_file.write(grub_config)

loader_entries_pattern = os.sep.join(
[self.root_mount.mountpoint, 'boot', 'entries', '*.conf']
)
for menu_entry_file in glob.iglob(loader_entries_pattern):
with open(menu_entry_file) as grub_menu_entry_file:
menu_entry = grub_menu_entry_file.read()
menu_entry = menu_entry.replace(
'root={0}'.format(boot_options.get('root_device')),
self.root_reference
)
with open(menu_entry_file, 'w') as grub_menu_entry_file:
grub_menu_entry_file.write(menu_entry)

if self.firmware.efi_mode():
vendor_grubenv_file = \
Defaults.get_vendor_grubenv(self.efi_mount.mountpoint)
Expand Down
5 changes: 4 additions & 1 deletion test/unit/bootloader/config/grub2_test.py
Expand Up @@ -422,11 +422,13 @@ def test_setup_install_image_config_multiboot(self):
@patch('kiwi.bootloader.config.grub2.CommandCapabilities.check_version')
@patch('kiwi.bootloader.config.grub2.Path.which')
@patch('kiwi.defaults.Defaults.get_vendor_grubenv')
@patch('glob.iglob')
def test_setup_disk_image_config(
self, mock_get_vendor_grubenv, mock_Path_which,
self, mock_iglob, mock_get_vendor_grubenv, mock_Path_which,
mock_CommandCapabilities_check_version, mock_Command_run,
mock_copy_grub_config_to_efi_path, mock_mount_system
):
mock_iglob.return_value = ['some_entry.conf']
mock_CommandCapabilities_check_version.return_value = True
mock_get_vendor_grubenv.return_value = 'grubenv'
mock_Path_which.return_value = '/path/to/grub2-mkconfig'
Expand Down Expand Up @@ -461,6 +463,7 @@ def test_setup_disk_image_config(
'efi_mount_point', 'root_mount_point/boot/grub2/grub.cfg'
)
assert file_handle.write.call_args_list == [
call('root=overlay:UUID=ID'),
call('root=overlay:UUID=ID'),
call('root=overlay:UUID=ID')
]
Expand Down

0 comments on commit e0a53f0

Please sign in to comment.