index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | examples/guided.py | 32 |
diff --git a/examples/guided.py b/examples/guided.py index 4e6d1bc5..8353b76b 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -1,6 +1,7 @@ import json import logging import os +import pathlib import time import archinstall @@ -28,7 +29,9 @@ archinstall.log(f"Disk states before installing: {archinstall.disk_layouts()}", def load_config(): if archinstall.arguments.get('harddrives', None) is not None: - archinstall.arguments['harddrives'] = [archinstall.BlockDevice(BlockDev) for BlockDev in archinstall.arguments['harddrives'].split(',')] + if type(archinstall.arguments['harddrives']) is str: + archinstall.arguments['harddrives'] = archinstall.arguments['harddrives'].split(',') + archinstall.arguments['harddrives'] = [archinstall.BlockDevice(BlockDev) for BlockDev in archinstall.arguments['harddrives']] # Temporarily disabling keep_partitions if config file is loaded # Temporary workaround to make Desktop Environments work if archinstall.arguments.get('profile', None) is not None: @@ -51,7 +54,19 @@ def load_config(): archinstall.storage['gfx_driver_packages'] = AVAILABLE_GFX_DRIVERS.get(archinstall.arguments.get('gfx_driver', None), None) if archinstall.arguments.get('servers', None) is not None: archinstall.storage['_selected_servers'] = archinstall.arguments.get('servers', None) - + if archinstall.arguments.get('disk_layouts', None) is not None: + if (dl_path := pathlib.Path(archinstall.arguments['disk_layouts'])).exists() and str(dl_path).endswith('.json'): + try: + with open(dl_path) as fh: + archinstall.storage['disk_layouts'] = json.load(fh) + except Exception as e: + raise ValueError(f"--disk_layouts does not contain a valid JSON format: {e}") + else: + try: + archinstall.storage['disk_layouts'] = json.loads(archinstall.arguments['disk_layouts']) + except: + raise ValueError("--disk_layouts=<json> needs either a JSON file or a JSON string given with a valid disk layout.") + def ask_user_questions(): """ First, we'll ask the user for a bunch of user input. @@ -94,14 +109,12 @@ def ask_user_questions(): # Ask which harddrives/block-devices we will install to # and convert them into archinstall.BlockDevice() objects. - if archinstall.arguments.get('harddrives', None): - archinstall.arguments['harddrives'] = [archinstall.BlockDevice(BlockDev) for BlockDev in archinstall.arguments['harddrives'].split(',')] - else: + if archinstall.arguments.get('harddrives', None) is None: archinstall.arguments['harddrives'] = archinstall.generic_multi_select(archinstall.all_disks(), text="Select one or more harddrives to use and configure (leave blank to skip this step): ", allow_empty=True) - if archinstall.arguments.get('harddrives', None): + if archinstall.arguments.get('harddrives', None) is not None and archinstall.storage.get('disk_layouts', None) is None: archinstall.storage['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives']) # Get disk encryption password (or skip if blank) @@ -238,8 +251,7 @@ def perform_filesystem_operations(): for drive in archinstall.arguments['harddrives']: with archinstall.Filesystem(drive, mode) as fs: - fs.load_layout(archinstall.storage['disk_layouts'][drive]) - + fs.load_layout(archinstall.storage['disk_layouts'][drive.path]) def perform_installation(mountpoint): """ @@ -269,7 +281,7 @@ def perform_installation(mountpoint): installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium if archinstall.arguments["bootloader"] == "grub-install" and has_uefi(): installation.add_additional_packages("grub") - installation.add_bootloader(archinstall.arguments["harddrive"], archinstall.arguments["bootloader"]) + installation.add_bootloader(archinstall.arguments["bootloader"]) # If user selected to copy the current ISO network configuration # Perform a copy of the config @@ -359,4 +371,4 @@ if not archinstall.arguments.get('silent'): ask_user_questions() perform_filesystem_operations() -perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt'))
\ No newline at end of file +perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt')) |