Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--archinstall/lib/locale_helpers.py13
-rw-r--r--archinstall/lib/user_interaction.py34
-rw-r--r--examples/guided.py52
4 files changed, 59 insertions, 46 deletions
diff --git a/README.md b/README.md
index a48f0a91..6934b2d7 100644
--- a/README.md
+++ b/README.md
@@ -51,7 +51,7 @@ disk_password = getpass.getpass(prompt='Disk password (won\'t echo): ')
harddrive.keep_partitions = False
# First, we configure the basic filesystem layout
-with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) as fs:
+with archinstall.Filesystem(harddrive, archinstall.GPT) as fs:
# We create a filesystem layout that will use the entire drive
# (this is a helper function, you can partition manually as well)
fs.use_entire_disk(root_filesystem_type='btrfs')
@@ -61,9 +61,9 @@ with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT)
boot.format('vfat')
- # Set the flat for encrypted to allow for encryption and then encrypt
+ # Set the flag for encrypted to allow for encryption and then encrypt
root.encrypted = True
- root.encrypt(password=archinstall.arguments.get('!encryption-password', None))
+ root.encrypt(password=disk_password)
with archinstall.luks2(root, 'luksloop', disk_password) as unlocked_root:
unlocked_root.format(root.filesystem)
diff --git a/archinstall/lib/locale_helpers.py b/archinstall/lib/locale_helpers.py
index 82964dc9..736bfc47 100644
--- a/archinstall/lib/locale_helpers.py
+++ b/archinstall/lib/locale_helpers.py
@@ -4,27 +4,22 @@ import os
from .exceptions import *
# from .general import sys_command
-def list_keyboard_languages(layout='qwerty'):
+def list_keyboard_languages():
locale_dir = '/usr/share/kbd/keymaps/'
if not os.path.isdir(locale_dir):
raise RequirementError(f'Directory containing locales does not exist: {locale_dir}')
for root, folders, files in os.walk(locale_dir):
- # Since qwerty is under /i386/ but other layouts are
- # in different spots, we'll need to filter the last foldername
- # of the path to verify against the desired layout.
- if os.path.basename(root) != layout:
- continue
for file in files:
if os.path.splitext(file)[1] == '.gz':
yield file.strip('.gz').strip('.map')
-def search_keyboard_layout(filter, layout='qwerty'):
- for language in list_keyboard_languages(layout):
+def search_keyboard_layout(filter):
+ for language in list_keyboard_languages():
if filter.lower() in language.lower():
yield language
def set_keyboard_language(locale):
- return subprocess.call(['loadkeys',locale]) == 0
+ return subprocess.call(['loadkeys', locale]) == 0
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 99cf6274..838c69a2 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -323,6 +323,8 @@ def select_language(options, show_only_country_codes=True):
:return: The language/dictionary key of the selected language
:rtype: str
"""
+ DEFAULT_KEYBOARD_LANGUAGE = 'us'
+
if show_only_country_codes:
languages = sorted([language for language in list(options) if len(language) == 2])
else:
@@ -332,9 +334,12 @@ def select_language(options, show_only_country_codes=True):
for index, language in enumerate(languages):
print(f"{index}: {language}")
- print(' -- You can enter ? or help to search for more languages --')
+ print(' -- You can enter ? or help to search for more languages, or skip to use US layout --')
selected_language = input('Select one of the above keyboard languages (by number or full name): ')
- if selected_language.lower() in ('?', 'help'):
+
+ if len(selected_language.strip()) == 0:
+ return DEFAULT_KEYBOARD_LANGUAGE
+ elif selected_language.lower() in ('?', 'help'):
while True:
filter_string = input('Search for layout containing (example: "sv-"): ')
new_options = list(search_keyboard_layout(filter_string))
@@ -347,6 +352,7 @@ def select_language(options, show_only_country_codes=True):
elif selected_language.isdigit() and (pos := int(selected_language)) <= len(languages)-1:
selected_language = languages[pos]
+ return select_language
# I'm leaving "options" on purpose here.
# Since languages possibly contains a filtered version of
# all possible language layouts, and we might want to write
@@ -354,9 +360,9 @@ def select_language(options, show_only_country_codes=True):
# go through the search step.
elif selected_language in options:
selected_language = options[options.index(selected_language)]
+ return selected_language
else:
- RequirementError("Selected language does not exist.")
- return selected_language
+ raise RequirementError("Selected language does not exist.")
raise RequirementError("Selecting languages require a least one language to be given as an option.")
@@ -380,26 +386,26 @@ def select_mirror_regions(mirrors, show_top_mirrors=True):
selected_mirrors = {}
if len(regions) >= 1:
- print_large_list(regions, margin_bottom=2)
+ print_large_list(regions, margin_bottom=4)
print(' -- You can skip this step by leaving the option blank --')
selected_mirror = input('Select one of the above regions to download packages from (by number or full name): ')
if len(selected_mirror.strip()) == 0:
+ # Returning back empty options which can be both used to
+ # do "if x:" logic as well as do `x.get('mirror', {}).get('sub', None)` chaining
return {}
- elif selected_mirror.isdigit() and (pos := int(selected_mirror)) <= len(regions)-1:
+ elif selected_mirror.isdigit() and int(selected_mirror) <= len(regions)-1:
+ # I'm leaving "mirrors" on purpose here.
+ # Since region possibly contains a known region of
+ # all possible regions, and we might want to write
+ # for instance Sweden (if we know that exists) without having to
+ # go through the search step.
region = regions[int(selected_mirror)]
selected_mirrors[region] = mirrors[region]
- # I'm leaving "mirrors" on purpose here.
- # Since region possibly contains a known region of
- # all possible regions, and we might want to write
- # for instance Sweden (if we know that exists) without having to
- # go through the search step.
elif selected_mirror in mirrors:
selected_mirrors[selected_mirror] = mirrors[selected_mirror]
else:
- RequirementError("Selected region does not exist.")
+ raise RequirementError("Selected region does not exist.")
return selected_mirrors
-
- return None
diff --git a/examples/guided.py b/examples/guided.py
index fa644480..c0d22023 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -14,7 +14,12 @@ def ask_user_questions():
will we continue with the actual installation steps.
"""
if not archinstall.arguments.get('keyboard-language', None):
- archinstall.arguments['keyboard-language'] = archinstall.select_language(archinstall.list_keyboard_languages()).strip()
+ while True:
+ try:
+ archinstall.arguments['keyboard-language'] = 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.
@@ -23,7 +28,12 @@ def ask_user_questions():
# Set which region to download packages from during the installation
if not archinstall.arguments.get('mirror-region', None):
- archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors())
+ 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")
else:
selected_region = archinstall.arguments['mirror-region']
archinstall.arguments['mirror-region'] = {selected_region : archinstall.list_mirrors()[selected_region]}
@@ -178,19 +188,24 @@ def ask_user_questions():
archinstall.arguments['audio'] = None
# Additional packages (with some light weight error handling for invalid package names)
- if not archinstall.arguments.get('packages', None):
- print("Packages not part of the desktop environment are not installed by default.")
- print("If you desire a web browser, such as firefox or chromium, you may specify it in the following prompt.")
- archinstall.arguments['packages'] = [package for package in input('Write additional packages to install (space separated, leave blank to skip): ').split(' ') if len(package)]
-
- if len(archinstall.arguments['packages']):
- # Verify packages that were given
- try:
- archinstall.log(f"Verifying that additional packages exist (this might take a few seconds)")
- archinstall.validate_package_list(archinstall.arguments['packages'])
- except archinstall.RequirementError as e:
- archinstall.log(e, fg='red')
- exit(1)
+ while True:
+ if not archinstall.arguments.get('packages', None):
+ print("Only packages such as base, base-devel, linux, linux-firmware, efibootmgr and optional profile packages are installed.")
+ print("If you desire a web browser, such as firefox or chromium, you may specify it in the following prompt.")
+ archinstall.arguments['packages'] = [package for package in input('Write additional packages to install (space separated, leave blank to skip): ').split(' ') if len(package)]
+
+ if len(archinstall.arguments['packages']):
+ # Verify packages that were given
+ try:
+ archinstall.log(f"Verifying that additional packages exist (this might take a few seconds)")
+ archinstall.validate_package_list(archinstall.arguments['packages'])
+ break
+ except archinstall.RequirementError as e:
+ archinstall.log(e, fg='red')
+ archinstall.arguments['packages'] = None # Clear the packages to trigger a new input question
+ else:
+ # no additional packages were selected, which we'll allow
+ break
# Ask or Call the helper function that asks the user to optionally configure a network.
if not archinstall.arguments.get('nic', None):
@@ -287,11 +302,8 @@ def perform_installation(mountpoint):
if installation.minimal_installation():
installation.set_hostname(archinstall.arguments['hostname'])
-
- # Configure the selected mirrors in the installation
- if archinstall.arguments.get('mirror-region', None):
+ if archinstall.arguments['mirror-region'].get("mirrors",{})!= None:
installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium
-
installation.set_keyboard_language(archinstall.arguments['keyboard-language'])
installation.add_bootloader()
@@ -308,7 +320,7 @@ def perform_installation(mountpoint):
installation.enable_service('systemd-networkd')
installation.enable_service('systemd-resolved')
- if archinstall.arguments.get('audio', None) != None:
+ if archinstall.arguments.get('audio', None) != None:
installation.log(f"This audio server will be used: {archinstall.arguments.get('audio', None)}", level=archinstall.LOG_LEVELS.Info)
if archinstall.arguments.get('audio', None) == 'pipewire':
print('Installing pipewire ...')