From 9f5c2bb70b0a4551eaa871164a3c9d71c1e65086 Mon Sep 17 00:00:00 2001 From: codefiles <11915375+codefiles@users.noreply.github.com> Date: Fri, 29 Sep 2023 10:09:28 -0400 Subject: Add support for ESP partition flag (#2133) --- archinstall/lib/disk/device_model.py | 18 +++++++++++------- archinstall/lib/disk/partitioning_menu.py | 7 +++++++ 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'archinstall/lib/disk') diff --git a/archinstall/lib/disk/device_model.py b/archinstall/lib/disk/device_model.py index b1f012f7..6992bccb 100644 --- a/archinstall/lib/disk/device_model.py +++ b/archinstall/lib/disk/device_model.py @@ -658,7 +658,8 @@ class PartitionModification: partuuid: Optional[str] = None uuid: Optional[str] = None - _boot_indicator_flags = [PartitionFlag.Boot, PartitionFlag.XBOOTLDR] + _efi_indicator_flags = (PartitionFlag.Boot, PartitionFlag.ESP) + _boot_indicator_flags = (PartitionFlag.Boot, PartitionFlag.XBOOTLDR) def __post_init__(self): # needed to use the object as a dictionary key due to hash func @@ -728,6 +729,13 @@ class PartitionModification: raise ValueError('Mountpoint is not specified') + def is_efi(self) -> bool: + return ( + any(set(self.flags) & set(self._efi_indicator_flags)) + and self.fs_type == FilesystemType.Fat32 + and PartitionFlag.XBOOTLDR not in self.flags + ) + def is_boot(self) -> bool: """ Returns True if any of the boot indicator flags are found in self.flags @@ -828,9 +836,8 @@ class DeviceModification: def get_efi_partition(self) -> Optional[PartitionModification]: """ Similar to get_boot_partition() but excludes XBOOTLDR partitions from it's candidates. - Also works with ESP flag. """ - filtered = filter(lambda x: (x.is_boot() or PartitionFlag.ESP in x.flags) and x.fs_type == FilesystemType.Fat32 and PartitionFlag.XBOOTLDR not in x.flags, self.partitions) + filtered = filter(lambda x: x.is_efi() and x.mountpoint, self.partitions) return next(filtered, None) def get_boot_partition(self) -> Optional[PartitionModification]: @@ -843,10 +850,7 @@ class DeviceModification: filtered = filter(lambda x: x.is_boot() and x != efi_partition and x.mountpoint, self.partitions) if boot_partition := next(filtered, None): return boot_partition - if efi_partition.is_boot(): - return efi_partition - else: - return None + return efi_partition else: filtered = filter(lambda x: x.is_boot() and x.mountpoint, self.partitions) return next(filtered, None) diff --git a/archinstall/lib/disk/partitioning_menu.py b/archinstall/lib/disk/partitioning_menu.py index c5263b82..a9478158 100644 --- a/archinstall/lib/disk/partitioning_menu.py +++ b/archinstall/lib/disk/partitioning_menu.py @@ -6,6 +6,7 @@ from typing import Any, Dict, TYPE_CHECKING, List, Optional, Tuple from .device_model import PartitionModification, FilesystemType, BDevice, Size, Unit, PartitionType, PartitionFlag, \ ModificationStatus, DeviceGeometry, SectorSize +from ..hardware import SysInfo from ..menu import Menu, ListManager, MenuSelection, TextInput from ..output import FormattedOutput, warn from .subvolume_menu import SubvolumeMenu @@ -105,10 +106,14 @@ class PartitioningList(ListManager): entry.mountpoint = self._prompt_mountpoint() if entry.mountpoint == Path('/boot'): entry.set_flag(PartitionFlag.Boot) + if SysInfo.has_uefi(): + entry.set_flag(PartitionFlag.ESP) case 'mark_formatting' if entry: self._prompt_formatting(entry) case 'mark_bootable' if entry: entry.invert_flag(PartitionFlag.Boot) + if SysInfo.has_uefi(): + entry.invert_flag(PartitionFlag.ESP) case 'set_filesystem' if entry: fs_type = self._prompt_partition_fs_type() if fs_type: @@ -310,6 +315,8 @@ class PartitioningList(ListManager): if partition.mountpoint == Path('/boot'): partition.set_flag(PartitionFlag.Boot) + if SysInfo.has_uefi(): + partition.set_flag(PartitionFlag.ESP) return partition -- cgit v1.2.3-54-g00ecf