(preset: DiskLayoutConfiguration | None = None)
| 394 | |
| 395 | |
| 396 | async def select_disk_config(preset: DiskLayoutConfiguration | None = None) -> DiskLayoutConfiguration | None: |
| 397 | default_layout = DiskLayoutType.Default.display_msg() |
| 398 | manual_mode = DiskLayoutType.Manual.display_msg() |
| 399 | pre_mount_mode = DiskLayoutType.Pre_mount.display_msg() |
| 400 | |
| 401 | items = [ |
| 402 | MenuItem(default_layout, value=default_layout), |
| 403 | MenuItem(manual_mode, value=manual_mode), |
| 404 | MenuItem(pre_mount_mode, value=pre_mount_mode), |
| 405 | ] |
| 406 | group = MenuItemGroup(items, sort_items=False) |
| 407 | |
| 408 | if preset: |
| 409 | group.set_selected_by_value(preset.config_type.display_msg()) |
| 410 | |
| 411 | result = await Selection[str]( |
| 412 | group, |
| 413 | header=tr('Select a disk configuration'), |
| 414 | allow_skip=True, |
| 415 | allow_reset=True, |
| 416 | ).show() |
| 417 | |
| 418 | match result.type_: |
| 419 | case ResultType.Skip: |
| 420 | return preset |
| 421 | case ResultType.Reset: |
| 422 | return None |
| 423 | case ResultType.Selection: |
| 424 | selection = result.get_value() |
| 425 | |
| 426 | if selection == pre_mount_mode: |
| 427 | output = tr('Enter root mount directory') + '\n\n' |
| 428 | output += tr('You will use whatever drive-setup is mounted at the specified directory') + '\n' |
| 429 | output += tr("WARNING: Archinstall won't check the suitability of this setup") |
| 430 | |
| 431 | path = await prompt_dir(output, allow_skip=True) |
| 432 | |
| 433 | if path is None: |
| 434 | return None |
| 435 | |
| 436 | mods = device_handler.detect_pre_mounted_mods(path) |
| 437 | |
| 438 | return DiskLayoutConfiguration( |
| 439 | config_type=DiskLayoutType.Pre_mount, |
| 440 | device_modifications=mods, |
| 441 | mountpoint=path, |
| 442 | ) |
| 443 | |
| 444 | preset_devices = [mod.device for mod in preset.device_modifications] if preset else [] |
| 445 | devices = await select_devices(preset_devices) |
| 446 | |
| 447 | if devices is None: |
| 448 | return preset |
| 449 | |
| 450 | if result.get_value() == default_layout: |
| 451 | modifications = await get_default_partition_layout(devices) |
| 452 | if modifications: |
| 453 | return DiskLayoutConfiguration( |
no test coverage detected