diff --git a/kiwi/bootloader/config/grub2.py b/kiwi/bootloader/config/grub2.py index 673442d7e6f..131d4126bd7 100644 --- a/kiwi/bootloader/config/grub2.py +++ b/kiwi/bootloader/config/grub2.py @@ -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( @@ -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