Move keep_initramfs logic into add_bootloader()

The grub-btrfs snapshot detection was in guided.py, forcing custom
script authors to replicate it. Since Installer already holds
disk_config, the check belongs inside add_bootloader().
This commit is contained in:
Softer 2026-05-05 03:00:27 +03:00
parent 0e3a8f2dc5
commit 07d0760dc4
2 changed files with 6 additions and 12 deletions

View File

@ -1806,7 +1806,6 @@ class Installer:
bootloader: Bootloader,
uki_enabled: bool = False,
bootloader_removable: bool = False,
keep_initramfs: bool = False,
) -> None:
"""
Adds a bootloader to the installation instance.
@ -1856,6 +1855,12 @@ class Installer:
bootloader_removable = False
if uki_enabled:
keep_initramfs = (
bootloader == Bootloader.Grub
and self._disk_config.has_default_btrfs_vols()
and self._disk_config.btrfs_options is not None
and self._disk_config.btrfs_options.snapshot_config is not None
)
self._config_uki(root, efi_partition, keep_initramfs)
match bootloader:

View File

@ -115,21 +115,10 @@ def perform_installation(
installation.setup_swap(algo=config.swap.algorithm)
if config.bootloader_config and config.bootloader_config.bootloader != Bootloader.NO_BOOTLOADER:
keep_initramfs = False
if (
config.bootloader_config.uki
and config.bootloader_config.bootloader == Bootloader.Grub
and disk_config.has_default_btrfs_vols()
and disk_config.btrfs_options
and disk_config.btrfs_options.snapshot_config
):
keep_initramfs = True
installation.add_bootloader(
config.bootloader_config.bootloader,
config.bootloader_config.uki,
config.bootloader_config.removable,
keep_initramfs,
)
if config.network_config: