Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/user_interaction.py
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/user_interaction.py')
-rw-r--r--archinstall/lib/user_interaction.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index e462c370..80db7be1 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -24,6 +24,10 @@ def get_password(prompt="Enter a password: "):
if passwd != passwd_verification:
log(' * Passwords did not match * ', bg='black', fg='red')
continue
+
+ if len(passwd.strip()) <= 0:
+ break
+
return passwd
return None
@@ -77,8 +81,14 @@ def ask_for_additional_users(prompt='Any additional users to install (leave blan
def ask_for_a_timezone():
timezone = input('Enter a valid timezone (Example: Europe/Stockholm): ').strip()
- if pathlib.Path(timezone).exists():
+ if (pathlib.Path("/usr")/"share"/"zoneinfo"/timezone).exists():
return timezone
+ else:
+ log(
+ f"Time zone {timezone} does not exist, continuing with system default.",
+ level=LOG_LEVELS.Warning,
+ fg='red'
+ )
def ask_to_configure_network():
# Optionally configure one network interface.
@@ -135,7 +145,7 @@ def ask_for_main_filesystem_format():
'f2fs' : 'f2fs'
}
- value = generic_select(options.values(), "Select which filesystem your main partition should use (by number of name): ")
+ value = generic_select(options.values(), "Select which filesystem your main partition should use (by number or name): ")
return next((key for key, val in options.items() if val == value), None)
def generic_select(options, input_text="Select one of the above by index or absolute value: ", sort=True):
@@ -160,7 +170,10 @@ def generic_select(options, input_text="Select one of the above by index or abso
if len(selected_option.strip()) <= 0:
return None
elif selected_option.isdigit():
- selected_option = options[int(selected_option)]
+ selected_option = int(selected_option)
+ if selected_option >= len(options):
+ raise RequirementError(f'Selected option "{selected_option}" is out of range')
+ selected_option = options[selected_option]
elif selected_option in options:
pass # We gave a correct absolute value
else:
@@ -185,7 +198,10 @@ def select_disk(dict_o_disks):
print(f"{index}: {drive} ({dict_o_disks[drive]['size'], dict_o_disks[drive].device, dict_o_disks[drive]['label']})")
drive = input('Select one of the above disks (by number or full path): ')
if drive.isdigit():
- drive = dict_o_disks[drives[int(drive)]]
+ drive = int(drive)
+ if drive >= len(drives):
+ raise DiskError(f'Selected option "{drive}" is out of range')
+ drive = dict_o_disks[drives[drive]]
elif drive in dict_o_disks:
drive = dict_o_disks[drive]
else: