From 30a374a65b84c2d7dfbb13a4643fb27f31bc71e2 Mon Sep 17 00:00:00 2001 From: codefiles <11915375+codefiles@users.noreply.github.com> Date: Mon, 20 Nov 2023 06:54:04 -0500 Subject: Fix parsing pre-mounted disk configuration from configuration file (#2221) --- archinstall/lib/disk/device_model.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'archinstall/lib/disk/device_model.py') diff --git a/archinstall/lib/disk/device_model.py b/archinstall/lib/disk/device_model.py index 15e68116..54b4932b 100644 --- a/archinstall/lib/disk/device_model.py +++ b/archinstall/lib/disk/device_model.py @@ -42,12 +42,20 @@ class DiskLayoutType(Enum): class DiskLayoutConfiguration: config_type: DiskLayoutType device_modifications: List[DeviceModification] = field(default_factory=list) + # used for pre-mounted config + mountpoint: Optional[Path] = None def json(self) -> Dict[str, Any]: - return { - 'config_type': self.config_type.value, - 'device_modifications': [mod.json() for mod in self.device_modifications] - } + if self.config_type == DiskLayoutType.Pre_mount: + return { + 'config_type': self.config_type.value, + 'mountpoint': str(self.mountpoint) + } + else: + return { + 'config_type': self.config_type.value, + 'device_modifications': [mod.json() for mod in self.device_modifications] + } @classmethod def parse_arg(cls, disk_config: Dict[str, List[Dict[str, Any]]]) -> Optional[DiskLayoutConfiguration]: @@ -64,6 +72,21 @@ class DiskLayoutConfiguration: device_modifications=device_modifications ) + if config_type == DiskLayoutType.Pre_mount.value: + if not (mountpoint := disk_config.get('mountpoint')): + raise ValueError('Must set a mountpoint when layout type is pre-mount') + + path = Path(str(mountpoint)) + + mods = device_handler.detect_pre_mounted_mods(path) + device_modifications.extend(mods) + + storage['MOUNT_POINT'] = path + + config.mountpoint = path + + return config + for entry in disk_config.get('device_modifications', []): device_path = Path(entry.get('device', None)) if entry.get('device', None) else None -- cgit v1.2.3-70-g09d2