Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/disk')
-rw-r--r--archinstall/lib/disk/device_model.py45
1 files changed, 41 insertions, 4 deletions
diff --git a/archinstall/lib/disk/device_model.py b/archinstall/lib/disk/device_model.py
index 97623772..ad3426b6 100644
--- a/archinstall/lib/disk/device_model.py
+++ b/archinstall/lib/disk/device_model.py
@@ -13,6 +13,7 @@ from typing import Optional, List, Dict, TYPE_CHECKING, Any
from typing import Union
import parted # type: ignore
+import _ped # type: ignore
from parted import Disk, Geometry, Partition
from ..exceptions import DiskError, SysCallError
@@ -525,7 +526,21 @@ class PartitionType(Enum):
class PartitionFlag(Enum):
- Boot = 1
+ """
+ Flags are taken from _ped because pyparted uses this to look
+ up their flag definitions: https://github.com/dcantrell/pyparted/blob/c4e0186dad45c8efbe67c52b02c8c4319df8aa9b/src/parted/__init__.py#L200-L202
+ Which is the way libparted checks for its flags: https://git.savannah.gnu.org/gitweb/?p=parted.git;a=blob;f=libparted/labels/gpt.c;hb=4a0e468ed63fff85a1f9b923189f20945b32f4f1#l183
+ """
+ Boot = _ped.PARTITION_BOOT
+ XBOOTLDR = _ped.PARTITION_BLS_BOOT # Note: parted calls this bls_boot
+ ESP = _ped.PARTITION_ESP
+
+
+# class PartitionGUIDs(Enum):
+# """
+# A list of Partition type GUIDs (lsblk -o+PARTTYPE) can be found here: https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
+# """
+# XBOOTLDR = 'bc13c2ff-59e6-4262-a352-b275fd6f7172'
class FilesystemType(Enum):
@@ -605,6 +620,8 @@ class PartitionModification:
partuuid: Optional[str] = None
uuid: Optional[str] = None
+ _boot_indicator_flags = [PartitionFlag.Boot, PartitionFlag.XBOOTLDR]
+
def __post_init__(self):
# needed to use the object as a dictionary key due to hash func
if not hasattr(self, '_obj_id'):
@@ -674,7 +691,10 @@ class PartitionModification:
raise ValueError('Mountpoint is not specified')
def is_boot(self) -> bool:
- return PartitionFlag.Boot in self.flags
+ """
+ Returns True if any of the boot indicator flags are found in self.flags
+ """
+ return any(set(self.flags) & set(self._boot_indicator_flags))
def is_root(self, relative_mountpoint: Optional[Path] = None) -> bool:
if relative_mountpoint is not None and self.mountpoint is not None:
@@ -765,9 +785,24 @@ class DeviceModification:
def add_partition(self, partition: PartitionModification):
self.partitions.append(partition)
+ def get_efi_partition(self) -> Optional[PartitionModification]:
+ """
+ Similar to get_boot_partition() but excludes XBOOTLDR partitions from it's candidates.
+ """
+ fliltered = filter(lambda x: x.is_boot() and x.fs_type == FilesystemType.Fat32 and PartitionFlag.XBOOTLDR not in x.flags, self.partitions)
+ return next(fliltered, None)
+
def get_boot_partition(self) -> Optional[PartitionModification]:
- liltered = filter(lambda x: x.is_boot(), self.partitions)
- return next(liltered, None)
+ """
+ Returns the first partition marked as XBOOTLDR (PARTTYPE id of bc13c2ff-...) or Boot and has a mountpoint.
+ Only returns XBOOTLDR if separate EFI is detected using self.get_efi_partition()
+ """
+ if efi_partition := self.get_efi_partition():
+ fliltered = filter(lambda x: x.is_boot() and x != efi_partition and x.mountpoint, self.partitions)
+ else:
+ fliltered = filter(lambda x: x.is_boot() and x.mountpoint, self.partitions)
+
+ return next(fliltered, None)
def get_root_partition(self, relative_path: Optional[Path]) -> Optional[PartitionModification]:
filtered = filter(lambda x: x.is_root(relative_path), self.partitions)
@@ -886,6 +921,7 @@ class LsblkInfo:
rota: bool = False
tran: Optional[str] = None
partuuid: Optional[str] = None
+ parttype :Optional[str] = None
uuid: Optional[str] = None
fstype: Optional[str] = None
fsver: Optional[str] = None
@@ -909,6 +945,7 @@ class LsblkInfo:
'rota': self.rota,
'tran': self.tran,
'partuuid': self.partuuid,
+ 'parttype' : self.parttype,
'uuid': self.uuid,
'fstype': self.fstype,
'fsver': self.fsver,