예제 #1
0
def ask_user_questions():
    """
        First, we'll ask the user for a bunch of user input.
        Not until we're satisfied with what we want to install
        will we continue with the actual installation steps.
    """
    if not archinstall.arguments.get('keyboard-layout', None):
        while True:
            try:
                archinstall.arguments['keyboard-layout'] = archinstall.select_language(archinstall.list_keyboard_languages()).strip()
                break
            except archinstall.RequirementError as err:
                archinstall.log(err, fg="red")

    # Before continuing, set the preferred keyboard layout/language in the current terminal.
    # This will just help the user with the next following questions.
    if len(archinstall.arguments['keyboard-layout']):
        archinstall.set_keyboard_language(archinstall.arguments['keyboard-layout'])

    # Set which region to download packages from during the installation
    if not archinstall.arguments.get('mirror-region', None):
        while True:
            try:
                archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors())
                break
            except archinstall.RequirementError as e:
                archinstall.log(e, fg="red")

    if not archinstall.arguments.get('sys-language', None) and archinstall.arguments.get('advanced', False):
        archinstall.arguments['sys-language'] = input("Enter a valid locale (language) for your OS, (Default: en_US): ").strip()
        archinstall.arguments['sys-encoding'] = input("Enter a valid system default encoding for your OS, (Default: utf-8): ").strip()
        archinstall.log("Keep in mind that if you want multiple locales, post configuration is required.", fg="yellow")

    if not archinstall.arguments.get('sys-language', None):
        archinstall.arguments['sys-language'] = 'en_US'
    if not archinstall.arguments.get('sys-encoding', None):
        archinstall.arguments['sys-encoding'] = 'utf-8'

    # Ask which harddrives/block-devices we will install to
    # and convert them into archinstall.BlockDevice() objects.
    if archinstall.arguments.get('harddrives', None) is None:
        _prompt = "Select one or more harddrives to use and configure (leave blank to skip this step): "
        archinstall.arguments['harddrives'] = archinstall.generic_multi_select(archinstall.all_disks(), text=_prompt, allow_empty=True)

    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'], archinstall.arguments.get('advanced', False))

    # Get disk encryption password (or skip if blank)
    if archinstall.arguments['harddrives'] and archinstall.arguments.get('!encryption-password', None) is None:
        if passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): '):
            archinstall.arguments['!encryption-password'] = passwd
예제 #2
0
def ask_harddrives():
    # Ask which harddrives/block-devices we will install to
    # and convert them into archinstall.BlockDevice() objects.
    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 not archinstall.arguments['harddrives']:
        archinstall.log("You decided to skip harddrive selection",
                        fg="red",
                        level=logging.INFO)
        archinstall.log(
            f"and will use whatever drive-setup is mounted at {archinstall.storage['MOUNT_POINT']} (experimental)",
            fg="red",
            level=logging.INFO)
        archinstall.log(
            "WARNING: Archinstall won't check the suitability of this setup",
            fg="red",
            level=logging.INFO)
        if input("Do you wish to continue ? [Y/n]").strip().lower() == 'n':
            exit(1)
    else:
        if archinstall.storage.get('disk_layouts', None) is None:
            archinstall.storage[
                'disk_layouts'] = archinstall.select_disk_layout(
                    archinstall.arguments['harddrives'],
                    archinstall.arguments.get('advanced', False))

        # Get disk encryption password (or skip if blank)
        if archinstall.arguments.get('!encryption-password', None) is None:
            if passwd := archinstall.get_password(
                    prompt=
                    'Enter disk encryption password (leave blank for no encryption): '
            ):
                archinstall.arguments['!encryption-password'] = passwd

        if archinstall.arguments.get('!encryption-password', None):
            # If no partitions was marked as encrypted, but a password was supplied and we have some disks to format..
            # Then we need to identify which partitions to encrypt. This will default to / (root).
            if len(
                    list(
                        archinstall.encrypted_partitions(
                            archinstall.storage['disk_layouts']))) == 0:
                archinstall.storage[
                    'disk_layouts'] = archinstall.select_encrypted_partitions(
                        archinstall.storage['disk_layouts'],
                        archinstall.arguments['!encryption-password'])
예제 #3
0
    def _set_root_password(self):
        prompt = 'Enter root password (leave blank to disable root & create superuser): '
        password = archinstall.get_password(prompt=prompt)

        if password is not None:
            self._menu_options.get('!superusers').set_current_selection(None)
            archinstall.arguments['!users'] = {}
            archinstall.arguments['!superusers'] = {}

        return password
예제 #4
0
            archinstall.log('Using existing partition table reported above.')
        elif option == 'format-all':
            archinstall.arguments[
                'filesystem'] = archinstall.ask_for_main_filesystem_format()
            archinstall.arguments['harddrive'].keep_partitions = False
    else:
        # If the drive doesn't have any partitions, safely mark the disk with keep_partitions = False
        # and ask the user for a root filesystem.
        archinstall.arguments[
            'filesystem'] = archinstall.ask_for_main_filesystem_format()
        archinstall.arguments['harddrive'].keep_partitions = False

    # Get disk encryption password (or skip if blank)
    if not archinstall.arguments.get('!encryption-password', None):
        if (passwd := archinstall.get_password(
                prompt=
                'Enter disk encryption password (leave blank for no encryption): '
        )):
            archinstall.arguments['!encryption-password'] = passwd
            archinstall.arguments[
                'harddrive'].encryption_password = archinstall.arguments[
                    '!encryption-password']

    # Get the hostname for the machine
    if not archinstall.arguments.get('hostname', None):
        archinstall.arguments['hostname'] = input(
            'Desired hostname for the installation: ').strip(' ')

    # Ask for a root password (optional, but triggers requirement for super-user if skipped)
    if not archinstall.arguments.get('!root-password', None):
        archinstall.arguments['!root-password'] = archinstall.get_password(
            prompt=
예제 #5
0
파일: guided.py 프로젝트: kevr/archinstall
                    archinstall.storage['disk_layouts'],
                    archinstall.arguments['!encryption-password'])

    # Ask which boot-loader to use (will only ask if we're in BIOS (non-efi) mode)
    if not archinstall.arguments.get("bootloader", None):
        archinstall.arguments["bootloader"] = archinstall.ask_for_bootloader()

    # Get the hostname for the machine
    if not archinstall.arguments.get('hostname', None):
        archinstall.arguments['hostname'] = input(
            'Desired hostname for the installation: ').strip(' ')

    # Ask for a root password (optional, but triggers requirement for super-user if skipped)
    if not archinstall.arguments.get('!root-password', None):
        archinstall.arguments['!root-password'] = archinstall.get_password(
            prompt=
            'Enter root password (Recommendation: leave blank to leave root disabled): '
        )

    # Ask for additional users (super-user if root pw was not set)
    if not archinstall.arguments.get('!root-password',
                                     None) and not archinstall.arguments.get(
                                         'superusers', None):
        archinstall.arguments[
            'superusers'] = archinstall.ask_for_superuser_account(
                'Create a required super-user with sudo privileges: ',
                forced=True)
        users, superusers = archinstall.ask_for_additional_users(
            'Enter a username to create a additional user (leave blank to skip & continue): '
        )
        archinstall.arguments['users'] = users
        archinstall.arguments['superusers'] = {
예제 #6
0
            archinstall.storage['disk_layouts'] = archinstall.select_encrypted_partitions(archinstall.storage['disk_layouts'], archinstall.arguments['!encryption-password'])

    # Ask which boot-loader to use (will only ask if we're in BIOS (non-efi) mode)
    if not archinstall.arguments.get("bootloader", None):
        archinstall.arguments["bootloader"] = archinstall.ask_for_bootloader(archinstall.arguments.get('advanced', False))

    if not archinstall.arguments.get('swap', None):
        archinstall.arguments['swap'] = archinstall.ask_for_swap()

    # Get the hostname for the machine
    if not archinstall.arguments.get('hostname', None):
        archinstall.arguments['hostname'] = input('Desired hostname for the installation: ').strip(' ')

    # Ask for a root password (optional, but triggers requirement for super-user if skipped)
    if not archinstall.arguments.get('!root-password', None):
        archinstall.arguments['!root-password'] = archinstall.get_password(prompt='Enter root password (leave blank to disable root & create superuser): ')

    # Ask for additional users (super-user if root pw was not set)
    if not archinstall.arguments.get('!root-password', None) and not archinstall.arguments.get('!superusers', None):
        archinstall.arguments['!superusers'] = archinstall.ask_for_superuser_account('Create a required super-user with sudo privileges: ', forced=True)
        users, superusers = archinstall.ask_for_additional_users('Enter a username to create an additional user (leave blank to skip & continue): ')
        archinstall.arguments['!users'] = users
        archinstall.arguments['!superusers'] = {**archinstall.arguments['!superusers'], **superusers}

    # Ask for archinstall-specific profiles (such as desktop environments etc)
    if not archinstall.arguments.get('profile', None):
        archinstall.arguments['profile'] = archinstall.select_profile()

    # Check the potentially selected profiles preparations to get early checks if some additional questions are needed.
    if archinstall.arguments['profile'] and archinstall.arguments['profile'].has_prep_function():
        with archinstall.arguments['profile'].load_instructions(namespace=f"{archinstall.arguments['profile'].namespace}.py") as imported:
예제 #7
0
 def _setup_selection_menu_options(self):
     self._menu_options['keyboard-layout'] = \
      Selector('Select keyboard layout', lambda: archinstall.select_language('us'), default='us')
     self._menu_options['mirror-region'] = \
      Selector(
       'Select mirror region',
       lambda: archinstall.select_mirror_regions(),
       display_func=lambda x: list(x.keys()) if x else '[]',
       default={})
     self._menu_options['sys-language'] = \
      Selector('Select locale language', lambda: archinstall.select_locale_lang('en_US'), default='en_US')
     self._menu_options['sys-encoding'] = \
      Selector('Select locale encoding', lambda: archinstall.select_locale_enc('utf-8'), default='utf-8')
     self._menu_options['harddrives'] = \
      Selector(
       'Select harddrives',
       lambda: self._select_harddrives())
     self._menu_options['disk_layouts'] = \
      Selector(
       'Select disk layout',
       lambda: archinstall.select_disk_layout(
        archinstall.arguments['harddrives'],
        archinstall.arguments.get('advanced', False)
       ),
       dependencies=['harddrives'])
     self._menu_options['!encryption-password'] = \
      Selector(
       'Set encryption password',
       lambda: archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): '),
       display_func=lambda x: self._secret(x) if x else 'None',
       dependencies=['harddrives'])
     self._menu_options['swap'] = \
      Selector(
       'Use swap',
       lambda: archinstall.ask_for_swap(),
       default=True)
     self._menu_options['bootloader'] = \
      Selector(
       'Select bootloader',
       lambda: archinstall.ask_for_bootloader(archinstall.arguments.get('advanced', False)),)
     self._menu_options['hostname'] = \
      Selector('Specify hostname', lambda: archinstall.ask_hostname())
     self._menu_options['!root-password'] = \
      Selector(
       'Set root password',
       lambda: self._set_root_password(),
       display_func=lambda x: self._secret(x) if x else 'None')
     self._menu_options['!superusers'] = \
      Selector(
       'Specify superuser account',
       lambda: 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(),
       default={},
       display_func=lambda x: list(x.keys()) if x else '[]')
     self._menu_options['profile'] = \
      Selector(
       'Specify profile',
       lambda: self._select_profile(),
       display_func=lambda x: x if x else 'None')
     self._menu_options['audio'] = \
      Selector(
       'Select audio',
       lambda: archinstall.ask_for_audio_selection(archinstall.is_desktop_profile(archinstall.arguments.get('profile', None))))
     self._menu_options['kernels'] = \
      Selector(
       'Select kernels',
       lambda: archinstall.select_kernel(),
       default='linux')
     self._menu_options['packages'] = \
      Selector(
       'Additional packages to install',
       lambda: archinstall.ask_additional_packages_to_install(archinstall.arguments.get('packages', None)),
       default=[])
     self._menu_options['nic'] = \
      Selector(
       'Configure network',
       lambda: archinstall.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: archinstall.ask_for_a_timezone())
     self._menu_options['ntp'] = \
      Selector(
       'Set automatic time sync (NTP)',
       lambda: archinstall.ask_ntp(),
       default=True)
     self._menu_options['install'] = \
      Selector(
       self._install_text(),
       enabled=True)
     self._menu_options['abort'] = Selector('Abort', enabled=True)