diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-03-07 10:09:56 +0100 |
---|---|---|
committer | lupoDharkael <izhe@hotmail.es> | 2024-03-08 13:03:00 +0100 |
commit | 4d4171e45958a50f4317a5add8fdba297e0f3a83 (patch) | |
tree | ed46ee6aa598dd4110c1f348963277bdffeb31b1 /src/utils | |
parent | 7f18485effb300680241bbd84186fdd5c160ec26 (diff) |
utils: move all boot from OS functionality into boot.py
This change is a preparative for reimplementing the BIOS boot
in order to deprecate the legacy script. All the codepaths to
boot systems located at a partition are now called from the
boot_os_at function enabling an easier structure for the incoming
code.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/boot.py | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/utils/boot.py b/src/utils/boot.py index 4de20b9..15dac7d 100644 --- a/src/utils/boot.py +++ b/src/utils/boot.py @@ -18,6 +18,17 @@ from src.utils.uefi import * from src.utils.fs import * +def _boot_bios_legacy(disk, part, mountpoint): + raise NotImplementedError + +def _boot_bios_linux(disk, part, mountpoint): + logging.info(f'Booting Linux system') + _boot_bios_legacy(disk, part, mountpoint) + +def _boot_bios_windows(disk, part, mountpoint): + logging.info(f'Booting Windows system') + _boot_bios_legacy(disk, part, mountpoint) + def _boot_uefi_windows(disk, part, mountpoint): logging.info(f'Booting windows system') bootlabel = f'Part-{disk:02d}-{part:02d}' @@ -69,21 +80,30 @@ def _boot_uefi_linux(disk, part, mountpoint): umount(esp_mountpoint) def boot_os_at(disk, part): - if not is_uefi_supported(disk): - raise NotImplementedError('BIOS booting is not implemented yet') - + logging.info(f'Booting disk={disk} partition={part}') device = get_partition_device(disk, part) mountpoint = device.replace('dev', 'mnt') if not mount_mkdir(device, mountpoint): raise RuntimeError(f'Cannot probe OS family. Unable to mount {device} at {esp_mountpoint}.') - logging.info(f'Booting system at {device}. Probing OS family...') + is_uefi = is_uefi_supported(disk) + if is_uefi: + logging.info('UEFI support detected') + else: + logging.info('UEFI support not detected') + os_family = get_os_family(mountpoint) + logging.info(f'{os_family} detected at {device}.') + try: - if os_family == OSFamily.WINDOWS: + if is_uefi and os_family == OSFamily.WINDOWS: _boot_uefi_windows(disk, part, mountpoint) - elif os_family == OSFamily.LINUX: + elif is_uefi and os_family == OSFamily.LINUX: _boot_uefi_linux(disk, part, mountpoint) + elif not is_uefi and os_family == OSFamily.WINDOWS: + _boot_bios_windows(disk, part, mountpoint) + elif not is_uefi and os_family == OSFamily.LINUX: + _boot_bios_linux(disk, part, mountpoint) else: raise RuntimeError('Unknown OS family') finally: |