Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/examples/guided.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/guided.py')
-rw-r--r--examples/guided.py102
1 files changed, 2 insertions, 100 deletions
diff --git a/examples/guided.py b/examples/guided.py
index 05e04ce0..0f4d846c 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -53,106 +53,8 @@ def ask_user_questions():
allow_empty=True)
]
-
-
- # Perform a quick sanity check on the selected harddrive.
- # 1. Check if it has partitions
- # 3. Check that we support the current partitions
- # 2. If so, ask if we should keep them or wipe everything
- if archinstall.arguments['harddrive'] and archinstall.arguments['harddrive'].has_partitions():
- archinstall.log(f"{archinstall.arguments['harddrive']} contains the following partitions:", fg='yellow')
-
- # We curate a list pf supported partitions
- # and print those that we don't support.
- partition_mountpoints = {}
- for partition in archinstall.arguments['harddrive']:
- try:
- if partition.filesystem_supported():
- archinstall.log(f" {partition}")
- partition_mountpoints[partition] = None
- except archinstall.UnknownFilesystemFormat as err:
- archinstall.log(f" {partition} (Filesystem not supported)", fg='red')
-
-
- # We then ask what to do with the partitions.
- if (option := archinstall.ask_for_disk_layout()) == 'abort':
- archinstall.log(f"Safely aborting the installation. No changes to the disk or system has been made.")
- exit(1)
- elif option == 'keep-existing':
- archinstall.arguments['harddrive'].keep_partitions = True
-
- archinstall.log(f" ** You will now select which partitions to use by selecting mount points (inside the installation). **")
- archinstall.log(f" ** The root would be a simple / and the boot partition /boot (as all paths are relative inside the installation). **")
- mountpoints_set = []
- while True:
- # Select a partition
- # If we provide keys as options, it's better to convert them to list and sort before passing
- mountpoints_list = sorted(list(partition_mountpoints.keys()))
- partition = archinstall.generic_select(mountpoints_list,
- "Select a partition by number that you want to set a mount-point for (leave blank when done): ")
- if not partition:
- if set(mountpoints_set) & {'/', '/boot'} == {'/', '/boot'}:
- break
-
- continue
-
- # Select a mount-point
- mountpoint = input(f"Enter a mount-point for {partition}: ").strip(' ')
- if len(mountpoint):
-
- # Get a valid & supported filesystem for the partition:
- while 1:
- new_filesystem = input(f"Enter a valid filesystem for {partition} (leave blank for {partition.filesystem}): ").strip(' ')
- if len(new_filesystem) <= 0:
- if partition.encrypted and partition.filesystem == 'crypto_LUKS':
- old_password = archinstall.arguments.get('!encryption-password', None)
- if not old_password:
- old_password = input(f'Enter the old encryption password for {partition}: ')
-
- if (autodetected_filesystem := partition.detect_inner_filesystem(old_password)):
- new_filesystem = autodetected_filesystem
- else:
- archinstall.log(f"Could not auto-detect the filesystem inside the encrypted volume.", fg='red')
- archinstall.log(f"A filesystem must be defined for the unlocked encrypted partition.")
- continue
- break
-
- # Since the potentially new filesystem is new
- # we have to check if we support it. We can do this by formatting /dev/null with the partitions filesystem.
- # There's a nice wrapper for this on the partition object itself that supports a path-override during .format()
- try:
- partition.format(new_filesystem, path='/dev/null', log_formatting=False, allow_formatting=True)
- except archinstall.UnknownFilesystemFormat:
- archinstall.log(f"Selected filesystem is not supported yet. If you want archinstall to support '{new_filesystem}', please create a issue-ticket suggesting it on github at https://github.com/archlinux/archinstall/issues.")
- archinstall.log(f"Until then, please enter another supported filesystem.")
- continue
- except archinstall.SysCallError:
- pass # Expected exception since mkfs.<format> can not format /dev/null.
- # But that means our .format() function supported it.
- break
-
- # When we've selected all three criteria,
- # We can safely mark the partition for formatting and where to mount it.
- # TODO: allow_formatting might be redundant since target_mountpoint should only be
- # set if we actually want to format it anyway.
- mountpoints_set.append(mountpoint)
- partition.allow_formatting = True
- partition.target_mountpoint = mountpoint
- # Only overwrite the filesystem definition if we selected one:
- if len(new_filesystem):
- partition.filesystem = new_filesystem
-
- archinstall.log('Using existing partition table reported above.')
- elif option == 'format-all':
- if not archinstall.arguments.get('filesystem', None):
- archinstall.arguments['filesystem'] = archinstall.ask_for_main_filesystem_format()
- archinstall.arguments['harddrive'].keep_partitions = False
- elif archinstall.arguments['harddrive']:
- # If the drive doesn't have any partitions, safely mark the disk with keep_partitions = False
- # and ask the user for a root filesystem.
- if not archinstall.arguments.get('filesystem', None):
- archinstall.arguments['filesystem'] = archinstall.ask_for_main_filesystem_format()
- archinstall.arguments['harddrive'].keep_partitions = False
+ if archinstall.arguments.get('harddrives', None):
+ archinstall.storage['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives'])
# Get disk encryption password (or skip if blank)
if archinstall.arguments['harddrive'] and archinstall.arguments.get('!encryption-password', None) is None: