additional package install

This commit is contained in:
le 2023-03-30 21:39:26 +08:00
parent b8b674c755
commit 00b28377f6
3 changed files with 327 additions and 268 deletions

View File

@ -188,12 +188,27 @@ class GlobalMenu(GeneralMenu):
_('Base Image'), _('Base Image'),
func=lambda preset: select_base_image(preset), func=lambda preset: select_base_image(preset),
default='runtime') default='runtime')
# self._menu_options['base_image'] = \
# Selector(
# _('Base Image'),
# func=lambda preset: select_base_image(preset),
# default='runtime')
# self._menu_options['harddrives'] = \
# Selector(
# _('Drive(s)'),
# lambda preset: self._select_harddrives(preset),
# display_func=lambda x: f'{len(x)} ' + str(_('Drive(s)')) if x is not None and len(x) > 0 else '',
# preview_func=self._prev_harddrives,
# )
self._menu_options['packages'] = \ self._menu_options['packages'] = \
Selector( Selector(
_('Additional packages'), _('Additional packages'),
# lambda x: 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, lambda preset: self._select_additional_packages(preset),
default=[]) display_func=lambda x: f'{len(x)} ' + str(_('package(s)')) if x is not None and len(x) > 0 else '',
default=[],
dependencies=['base_image_develop'])
self._menu_options['additional-repositories'] = \ self._menu_options['additional-repositories'] = \
Selector( Selector(
_('Optional repositories'), _('Optional repositories'),
@ -382,6 +397,9 @@ class GlobalMenu(GeneralMenu):
if not self._menu_options['harddrives'].is_empty() and not check('disk_layouts'): if not self._menu_options['harddrives'].is_empty() and not check('disk_layouts'):
missing += [str(_('Disk layout'))] missing += [str(_('Disk layout'))]
if storage['arguments'].get('used_lvm_partition',False):
if not check('lvmdrives'):
missing += [str(_('LVM(s)'))]
return missing return missing
def _set_root_password(self) -> Optional[str]: def _set_root_password(self) -> Optional[str]:
@ -515,3 +533,7 @@ class GlobalMenu(GeneralMenu):
def _create_user_account(self, defined_users: List[User]) -> List[User]: def _create_user_account(self, defined_users: List[User]) -> List[User]:
users = ask_for_additional_users(defined_users=defined_users) users = ask_for_additional_users(defined_users=defined_users)
return users return users
def _select_additional_packages(self, old_packages: List[str] = []) -> List:
select_packages = ask_additional_packages_to_install(old_packages)
return select_packages

View File

@ -20,334 +20,338 @@ from ..translationhandler import Language, TranslationHandler
from ..packages.packages import validate_package_list from ..packages.packages import validate_package_list
from ..storage import storage from ..storage import storage
import time
if TYPE_CHECKING: if TYPE_CHECKING:
_: Any _: Any
def ask_ntp(preset: bool = True) -> bool: def ask_ntp(preset: bool = True) -> bool:
prompt = str(_('Would you like to use automatic time synchronization (NTP) with the default time servers?\n')) prompt = str(_('Would you like to use automatic time synchronization (NTP) with the default time servers?\n'))
prompt += str(_('Hardware time and other post-configuration steps might be required in order for NTP to work.\nFor more information, please check the Arch wiki')) prompt += str(_('Hardware time and other post-configuration steps might be required in order for NTP to work.\nFor more information, please check the Arch wiki'))
if preset: if preset:
preset_val = Menu.yes() preset_val = Menu.yes()
else: else:
preset_val = Menu.no() preset_val = Menu.no()
choice = Menu(prompt, Menu.yes_no(), skip=False, preset_values=preset_val, default_option=Menu.yes()).run() choice = Menu(prompt, Menu.yes_no(), skip=False, preset_values=preset_val, default_option=Menu.yes()).run()
return False if choice.value == Menu.no() else True return False if choice.value == Menu.no() else True
def ask_hostname(preset: str = None) -> str: def ask_hostname(preset: str = None) -> str:
hostname = TextInput(_('Desired hostname for the installation: '), preset).run().strip(' ') hostname = TextInput(_('Desired hostname for the installation: '), preset).run().strip(' ')
return hostname return hostname
def ask_for_a_timezone(preset: str = None) -> str: def ask_for_a_timezone(preset: str = None) -> str:
timezones = list_timezones() timezones = list_timezones()
default = 'UTC' default = 'UTC'
choice = Menu( choice = Menu(
_('Select a timezone'), _('Select a timezone'),
list(timezones), list(timezones),
preset_values=preset, preset_values=preset,
default_option=default default_option=default
).run() ).run()
if choice.type_ == MenuSelectionType.Esc: if choice.type_ == MenuSelectionType.Esc:
return preset return preset
elif choice.type_ == MenuSelectionType.Selection: elif choice.type_ == MenuSelectionType.Selection:
return choice.value return choice.value
def ask_for_audio_selection(desktop: bool = True, preset: str = None) -> str: def ask_for_audio_selection(desktop: bool = True, preset: str = None) -> str:
no_audio = str(_('No audio server')) no_audio = str(_('No audio server'))
choices = ['pipewire', 'pulseaudio'] if desktop else ['pipewire', 'pulseaudio', no_audio] choices = ['pipewire', 'pulseaudio'] if desktop else ['pipewire', 'pulseaudio', no_audio]
default = 'pipewire' if desktop else no_audio default = 'pipewire' if desktop else no_audio
choice = Menu(_('Choose an audio server'), choices, preset_values=preset, default_option=default).run() choice = Menu(_('Choose an audio server'), choices, preset_values=preset, default_option=default).run()
if choice.type_ == MenuSelectionType.Esc: if choice.type_ == MenuSelectionType.Esc:
return preset return preset
elif choice.type_ == MenuSelectionType.Selection: elif choice.type_ == MenuSelectionType.Selection:
return choice.value return choice.value
def select_language(preset_value: str = None) -> str: def select_language(preset_value: str = None) -> str:
""" """
Asks the user to select a language Asks the user to select a language
Usually this is combined with :ref:`archinstall.list_keyboard_languages`. Usually this is combined with :ref:`archinstall.list_keyboard_languages`.
:return: The language/dictionary key of the selected language :return: The language/dictionary key of the selected language
:rtype: str :rtype: str
""" """
kb_lang = list_keyboard_languages() kb_lang = list_keyboard_languages()
# sort alphabetically and then by length # sort alphabetically and then by length
sorted_kb_lang = sorted(sorted(list(kb_lang)), key=len) sorted_kb_lang = sorted(sorted(list(kb_lang)), key=len)
selected_lang = Menu( selected_lang = Menu(
_('Select keyboard layout'), _('Select keyboard layout'),
sorted_kb_lang, sorted_kb_lang,
preset_values=preset_value, preset_values=preset_value,
sort=False sort=False
).run() ).run()
if selected_lang.value is None: if selected_lang.value is None:
return preset_value return preset_value
return selected_lang.value return selected_lang.value
def select_mirror_regions(preset_values: Dict[str, Any] = {}) -> Dict[str, Any]: def select_mirror_regions(preset_values: Dict[str, Any] = {}) -> Dict[str, Any]:
""" """
Asks the user to select a mirror or region Asks the user to select a mirror or region
Usually this is combined with :ref:`archinstall.list_mirrors`. Usually this is combined with :ref:`archinstall.list_mirrors`.
:return: The dictionary information about a mirror/region. :return: The dictionary information about a mirror/region.
:rtype: dict :rtype: dict
""" """
if preset_values is None: if preset_values is None:
preselected = None preselected = None
else: else:
preselected = list(preset_values.keys()) preselected = list(preset_values.keys())
mirrors = list_mirrors() mirrors = list_mirrors()
selected_mirror = Menu( selected_mirror = Menu(
_('Select one of the regions to download packages from'), _('Select one of the regions to download packages from'),
list(mirrors.keys()), list(mirrors.keys()),
preset_values=preselected, preset_values=preselected,
multi=True, multi=True,
raise_error_on_interrupt=True raise_error_on_interrupt=True
).run() ).run()
# match selected_mirror.type_: # match selected_mirror.type_:
# case MenuSelectionType.Ctrl_c: return {} # case MenuSelectionType.Ctrl_c: return {}
# case MenuSelectionType.Esc: return preset_values # case MenuSelectionType.Esc: return preset_values
# case _: return {selected: mirrors[selected] for selected in selected_mirror.value} # case _: return {selected: mirrors[selected] for selected in selected_mirror.value}
if selected_mirror.type_ == MenuSelectionType.Esc: if selected_mirror.type_ == MenuSelectionType.Esc:
return preset_values return preset_values
elif selected_mirror.type_ == MenuSelectionType.Ctrl_c: elif selected_mirror.type_ == MenuSelectionType.Ctrl_c:
return {} return {}
else: else:
return {selected: mirrors[selected] for selected in selected_mirror.value} return {selected: mirrors[selected] for selected in selected_mirror.value}
def select_archinstall_language(languages: List[Language], preset_value: Language) -> Language: def select_archinstall_language(languages: List[Language], preset_value: Language) -> Language:
# these are the displayed language names which can either be # these are the displayed language names which can either be
# the english name of a language or, if present, the # the english name of a language or, if present, the
# name of the language in its own language # name of the language in its own language
options = {lang.display_name: lang for lang in languages} options = {lang.display_name: lang for lang in languages}
def dependency_preview(current_selection: str) -> Optional[str]: def dependency_preview(current_selection: str) -> Optional[str]:
current_lang = options[current_selection] current_lang = options[current_selection]
if current_lang.external_dep and not TranslationHandler.is_custom_font_enabled(): if current_lang.external_dep and not TranslationHandler.is_custom_font_enabled():
font_file = TranslationHandler.custom_font_path() font_file = TranslationHandler.custom_font_path()
text = str(_('To be able to use this translation, please install a font manually that supports the language.')) + '\n' text = str(_('To be able to use this translation, please install a font manually that supports the language.')) + '\n'
text += str(_('The font should be stored as {}')).format(font_file) text += str(_('The font should be stored as {}')).format(font_file)
return text return text
return None return None
choice = Menu( choice = Menu(
_('Archinstall language'), _('Archinstall language'),
list(options.keys()), list(options.keys()),
default_option=preset_value.display_name, default_option=preset_value.display_name,
preview_command=lambda x: dependency_preview(x), preview_command=lambda x: dependency_preview(x),
preview_size=0.5 preview_size=0.5
).run() ).run()
# match choice.type_: # match choice.type_:
# case MenuSelectionType.Esc: # case MenuSelectionType.Esc:
# return preset_value # return preset_value
# case MenuSelectionType.Selection: # case MenuSelectionType.Selection:
# language: Language = options[choice.value] # language: Language = options[choice.value]
# # we have to make sure that the proper AUR dependency is # # we have to make sure that the proper AUR dependency is
# # present to be able to use this language # # present to be able to use this language
# if not language.external_dep or TranslationHandler.is_custom_font_enabled(): # if not language.external_dep or TranslationHandler.is_custom_font_enabled():
# return language # return language
# return select_archinstall_language(languages, preset_value) # return select_archinstall_language(languages, preset_value)
if choice.type_ == MenuSelectionType.Esc: if choice.type_ == MenuSelectionType.Esc:
return preset_value return preset_value
elif choice.type_ == MenuSelectionType.Selection: elif choice.type_ == MenuSelectionType.Selection:
language: Language = options[choice.value] language: Language = options[choice.value]
# we have to make sure that the proper AUR dependency is # we have to make sure that the proper AUR dependency is
# present to be able to use this language # present to be able to use this language
if not language.external_dep or TranslationHandler.is_custom_font_enabled(): if not language.external_dep or TranslationHandler.is_custom_font_enabled():
return language return language
return select_archinstall_language(languages, preset_value) return select_archinstall_language(languages, preset_value)
def select_profile(preset) -> Optional[Profile]: def select_profile(preset) -> Optional[Profile]:
""" """
# Asks the user to select a profile from the available profiles. # Asks the user to select a profile from the available profiles.
# #
# :return: The name/dictionary key of the selected profile # :return: The name/dictionary key of the selected profile
# :rtype: str # :rtype: str
# """ # """
top_level_profiles = sorted(list(list_profiles(filter_top_level_profiles=True))) top_level_profiles = sorted(list(list_profiles(filter_top_level_profiles=True)))
options = {} options = {}
for profile in top_level_profiles: for profile in top_level_profiles:
profile = Profile(None, profile) profile = Profile(None, profile)
description = profile.get_profile_description() description = profile.get_profile_description()
option = f'{profile.profile}: {description}' option = f'{profile.profile}: {description}'
options[option] = profile options[option] = profile
title = _('This is a list of pre-programmed profiles, they might make it easier to install things like desktop environments') title = _('This is a list of pre-programmed profiles, they might make it easier to install things like desktop environments')
warning = str(_('Are you sure you want to reset this setting?')) warning = str(_('Are you sure you want to reset this setting?'))
selection = Menu( selection = Menu(
title=title, title=title,
p_options=list(options.keys()), p_options=list(options.keys()),
raise_error_on_interrupt=True, raise_error_on_interrupt=True,
raise_error_warning_msg=warning raise_error_warning_msg=warning
).run() ).run()
# match selection.type_: # match selection.type_:
# case MenuSelectionType.Selection: # case MenuSelectionType.Selection:
# return options[selection.value] if selection.value is not None else None # return options[selection.value] if selection.value is not None else None
# case MenuSelectionType.Ctrl_c: # case MenuSelectionType.Ctrl_c:
# storage['profile_minimal'] = False # storage['profile_minimal'] = False
# storage['_selected_servers'] = [] # storage['_selected_servers'] = []
# storage['_desktop_profile'] = None # storage['_desktop_profile'] = None
# storage['arguments']['desktop-environment'] = None # storage['arguments']['desktop-environment'] = None
# storage['arguments']['gfx_driver_packages'] = None # storage['arguments']['gfx_driver_packages'] = None
# return None # return None
# case MenuSelectionType.Esc: # case MenuSelectionType.Esc:
# return None # return None
if selection.type_ == MenuSelectionType.Esc: if selection.type_ == MenuSelectionType.Esc:
return None return None
elif selection.type_ == MenuSelectionType.Selection: elif selection.type_ == MenuSelectionType.Selection:
return options[selection.value] if selection.value is not None else None return options[selection.value] if selection.value is not None else None
elif selection.type_ == MenuSelectionType.Ctrl_c: elif selection.type_ == MenuSelectionType.Ctrl_c:
storage['profile_minimal'] = False storage['profile_minimal'] = False
storage['_selected_servers'] = [] storage['_selected_servers'] = []
storage['_desktop_profile'] = None storage['_desktop_profile'] = None
storage['arguments']['desktop-environment'] = None storage['arguments']['desktop-environment'] = None
storage['arguments']['gfx_driver_packages'] = None storage['arguments']['gfx_driver_packages'] = None
return None return None
def select_base_image(preset: str) -> str: def select_base_image(preset: str) -> str:
""" """
Asks the user to select a image for system. Asks the user to select a image for system.
:return: The string as a selected image :return: The string as a selected image
:rtype: string :rtype: string
""" """
allnames = ["runtime", "develop"] allnames = ["runtime", "develop"]
default_val = "runtime" default_val = "runtime"
warning = str(_('Are you sure you want to reset this setting?')) warning = str(_('Are you sure you want to reset this setting?'))
choice = Menu( choice = Menu(
_('Choose which base image to use or leave blank for default "{}"').format(default_val), _('Choose which base image to use or leave blank for default "{}"').format(default_val),
allnames, allnames,
sort=False, sort=False,
multi=False, multi=False,
preset_values=preset, preset_values=preset,
raise_error_on_interrupt=True, raise_error_on_interrupt=True,
raise_error_warning_msg=warning raise_error_warning_msg=warning
).run() ).run()
# match choice.type_: # match choice.type_:
# case MenuSelectionType.Esc: return preset # case MenuSelectionType.Esc: return preset
# case MenuSelectionType.Ctrl_c: return [] # case MenuSelectionType.Ctrl_c: return []
# case MenuSelectionType.Selection: return choice.value # case MenuSelectionType.Selection: return choice.value
if choice.type_ == MenuSelectionType.Esc: storage['arguments']['base_image_develop'] = False
return preset if choice.type_ == MenuSelectionType.Esc:
elif choice.type_ == MenuSelectionType.Ctrl_c: if preset == 'develop':
return [] storage['arguments']['base_image_develop'] = True
elif choice.type_ == MenuSelectionType.Selection: return preset
return choice.value elif choice.type_ == MenuSelectionType.Ctrl_c:
return []
elif choice.type_ == MenuSelectionType.Selection:
if choice.value == 'develop':
storage['arguments']['base_image_develop'] = True
return choice.value
def ask_additional_packages_to_install(pre_set_packages: List[str] = []) -> List[str]: def ask_additional_packages_to_install(pre_set_packages: List[str] = []) -> List[str]:
# Additional packages (with some light weight error handling for invalid package names) title = str(_('Select one or more packages to use and install\n'))
print(_('Only packages such as base, base-devel, linux, linux-firmware, efibootmgr and optional profile packages are installed.')) warning = str(_('If you reset the packages selection, Are you sure?'))
print(_('If you desire a web browser, such as firefox or chromium, you may specify it in the following prompt.')) options = {"kde-plasma": "kde-plasma"}
options_keys = options.keys()
# print(pre_set_packages)
# time.sleep(1.5)
selected_harddrive = Menu(
title,
options_keys,
preset_values=pre_set_packages,
multi=True,
raise_error_on_interrupt=True,
raise_error_warning_msg=warning
).run()
def read_packages(already_defined: list = []) -> list: select_packages = []
display = ' '.join(already_defined) if selected_harddrive.type_ == MenuSelectionType.Esc:
input_packages = TextInput(_('Write additional packages to install (space separated, leave blank to skip): '), display).run().strip() select_packages = pre_set_packages
return input_packages.split() if input_packages else [] elif selected_harddrive.type_ == MenuSelectionType.Ctrl_c:
select_packages = []
pre_set_packages = pre_set_packages if pre_set_packages else [] elif selected_harddrive.type_ == MenuSelectionType.Selection:
packages = read_packages(pre_set_packages) select_packages = [options[i] for i in selected_harddrive.value]
storage['arguments']['packages'] = select_packages
if not storage['arguments']['offline'] and not storage['arguments']['no_pkg_lookups']: return select_packages
while True:
if len(packages):
# Verify packages that were given
print(_("Verifying that additional packages exist (this might take a few seconds)"))
valid, invalid = validate_package_list(packages)
if invalid:
log(f"Some packages could not be found in the repository: {invalid}", level=logging.WARNING, fg='red')
packages = read_packages(valid)
continue
break
return packages
def add_number_of_parrallel_downloads(input_number :Optional[int] = None) -> Optional[int]: def add_number_of_parrallel_downloads(input_number :Optional[int] = None) -> Optional[int]:
max_downloads = 5 max_downloads = 5
print(_(f"This option enables the number of parallel downloads that can occur during installation")) print(_(f"This option enables the number of parallel downloads that can occur during installation"))
print(_(f"Enter the number of parallel downloads to be enabled.\n (Enter a value between 1 to {max_downloads})\nNote:")) print(_(f"Enter the number of parallel downloads to be enabled.\n (Enter a value between 1 to {max_downloads})\nNote:"))
print(_(f" - Maximum value : {max_downloads} ( Allows {max_downloads} parallel downloads, allows {max_downloads+1} downloads at a time )")) print(_(f" - Maximum value : {max_downloads} ( Allows {max_downloads} parallel downloads, allows {max_downloads+1} downloads at a time )"))
print(_(f" - Minimum value : 1 ( Allows 1 parallel download, allows 2 downloads at a time )")) print(_(f" - Minimum value : 1 ( Allows 1 parallel download, allows 2 downloads at a time )"))
print(_(f" - Disable/Default : 0 ( Disables parallel downloading, allows only 1 download at a time )")) print(_(f" - Disable/Default : 0 ( Disables parallel downloading, allows only 1 download at a time )"))
while True: while True:
try: try:
input_number = int(TextInput(_("[Default value: 0] > ")).run().strip() or 0) input_number = int(TextInput(_("[Default value: 0] > ")).run().strip() or 0)
if input_number <= 0: if input_number <= 0:
input_number = 0 input_number = 0
elif input_number > max_downloads: elif input_number > max_downloads:
input_number = max_downloads input_number = max_downloads
break break
except: except:
print(_(f"Invalid input! Try again with a valid input [1 to {max_downloads}, or 0 to disable]")) print(_(f"Invalid input! Try again with a valid input [1 to {max_downloads}, or 0 to disable]"))
pacman_conf_path = pathlib.Path("/etc/pacman.conf") pacman_conf_path = pathlib.Path("/etc/pacman.conf")
with pacman_conf_path.open() as f: with pacman_conf_path.open() as f:
pacman_conf = f.read().split("\n") pacman_conf = f.read().split("\n")
with pacman_conf_path.open("w") as fwrite: with pacman_conf_path.open("w") as fwrite:
for line in pacman_conf: for line in pacman_conf:
if "ParallelDownloads" in line: if "ParallelDownloads" in line:
fwrite.write(f"ParallelDownloads = {input_number+1}\n") if not input_number == 0 else fwrite.write("#ParallelDownloads = 0\n") fwrite.write(f"ParallelDownloads = {input_number+1}\n") if not input_number == 0 else fwrite.write("#ParallelDownloads = 0\n")
else: else:
fwrite.write(f"{line}\n") fwrite.write(f"{line}\n")
return input_number return input_number
def select_additional_repositories(preset: List[str]) -> List[str]: def select_additional_repositories(preset: List[str]) -> List[str]:
""" """
Allows the user to select additional repositories (multilib, and testing) if desired. Allows the user to select additional repositories (multilib, and testing) if desired.
:return: The string as a selected repository :return: The string as a selected repository
:rtype: string :rtype: string
""" """
repositories = ["multilib", "testing"] repositories = ["multilib", "testing"]
choice = Menu( choice = Menu(
_('Choose which optional additional repositories to enable'), _('Choose which optional additional repositories to enable'),
repositories, repositories,
sort=False, sort=False,
multi=True, multi=True,
preset_values=preset, preset_values=preset,
raise_error_on_interrupt=True raise_error_on_interrupt=True
).run() ).run()
# match choice.type_: # match choice.type_:
# case MenuSelectionType.Esc: return preset # case MenuSelectionType.Esc: return preset
# case MenuSelectionType.Ctrl_c: return [] # case MenuSelectionType.Ctrl_c: return []
# case MenuSelectionType.Selection: return choice.value # case MenuSelectionType.Selection: return choice.value
if choice.type_ == MenuSelectionType.Esc: if choice.type_ == MenuSelectionType.Esc:
return preset return preset
elif choice.type_ == MenuSelectionType.Ctrl_c: elif choice.type_ == MenuSelectionType.Ctrl_c:
return [] return []
elif choice.type_ == MenuSelectionType.Selection: elif choice.type_ == MenuSelectionType.Selection:
return choice.value return choice.value

View File

@ -93,7 +93,7 @@ def ask_user_questions():
will we continue with the actual installation steps. will we continue with the actual installation steps.
""" """
archinstall.SysCommand('local-install lvm aio') archinstall.SysCommand('local-install lvm2 aio')
partprobe() partprobe()
time.sleep(0.5) time.sleep(0.5)
# ref: https://github.com/archlinux/archinstall/pull/831 # ref: https://github.com/archlinux/archinstall/pull/831
@ -152,7 +152,6 @@ def ask_user_questions():
# Ask for preferred kernel: # Ask for preferred kernel:
# global_menu.enable('kernels') # global_menu.enable('kernels')
# global_menu.enable('packages')
# if archinstall.arguments.get('advanced', False): # if archinstall.arguments.get('advanced', False):
# # Enable parallel downloads # # Enable parallel downloads
@ -165,6 +164,8 @@ def ask_user_questions():
global_menu.enable("base_image") global_menu.enable("base_image")
global_menu.enable('packages')
# global_menu.enable('ntp') # global_menu.enable('ntp')
# global_menu.enable('additional-repositories') # global_menu.enable('additional-repositories')
@ -230,7 +231,7 @@ def install_grub(installation : archinstall.Installer, boot_dev_path: str):
# if archinstall.has_uefi(): # if archinstall.has_uefi():
# installation.log("Installing finish", level=logging.INFO) # installation.log("Installing finish", level=logging.INFO)
installation.log("Installing finish", level=logging.INFO) installation.log("Installing grub finish", level=logging.INFO)
def extract_rootfs(installation): def extract_rootfs(installation):
target = installation.target target = installation.target
@ -327,6 +328,32 @@ deb-src http://mirrors.huaweicloud.com/debian/ bullseye main
except SysCallError as error: except SysCallError as error:
installation.log(f"clear tmp failed: {error!r}", level=logging.WARN, fg="yellow") installation.log(f"clear tmp failed: {error!r}", level=logging.WARN, fg="yellow")
def install_packages(installation,additional_packages):
target = installation.target
if len(additional_packages) == 0:
return
try:
# install additional_packages package
installation.log("Installing additional_packages package, {}".format("..."), level=logging.INFO)
for key_name in additional_packages:
installation.log("Installing {} package...".format(key_name), level=logging.INFO)
if key_name == 'kde-plasma':
archinstall.SysCommand('chroot {} bash -c "dpkg -i /media/pool/other/plugins/{}/*.deb"'.format(target,'psmisc'))
time.sleep(0.1)
archinstall.SysCommand('chroot {} bash -c "dpkg -i /media/pool/other/plugins/{}/*.deb"'.format(target,key_name))
# change default dm
time.sleep(0.1)
archinstall.SysCommand('chroot {} bash -c "rm -rf /etc/systemd/system/display-manager.service"'.format(target))
archinstall.SysCommand('chroot {} bash -c "ln -s /lib/systemd/system/lightdm.service /etc/systemd/system/display-manager.service"'.format(target))
archinstall.SysCommand('chroot {} bash -c "mv /usr/share/xsessions/lightdm-xsession.desktop /usr/share/xsessions/qlightdm-xsession.desktop"'.format(target))
except SysCallError as error:
installation.log(f"additional_packages error: {error!r}", level=logging.ERROR, fg="red")
raise error
installation.log("Installing additional_packages finish.", level=logging.INFO)
installation.log("And The default startup session may not be KDE-Plasma DM, and you can modify it on the login page.", level=logging.INFO)
def perform_installation2(mountpoint): def perform_installation2(mountpoint):
with archinstall.Installer(mountpoint, kernels=archinstall.arguments.get('kernels', ['linux'])) as installation: with archinstall.Installer(mountpoint, kernels=archinstall.arguments.get('kernels', ['linux'])) as installation:
disk_layouts = None disk_layouts = None
@ -381,6 +408,10 @@ def perform_installation2(mountpoint):
# 6 do config # 6 do config
do_config(installation) do_config(installation)
# 7 install adational packages
if archinstall.arguments.get('base_image_develop',False):
addition_packages = archinstall.arguments.get('packages',[])
install_packages(installation,addition_packages)
input(str(_('Install finished, user:[acosail] password is [ ].\nPress Enter to reboot.'))) input(str(_('Install finished, user:[acosail] password is [ ].\nPress Enter to reboot.')))
reboot() reboot()
@ -656,6 +687,8 @@ if not archinstall.arguments.get('silent'):
ask_user_questions() ask_user_questions()
config_output = ConfigurationOutput(archinstall.arguments) config_output = ConfigurationOutput(archinstall.arguments)
# print("config_output===========>>>",archinstall.arguments)
# time.sleep(15)
if not archinstall.arguments.get('silent'): if not archinstall.arguments.get('silent'):
config_output.show() config_output.show()
config_output.save() config_output.save()