Renamed keyboard-language to keyboard-layout to avoid confusion. Added encryption checks for disk layout selection, if disk encryption password is given - but no partitions were found using encryption, the user will be asked which partitions to encrypt - unless there's only /boot and /<root> then we'll automatically select /<root> because that's what we support for now.
This commit is contained in:
parent
e6c28a94ee
commit
129ceaea8b
|
|
@ -731,3 +731,13 @@ def disk_layouts():
|
||||||
except SysCallError as err:
|
except SysCallError as err:
|
||||||
log(f"Could not return disk layouts: {err}")
|
log(f"Could not return disk layouts: {err}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def encrypted_partitions(blockdevices :dict) -> bool:
|
||||||
|
for partition in blockdevices.values():
|
||||||
|
if partition.get('encrypted', False):
|
||||||
|
yield partition
|
||||||
|
|
||||||
|
def find_partition_by_mountpoint(partitions, relative_mountpoint :str):
|
||||||
|
for partition in partitions:
|
||||||
|
if partition.get('mountpoint', None) == relative_mountpoint:
|
||||||
|
return partition
|
||||||
|
|
@ -150,6 +150,20 @@ def generic_multi_select(options, text="Select one or more of the options above
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
return selected_options
|
return selected_options
|
||||||
|
|
||||||
|
def select_encrypted_partitions(blockdevices :dict) -> dict:
|
||||||
|
print(blockdevices[0])
|
||||||
|
|
||||||
|
if len(blockdevices) == 1:
|
||||||
|
if len(blockdevices[0]['partitions']) == 2:
|
||||||
|
root = find_partition_by_mountpoint(blockdevices[0]['partitions'], '/')
|
||||||
|
blockdevices[0]['partitions'][root]['encrypted'] = True
|
||||||
|
return True
|
||||||
|
|
||||||
|
options = []
|
||||||
|
for partition in blockdevices.values():
|
||||||
|
options.append({key: val for key, val in partition.items() if val})
|
||||||
|
|
||||||
|
print(generic_multi_select(options, f"Choose which partitions to encrypt (leave blank when done): "))
|
||||||
|
|
||||||
class MiniCurses():
|
class MiniCurses():
|
||||||
def __init__(self, width, height):
|
def __init__(self, width, height):
|
||||||
|
|
@ -594,7 +608,7 @@ def wipe_and_create_partitions(block_device):
|
||||||
else:
|
else:
|
||||||
partition_type = 'msdos'
|
partition_type = 'msdos'
|
||||||
|
|
||||||
partitions_result = [part.__dump__() for part in block_device.partitions.values()]
|
partitions_result = [] # Test code: [part.__dump__() for part in block_device.partitions.values()]
|
||||||
suggested_layout = [
|
suggested_layout = [
|
||||||
{ # Boot
|
{ # Boot
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ def ask_user_questions():
|
||||||
Not until we're satisfied with what we want to install
|
Not until we're satisfied with what we want to install
|
||||||
will we continue with the actual installation steps.
|
will we continue with the actual installation steps.
|
||||||
"""
|
"""
|
||||||
if not archinstall.arguments.get('keyboard-language', None):
|
if not archinstall.arguments.get('keyboard-layout', None):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
archinstall.arguments['keyboard-language'] = archinstall.select_language(archinstall.list_keyboard_languages()).strip()
|
archinstall.arguments['keyboard-layout'] = archinstall.select_language(archinstall.list_keyboard_languages()).strip()
|
||||||
break
|
break
|
||||||
except archinstall.RequirementError as err:
|
except archinstall.RequirementError as err:
|
||||||
archinstall.log(err, fg="red")
|
archinstall.log(err, fg="red")
|
||||||
|
|
@ -27,8 +27,8 @@ def ask_user_questions():
|
||||||
|
|
||||||
# Before continuing, set the preferred keyboard layout/language in the current terminal.
|
# Before continuing, set the preferred keyboard layout/language in the current terminal.
|
||||||
# This will just help the user with the next following questions.
|
# This will just help the user with the next following questions.
|
||||||
if len(archinstall.arguments['keyboard-language']):
|
if len(archinstall.arguments['keyboard-layout']):
|
||||||
archinstall.set_keyboard_language(archinstall.arguments['keyboard-language'])
|
archinstall.set_keyboard_language(archinstall.arguments['keyboard-layout'])
|
||||||
|
|
||||||
|
|
||||||
# Set which region to download packages from during the installation
|
# Set which region to download packages from during the installation
|
||||||
|
|
@ -64,6 +64,11 @@ def ask_user_questions():
|
||||||
if (passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): ')):
|
if (passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): ')):
|
||||||
archinstall.arguments['!encryption-password'] = passwd
|
archinstall.arguments['!encryption-password'] = passwd
|
||||||
|
|
||||||
|
# If no partitions was marked as encrypted (rare), but a password was supplied -
|
||||||
|
# then we need to identify which partitions to encrypt. This will default to / (root) if only
|
||||||
|
# root and boot are detected.
|
||||||
|
if len(list(archinstall.encrypted_partitions(archinstall.storage['disk_layouts']))) == 0:
|
||||||
|
archinstall.storage['disk_layouts'] = archinstall.select_encrypted_partitions(archinstall.storage['disk_layouts'])
|
||||||
|
|
||||||
# Ask which boot-loader to use (will only ask if we're in BIOS (non-efi) mode)
|
# Ask which boot-loader to use (will only ask if we're in BIOS (non-efi) mode)
|
||||||
archinstall.arguments["bootloader"] = archinstall.ask_for_bootloader()
|
archinstall.arguments["bootloader"] = archinstall.ask_for_bootloader()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue