def load_config(): if archinstall.arguments.get('harddrives', None) is not None: 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: if type(archinstall.arguments.get('profile', None)) is dict: archinstall.arguments['profile'] = archinstall.Profile( None, archinstall.arguments.get('profile', None)['path']) else: archinstall.arguments['profile'] = archinstall.Profile( None, archinstall.arguments.get('profile', None)) archinstall.storage['_desktop_profile'] = archinstall.arguments.get( 'desktop-environment', None) if archinstall.arguments.get('mirror-region', None) is not None: if type(archinstall.arguments.get('mirror-region', None)) is dict: archinstall.arguments['mirror-region'] = archinstall.arguments.get( 'mirror-region', None) else: selected_region = archinstall.arguments.get('mirror-region', None) archinstall.arguments['mirror-region'] = { selected_region: archinstall.list_mirrors()[selected_region] } if archinstall.arguments.get('sys-language', None) is not None: archinstall.arguments['sys-language'] = archinstall.arguments.get( 'sys-language', 'en_US') if archinstall.arguments.get('sys-encoding', None) is not None: archinstall.arguments['sys-encoding'] = archinstall.arguments.get( 'sys-encoding', 'utf-8') if archinstall.arguments.get('gfx_driver', None) is not None: 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 load_profiles(): if archinstall.arguments.get('profile', None) is not None: if type(archinstall.arguments.get('profile', None)) is dict: archinstall.arguments['profile'] = archinstall.Profile( None, archinstall.arguments.get('profile', None)['path']) else: archinstall.arguments['profile'] = archinstall.Profile( None, archinstall.arguments.get('profile', None))
def _prep_function(*args, **kwargs): """ Magic function called by the importing installer before continuing any further. It also avoids executing any other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ supported_desktops = [ 'gnome', 'kde', 'awesome', 'sway', 'cinnamon', 'xfce4', 'lxqt', 'i3', 'budgie', 'mate' ] desktop = archinstall.generic_select( supported_desktops, 'Select your desired desktop environment: ', allow_empty_input=False, sort=True) # Temporarily store the selected desktop profile # in a session-safe location, since this module will get reloaded # the next time it gets executed. archinstall.storage['_desktop_profile'] = desktop profile = archinstall.Profile(None, desktop) # Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered. with profile.load_instructions(namespace=f"{desktop}.py") as imported: if hasattr(imported, '_prep_function'): return imported._prep_function() else: print( f"Deprecated (??): {desktop} profile has no _prep_function() anymore" )
def _prep_function(*args, **kwargs): """ Magic function called by the importing installer before continuing any further. It also avoids executing any other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ supported_configurations = ['i3-wm', 'i3-gaps'] desktop = archinstall.generic_select(supported_configurations, 'Select your desired configuration: ', allow_empty_input=False, sort=True) # Temporarily store the selected desktop profile # in a session-safe location, since this module will get reloaded # the next time it gets executed. archinstall.storage['_i3_configuration'] = desktop # i3 requires a functioning Xorg installation. profile = archinstall.Profile(None, 'xorg') with profile.load_instructions(namespace='xorg.py') as imported: if hasattr(imported, '_prep_function'): return imported._prep_function() else: print( 'Deprecated (??): xorg profile has no _prep_function() anymore' )
def _prep_function(*args, **kwargs) -> bool: """ Magic function called by the importing installer before continuing any further. It also avoids executing any other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ choice = Menu(str(_('Select your desired desktop environment')), __supported__).run() if choice.type_ != MenuSelectionType.Selection: return False if choice.value: # Temporarily store the selected desktop profile # in a session-safe location, since this module will get reloaded # the next time it gets executed. if not archinstall.storage.get('_desktop_profile', None): archinstall.storage['_desktop_profile'] = choice.value if not archinstall.arguments.get('desktop-environment', None): archinstall.arguments['desktop-environment'] = choice.value profile = archinstall.Profile(None, choice.value) # Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered. with profile.load_instructions( namespace=f"{choice.value}.py") as imported: if hasattr(imported, '_prep_function'): return imported._prep_function() else: log(f"Deprecated (??): {choice.value} profile has no _prep_function() anymore" ) exit(1) return False
def _prep_function(*args, **kwargs): """ Magic function called by the importing installer before continuing any further. It also avoids executing any other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ desktop = archinstall.generic_select( __supported__, 'Select your desired desktop environment: ', allow_empty_input=False, sort=True) # Temporarily store the selected desktop profile # in a session-safe location, since this module will get reloaded # the next time it gets executed. if '_desktop_profile' not in archinstall.storage.keys(): archinstall.storage['_desktop_profile'] = desktop profile = archinstall.Profile(None, desktop) # Set the resolved profile path to the actual desktop environment archinstall.arguments['profile'] = profile # Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered. with profile.load_instructions(namespace=f"{desktop}.py") as imported: if hasattr(imported, '_prep_function'): return imported._prep_function() else: print( f"Deprecated (??): {desktop} profile has no _prep_function() anymore" )
def load_config(): if archinstall.arguments.get('harddrives', None) is not None: 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: if type(archinstall.arguments.get('profile', None)) is dict: archinstall.arguments['profile'] = archinstall.Profile( None, archinstall.arguments.get('profile', None)['path']) else: archinstall.arguments['profile'] = archinstall.Profile( None, archinstall.arguments.get('profile', None)) archinstall.storage['_desktop_profile'] = archinstall.arguments.get( 'desktop-environment', None) if archinstall.arguments.get('mirror-region', None) is not None: if type(archinstall.arguments.get('mirror-region', None)) is dict: archinstall.arguments['mirror-region'] = archinstall.arguments.get( 'mirror-region', None) else: selected_region = archinstall.arguments.get('mirror-region', None) archinstall.arguments['mirror-region'] = { selected_region: archinstall.list_mirrors()[selected_region] } if archinstall.arguments.get('sys-language', None) is not None: archinstall.arguments['sys-language'] = archinstall.arguments.get( 'sys-language', 'en_US') if archinstall.arguments.get('sys-encoding', None) is not None: archinstall.arguments['sys-encoding'] = archinstall.arguments.get( 'sys-encoding', 'utf-8') if archinstall.arguments.get('gfx_driver', None) is not None: archinstall.storage[ 'gfx_driver_packages'] = archinstall.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)
def _prep_function(*args, **kwargs): """ Magic function called by the importing installer before continuing any further. It also avoids executing any other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ # Deepin requires a functioning Xorg installation. profile = archinstall.Profile(None, 'xorg') with profile.load_instructions(namespace='xorg.py') as imported: if hasattr(imported, '_prep_function'): return imported._prep_function() else: print('Deprecated (??): xorg profile has no _prep_function() anymore')
def _prep_function(*args, **kwargs): """ Magic function called by the importing installer before continuing any further. It also avoids executing any other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ # Gnome optionally supports xorg, we'll install it since it also # includes graphic driver setups (this might change in the future) profile = archinstall.Profile(None, 'xorg') with profile.load_instructions(namespace='xorg.py') as imported: if hasattr(imported, '_prep_function'): return imported._prep_function() else: print('Deprecated (??): xorg profile has no _prep_function() anymore')
if not check_mirror_reachable(): log_file = os.path.join(archinstall.storage.get('LOG_PATH', None), archinstall.storage.get('LOG_FILE', None)) archinstall.log( f"Arch Linux mirrors are not reachable. Please check your internet connection and the log file '{log_file}'.", level=logging.INFO, fg="red") exit(1) if archinstall.arguments.get('silent', None) is None: ask_user_questions() else: # Workarounds if config is loaded from a file # The harddrive section should be moved to perform_installation_steps, where it's actually being performed # Blockdevice object should be created in perform_installation_steps # This needs to be done until then archinstall.arguments['harddrive'] = archinstall.BlockDevice( path=archinstall.arguments['harddrive']['path']) # Temporarily disabling keep_partitions if config file is loaded archinstall.arguments['harddrive'].keep_partitions = False # Temporary workaround to make Desktop Environments work if archinstall.arguments.get('profile', None) is not None: archinstall.arguments['profile'] = archinstall.Profile( None, archinstall.arguments.get('profile', None)) else: archinstall.arguments['profile'] = None perform_installation_steps()
import archinstall import time for name, info in archinstall.list_profiles().items(): # Tailored means it's a match for this machine # based on it's MAC address (or some other criteria # that fits the requirements for this machine specifically). if info['tailored']: print(f'Found a tailored profile for this machine called: "{name}".') print(f'Starting install in:') for i in range(10, 0, -1): print(f'{i}...') time.sleep(1) profile = archinstall.Profile(None, info['path']) profile.install() break