Adding in partition layout structure

This commit is contained in:
Anton Hvornum 2021-05-06 15:18:57 +02:00
parent c20be61e12
commit 8925be6c87
2 changed files with 56 additions and 0 deletions

View File

@ -484,6 +484,48 @@ def generic_select(options, input_text="Select one of the above by index or abso
return selected_option
def select_partitions(block_devices :list):
return {
"/dev/sda": { # Block Device level
"wipe": False, # Safety flags
"partitions" : [ # Affected / New partitions
{
"PARTUUID" : "654bb317-1b73-4339-9a00-7222792f4ba9", # If existing partition
"wipe" : False, # Safety flags
"boot" : True, # Safety flags / new flags
"ESP" : True # Safety flags / new flags
}
]
},
"/dev/sdb" : {
"wipe" : True,
"partitions" : [
{
# No PARTUUID required here since it's a new partition
"type" : "primary", # parted options
"size" : "100%",
"filesystem" : {
"encrypted" : True, # TODO: Not sure about this here
"format": "btrfs", # mkfs options
}
}
]
}
}
def select_disk_layout(block_devices :list):
modes = [
"Wipe all selected drives and use a best-effort default partition layout",
"Select which partitions to use (and what to do with them)"
]
mode = input("Do you wish to ")
if mode == 'Select which partitions to use (and what to do with them)':
return select_partitions(block_devices)
else:
return get_default_partition_layout(block_devices)
def select_disk(dict_o_disks):
"""
Asks the user to select a harddrive from the `dict_o_disks` selection.

View File

@ -24,11 +24,13 @@ def ask_user_questions():
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-language']):
archinstall.set_keyboard_language(archinstall.arguments['keyboard-language'])
# Set which region to download packages from during the installation
if not archinstall.arguments.get('mirror-region', None):
while True:
@ -56,20 +58,27 @@ def ask_user_questions():
if archinstall.arguments.get('harddrives', None):
archinstall.storage['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives'])
# 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
# Ask which boot-loader to use (will only ask if we're in BIOS (non-efi) mode)
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)
archinstall.arguments['users'] = {}
archinstall.arguments['superusers'] = {}
@ -80,12 +89,14 @@ def ask_user_questions():
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(archinstall.list_profiles(filter_top_level_profiles=True))
else:
archinstall.arguments['profile'] = archinstall.list_profiles()[archinstall.arguments['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:
@ -96,6 +107,7 @@ def ask_user_questions():
)
exit(1)
# Ask about audio server selection if one is not already set
if not archinstall.arguments.get('audio', None):
# only ask for audio server selection on a desktop profile
@ -106,11 +118,13 @@ def ask_user_questions():
# we will not try to remove packages post-installation to not have audio, as that may cause multiple issues
archinstall.arguments['audio'] = None
# Ask for preferred kernel:
if not archinstall.arguments.get("kernels", None):
kernels = ["linux", "linux-lts", "linux-zen", "linux-hardened"]
archinstall.arguments['kernels'] = archinstall.select_kernel(kernels)
# Additional packages (with some light weight error handling for invalid package names)
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.")