Skip to content

Commit

Permalink
bootloader/config/grub2: Handle ostree case for BLS configs
Browse files Browse the repository at this point in the history
- Do not replace but append to the existing kernel command line as it is
  correct
- Do not fix the path to the kernel & initrd as those are also correct
  • Loading branch information
travier authored and schaefi committed Nov 14, 2024
1 parent bdaee21 commit e14f0e8
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions kiwi/bootloader/config/grub2.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,13 @@ def setup_disk_image_config(
# be deleted...
if self.xml_state.build_type.get_overlayroot_write_partition() is not False:
self._fix_grub_root_device_reference(config_file, boot_options)
self._fix_grub_loader_entries_boot_cmdline()
self._fix_grub_loader_entries_linux_and_initrd_paths()
if not Defaults.is_ostree(self.root_dir):
self._fix_grub_loader_entries_boot_cmdline()
self._fix_grub_loader_entries_linux_and_initrd_paths()
else:
# In the ostree case, the BLS entries are correct, but we still
# need to append the additionnal kernel command line arguments
self.grub_loader_entries_boot_cmdline_append()

if self.firmware.efi_mode() and self.early_boot_script_efi:
self._copy_grub_config_to_efi_path(
Expand Down Expand Up @@ -1491,6 +1496,25 @@ def _fix_grub_loader_entries_boot_cmdline(self):
with open(menu_entry_file, 'w') as grub_menu_entry_file:
grub_menu_entry_file.write(menu_entry)

def grub_loader_entries_boot_cmdline_append(self):
if self.cmdline:
loader_entries_pattern = os.sep.join(
[
self.root_mount.mountpoint,
'boot', 'loader', '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 = re.sub(
r'options (.*)',
r'options \1 {0}'.format(self.cmdline),
menu_entry
)
with open(menu_entry_file, 'w') as grub_menu_entry_file:
grub_menu_entry_file.write(menu_entry)

def _fix_grub_loader_entries_linux_and_initrd_paths(self):
# For the same reasons encoded in _fix_grub_loader_entries_boot_cmdline
# this method exists. In this method the wrong paths to the linux
Expand Down

0 comments on commit e14f0e8

Please sign in to comment.