From 437ac124c6f02bc4f1c7e319a8ad407acffe9d8f Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 9 Aug 2022 20:05:05 +0200 Subject: Converted paths to pathlib.Path and mount points to detect properly (#1412) * Converted a path to pathlib.Path * Using Partition.mountpoints instead of Partition.mountpoint * Update mapperdev.py * Added .mountpoints to MapperDev * Spelling error --- archinstall/lib/disk/helpers.py | 4 ++++ archinstall/lib/disk/mapperdev.py | 6 +++++- archinstall/lib/installer.py | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/archinstall/lib/disk/helpers.py b/archinstall/lib/disk/helpers.py index c8ac564e..60efe724 100644 --- a/archinstall/lib/disk/helpers.py +++ b/archinstall/lib/disk/helpers.py @@ -403,6 +403,10 @@ def get_partitions_in_use(mountpoint :str) -> Dict[str, Any]: log(f'Filtering available mounts {block_devices_mountpoints} to those under {mountpoint}', level=logging.DEBUG) for mountpoint in list(get_all_targets(output['filesystems']).keys()): + # Since all_blockdevices() returns PosixPath objects, we need to convert + # findmnt paths to pathlib.Path() first: + mountpoint = pathlib.Path(mountpoint) + if mountpoint in block_devices_mountpoints: if mountpoint not in mounts: mounts[mountpoint] = block_devices_mountpoints[mountpoint] diff --git a/archinstall/lib/disk/mapperdev.py b/archinstall/lib/disk/mapperdev.py index 49137ae9..71ef2a79 100644 --- a/archinstall/lib/disk/mapperdev.py +++ b/archinstall/lib/disk/mapperdev.py @@ -64,10 +64,14 @@ class MapperDev: return None + @property + def mountpoints(self) -> List[Dict[str, Any]]: + return [obj['target'] for obj in self.mount_information] + @property def mount_information(self) -> List[Dict[str, Any]]: from .helpers import find_mountpoint - return list(find_mountpoint(self.path)) + return [{**obj, 'target' : pathlib.Path(obj.get('target', '/dev/null'))} for obj in find_mountpoint(self.path)] @property def filesystem(self) -> Optional[str]: diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 42f71678..a0bcc2a6 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -1000,9 +1000,9 @@ class Installer: root_partition = None for partition in self.partitions: print(partition, [partition.mountpoint], [self.target]) - if partition.mountpoint == self.target / 'boot': + if self.target / 'boot' in partition.mountpoints: boot_partition = partition - elif partition.mountpoint == self.target: + elif self.target in partition.mountpoints: root_partition = partition if boot_partition is None or root_partition is None: -- cgit v1.2.3-70-g09d2