index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | archinstall/lib/menu/selection_menu.py | 66 |
diff --git a/archinstall/lib/menu/selection_menu.py b/archinstall/lib/menu/selection_menu.py index 97dfd2a7..a82e8a70 100644 --- a/archinstall/lib/menu/selection_menu.py +++ b/archinstall/lib/menu/selection_menu.py @@ -252,6 +252,7 @@ class GeneralMenu: # we synch all the options just in case for item in self.list_options(): self.synch(item) + self.post_callback # as all the values can vary i have to exec this callback cursor_pos = None while True: # Before continuing, set the preferred keyboard layout/language in the current terminal. @@ -278,7 +279,7 @@ class GeneralMenu: Returns true if the menu shall continue, False if it has ended """ # find the selected option in our option list - option = [[k, v] for k, v in self._menu_options.items() if v.text.strip() == selection] + option = [[k, v] for k, v in self._menu_options.items() if v.text.strip() == selection.strip()] if len(option) != 1: raise ValueError(f'Selection not found: {selection}') selector_name = option[0][0] @@ -303,8 +304,8 @@ class GeneralMenu: result = None if selector.func: - # TODO insert code to allow selector functions with preset value - result = selector.func() + presel_val = self.option(selector_name).get_selection() + result = selector.func(presel_val) self._menu_options[selector_name].set_current_selection(result) self._data_store[selector_name] = result exec_ret_val = selector.exec_func(selector_name,result) if selector.exec_func else False @@ -412,32 +413,33 @@ class GlobalMenu(GeneralMenu): super().__init__(data_store=data_store, auto_cursor=True) def _setup_selection_menu_options(self): + # archinstall.Language will not use preset values self._menu_options['archinstall-language'] = \ Selector( _('Select Archinstall language'), - lambda: self._select_archinstall_language('English'), + lambda x: self._select_archinstall_language('English'), default='English', enabled=True) self._menu_options['keyboard-layout'] = \ - Selector(_('Select keyboard layout'), lambda: select_language('us'), default='us') + Selector(_('Select keyboard layout'), lambda preset: select_language('us',preset), default='us') self._menu_options['mirror-region'] = \ Selector( _('Select mirror region'), - lambda: select_mirror_regions(), + select_mirror_regions, display_func=lambda x: list(x.keys()) if x else '[]', default={}) self._menu_options['sys-language'] = \ - Selector(_('Select locale language'), lambda: select_locale_lang('en_US'), default='en_US') + Selector(_('Select locale language'), lambda preset: select_locale_lang('en_US',preset), default='en_US') self._menu_options['sys-encoding'] = \ - Selector(_('Select locale encoding'), lambda: select_locale_enc('utf-8'), default='utf-8') + Selector(_('Select locale encoding'), lambda preset: select_locale_enc('utf-8',preset), default='utf-8') self._menu_options['harddrives'] = \ Selector( _('Select harddrives'), - lambda: self._select_harddrives()) + self._select_harddrives) self._menu_options['disk_layouts'] = \ Selector( _('Select disk layout'), - lambda: select_disk_layout( + lambda x: select_disk_layout( storage['arguments'].get('harddrives', []), storage['arguments'].get('advanced', False) ), @@ -445,80 +447,82 @@ class GlobalMenu(GeneralMenu): self._menu_options['!encryption-password'] = \ Selector( _('Set encryption password'), - lambda: self._select_encrypted_password(), + lambda x: self._select_encrypted_password(), display_func=lambda x: secret(x) if x else 'None', dependencies=['harddrives']) self._menu_options['swap'] = \ Selector( _('Use swap'), - lambda: ask_for_swap(), + lambda preset: ask_for_swap(preset), default=True) self._menu_options['bootloader'] = \ Selector( _('Select bootloader'), - lambda: ask_for_bootloader(storage['arguments'].get('advanced', False)), + lambda preset: ask_for_bootloader(storage['arguments'].get('advanced', False),preset), default="systemd-bootctl" if has_uefi() else "grub-install") self._menu_options['hostname'] = \ Selector( _('Specify hostname'), - lambda: ask_hostname(), + ask_hostname, default='archlinux') + # root password won't have preset value self._menu_options['!root-password'] = \ Selector( _('Set root password'), - lambda: self._set_root_password(), + lambda preset:self._set_root_password(), display_func=lambda x: secret(x) if x else 'None') self._menu_options['!superusers'] = \ Selector( _('Specify superuser account'), - lambda: self._create_superuser_account(), + lambda x: self._create_superuser_account(), dependencies_not=['!root-password'], display_func=lambda x: list(x.keys()) if x else '') self._menu_options['!users'] = \ Selector( _('Specify user account'), - lambda: self._create_user_account(), + lambda x: self._create_user_account(), default={}, display_func=lambda x: list(x.keys()) if x else '[]') self._menu_options['profile'] = \ Selector( _('Specify profile'), - lambda: self._select_profile(), + lambda x: self._select_profile(), display_func=lambda x: x if x else 'None') self._menu_options['audio'] = \ Selector( _('Select audio'), - lambda: ask_for_audio_selection(is_desktop_profile(storage['arguments'].get('profile', None)))) + lambda preset: ask_for_audio_selection(is_desktop_profile(storage['arguments'].get('profile', None)),preset)) self._menu_options['kernels'] = \ Selector( _('Select kernels'), - lambda: select_kernel(), + lambda preset: select_kernel(preset), default=['linux']) self._menu_options['packages'] = \ Selector( _('Additional packages to install'), - lambda: ask_additional_packages_to_install(storage['arguments'].get('packages', None)), + # lambda x: ask_additional_packages_to_install(storage['arguments'].get('packages', None)), + ask_additional_packages_to_install, default=[]) self._menu_options['additional-repositories'] = \ Selector( _('Additional repositories to enable'), - lambda: select_additional_repositories(), + select_additional_repositories, default=[]) self._menu_options['nic'] = \ Selector( _('Configure network'), - lambda: ask_to_configure_network(), + ask_to_configure_network, display_func=lambda x: x if x else _('Not configured, unavailable unless setup manually'), default={}) self._menu_options['timezone'] = \ Selector( _('Select timezone'), - lambda: ask_for_a_timezone(), + lambda preset: ask_for_a_timezone(preset), default='UTC') self._menu_options['ntp'] = \ Selector( _('Set automatic time sync (NTP)'), - lambda: self._select_ntp(), + lambda preset: self._select_ntp(preset), default=True) self._menu_options['install'] = \ Selector( @@ -591,20 +595,20 @@ class GlobalMenu(GeneralMenu): else: return None - def _select_ntp(self) -> bool: - ntp = ask_ntp() + def _select_ntp(self, preset :bool = True) -> bool: + ntp = ask_ntp(preset) value = str(ntp).lower() SysCommand(f'timedatectl set-ntp {value}') return ntp - def _select_harddrives(self): - old_haddrives = storage['arguments'].get('harddrives', []) - harddrives = select_harddrives() + def _select_harddrives(self, old_harddrives : list) -> list: + # old_haddrives = storage['arguments'].get('harddrives', []) + harddrives = select_harddrives(old_harddrives) # in case the harddrives got changed we have to reset the disk layout as well - if old_haddrives != harddrives: + if old_harddrives != harddrives: self._menu_options.get('disk_layouts').set_current_selection(None) storage['arguments']['disk_layouts'] = {} |