* Fix #966 * Add types to parameters * Update network configuration * Backwards compability for nic config * Update Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
This commit is contained in:
parent
d9118a33b3
commit
6489a417aa
|
|
@ -203,7 +203,13 @@ def load_config():
|
|||
storage['gfx_driver_packages'] = AVAILABLE_GFX_DRIVERS.get(arguments.get('gfx_driver', None), None)
|
||||
if arguments.get('servers', None) is not None:
|
||||
storage['_selected_servers'] = arguments.get('servers', None)
|
||||
|
||||
if nic_config := arguments.get('nic', {}):
|
||||
if nic_config.get('nic', '') == 'Copy ISO network configuration to installation':
|
||||
arguments['nic'] = {'type': 'iso_config'}
|
||||
elif 'NetworkManager' in nic_config:
|
||||
arguments['nic'] = {'type': 'network_manager', 'NetworkManager': True}
|
||||
else:
|
||||
arguments['nic'] = {k if k != 'nic' else 'type': v for k, v in nic_config.items()}
|
||||
|
||||
def post_process_arguments(arguments):
|
||||
storage['arguments'] = arguments
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from typing import Dict, List, Union, Any
|
||||
|
||||
from archinstall.lib.menu.simple_menu import TerminalMenu
|
||||
from ..exceptions import RequirementError
|
||||
from ..output import log
|
||||
|
|
@ -7,7 +9,17 @@ import sys
|
|||
import logging
|
||||
|
||||
class Menu(TerminalMenu):
|
||||
def __init__(self, title, p_options, skip=True, multi=False, default_option=None, sort=True, preset_values=None, cursor_index=None):
|
||||
def __init__(
|
||||
self,
|
||||
title :str,
|
||||
p_options :Union[List[str], Dict[str, Any]],
|
||||
skip :bool = True,
|
||||
multi :bool = False,
|
||||
default_option :str = None,
|
||||
sort :bool = True,
|
||||
preset_values :Union[str, List[str]] = None,
|
||||
cursor_index :int = None
|
||||
):
|
||||
"""
|
||||
Creates a new menu
|
||||
|
||||
|
|
@ -60,6 +72,11 @@ class Menu(TerminalMenu):
|
|||
log(f"invalid parameter at Menu() call was at <{sys._getframe(1).f_code.co_name}>",level=logging.WARNING)
|
||||
raise RequirementError('Menu.__init__() requires at least one option to proceed.')
|
||||
|
||||
if any([o for o in options if not isinstance(o, str)]):
|
||||
log(" * Menu options must be of type string * ", fg='red')
|
||||
log(f"invalid parameter at Menu() call was at <{sys._getframe(1).f_code.co_name}>",level=logging.WARNING)
|
||||
raise RequirementError('Menu.__init__() requires the options to be of type string')
|
||||
|
||||
if sort:
|
||||
options = sorted(options)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from pathlib import Path
|
|||
from typing import List, Dict
|
||||
from .exceptions import TranslationError
|
||||
|
||||
|
||||
class Languages:
|
||||
def __init__(self):
|
||||
self._mappings = self._get_language_mappings()
|
||||
|
|
@ -46,6 +47,13 @@ class DeferredTranslation:
|
|||
def __gt__(self, other) -> bool:
|
||||
return self.message > other
|
||||
|
||||
def __add__(self, other) -> DeferredTranslation:
|
||||
if isinstance(other, str):
|
||||
other = DeferredTranslation(other)
|
||||
|
||||
concat = self.message + other.message
|
||||
return DeferredTranslation(concat)
|
||||
|
||||
def format(self, *args) -> str:
|
||||
return self.message.format(*args)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ from .mirrors import list_mirrors
|
|||
|
||||
# TODO: Some inconsistencies between the selection processes.
|
||||
# Some return the keys from the options, some the values?
|
||||
from .translation import Translation
|
||||
from .translation import Translation, DeferredTranslation
|
||||
from .disk.validators import fs_types
|
||||
from .packages.packages import validate_package_list
|
||||
|
||||
|
|
@ -428,22 +428,22 @@ def ask_to_configure_network() -> Dict[str, Any]:
|
|||
# Optionally configure one network interface.
|
||||
# while 1:
|
||||
# {MAC: Ifname}
|
||||
|
||||
iso_config = _('Copy ISO network configuration to installation')
|
||||
network_manager = _('Use NetworkManager (necessary to configure internet graphically in GNOME and KDE)')
|
||||
|
||||
interfaces = {
|
||||
'ISO-CONFIG': iso_config,
|
||||
'NetworkManager': network_manager,
|
||||
'iso_config': str(_('Copy ISO network configuration to installation')),
|
||||
'network_manager': str(_('Use NetworkManager (necessary to configure internet graphically in GNOME and KDE)')),
|
||||
**list_interfaces()
|
||||
}
|
||||
|
||||
nic = Menu(_('Select one network interface to configure'), list(interfaces.values())).run()
|
||||
|
||||
if nic and nic != iso_config:
|
||||
if nic == network_manager:
|
||||
return {'nic': nic, 'NetworkManager': True}
|
||||
if not nic:
|
||||
return {}
|
||||
|
||||
if nic == interfaces['iso_config']:
|
||||
return {'type': 'iso_config'}
|
||||
elif nic == interfaces['network_manager']:
|
||||
return {'type': 'network_manager', 'NetworkManager': True}
|
||||
else:
|
||||
# Current workaround:
|
||||
# For selecting modes without entering text within brackets,
|
||||
# printing out this part separate from options, passed in
|
||||
|
|
@ -491,13 +491,10 @@ def ask_to_configure_network() -> Dict[str, Any]:
|
|||
if len(dns_input):
|
||||
dns = dns_input.split(' ')
|
||||
|
||||
return {'nic': nic, 'dhcp': False, 'ip': ip, 'gateway': gateway, 'dns': dns}
|
||||
return {'type': nic, 'dhcp': False, 'ip': ip, 'gateway': gateway, 'dns': dns}
|
||||
else:
|
||||
return {'nic': nic}
|
||||
elif nic:
|
||||
return nic
|
||||
|
||||
return {}
|
||||
# this will contain network iface names
|
||||
return {'type': nic}
|
||||
|
||||
|
||||
def partition_overlap(partitions :list, start :str, end :str) -> bool:
|
||||
|
|
@ -925,7 +922,7 @@ def select_driver(options :Dict[str, Any] = AVAILABLE_GFX_DRIVERS, force_ask :bo
|
|||
|
||||
if drivers:
|
||||
arguments = storage.get('arguments', {})
|
||||
title = ''
|
||||
title = DeferredTranslation('')
|
||||
|
||||
if has_amd_graphics():
|
||||
title += _('For the best compatibility with your AMD hardware, you may want to use either the all open-source or AMD / ATI options.') + '\n'
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ def perform_installation(mountpoint):
|
|||
|
||||
# If user selected to copy the current ISO network configuration
|
||||
# Perform a copy of the config
|
||||
if archinstall.arguments.get('nic', {}) == 'Copy ISO network configuration to installation':
|
||||
if archinstall.arguments.get('nic', {}).get('type', '') == 'iso_config':
|
||||
installation.copy_iso_network_config(enable_services=True) # Sources the ISO network configuration to the install medium.
|
||||
elif archinstall.arguments.get('nic', {}).get('NetworkManager', False):
|
||||
installation.add_additional_packages("networkmanager")
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ def os_setup(installation):
|
|||
|
||||
# If user selected to copy the current ISO network configuration
|
||||
# Perform a copy of the config
|
||||
if archinstall.arguments.get('nic', {}) == 'Copy ISO network configuration to installation':
|
||||
if archinstall.arguments.get('nic', {}).get('type', '') == 'iso_config':
|
||||
installation.copy_iso_network_config(
|
||||
enable_services=True) # Sources the ISO network configuration to the install medium.
|
||||
elif archinstall.arguments.get('nic', {}).get('NetworkManager', False):
|
||||
|
|
|
|||
Loading…
Reference in New Issue