Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion archinstall/lib/authentication/authentication_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _define_menu_options(self) -> list[MenuItem]:

def _create_user_account(self, preset: list[User] | None = None) -> list[User]:
preset = [] if preset is None else preset
users = ask_for_additional_users(defined_users=preset)
users = ask_for_additional_users(preset=preset)
return users

def _prev_users(self, item: MenuItem) -> str | None:
Expand Down
18 changes: 14 additions & 4 deletions archinstall/lib/disk/partitioning_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,12 @@ def as_segments(self, device_partitions: list[PartitionModification]) -> list[Di
def get_part_mods(disk_segments: list[DiskSegment]) -> list[PartitionModification]:
return [s.segment for s in disk_segments if isinstance(s.segment, PartitionModification)]

def get_device_mod(self) -> DeviceModification:
def show(self) -> DeviceModification | None:
disk_segments = super().run()

if not disk_segments:
return None

partitions = self.get_part_mods(disk_segments)
return DeviceModification(self._device, self._wipe, partitions)

Expand Down Expand Up @@ -376,10 +380,13 @@ def _toggle_mount_option(
partition.mount_options = [o for o in partition.mount_options if o != option.value]

def _set_btrfs_subvolumes(self, partition: PartitionModification) -> None:
partition.btrfs_subvols = SubvolumeMenu(
subvols = SubvolumeMenu(
partition.btrfs_subvols,
None,
).run()
).show()

if subvols is not None:
partition.btrfs_subvols = subvols

def _prompt_formatting(self, partition: PartitionModification) -> None:
# an existing partition can toggle between Exist or Modify
Expand Down Expand Up @@ -569,7 +576,10 @@ def manual_partitioning(
partition_table: PartitionTable,
) -> DeviceModification | None:
menu_list = PartitioningList(device_mod, partition_table)
mod = menu_list.get_device_mod()
mod = menu_list.show()

if not mod:
return None

if menu_list.is_last_choice_cancel():
return device_mod
Expand Down
3 changes: 3 additions & 0 deletions archinstall/lib/disk/subvolume_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def __init__(
prompt,
)

def show(self) -> list[SubvolumeModification] | None:
return super().run()

@override
def selected_action_display(self, selection: SubvolumeModification) -> str:
return str(selection.name)
Expand Down
27 changes: 17 additions & 10 deletions archinstall/lib/interactions/disk_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,20 @@ def get_default_partition_layout(
def _manual_partitioning(
preset: list[DeviceModification],
devices: list[BDevice],
) -> list[DeviceModification]:
modifications = []
) -> list[DeviceModification] | None:
modifications: list[DeviceModification] = []

for device in devices:
mod = next(filter(lambda x: x.device == device, preset), None)
if not mod:
mod = DeviceModification(device, wipe=False)

if device_mod := manual_partitioning(mod, device_handler.partition_table):
modifications.append(device_mod)
device_mod = manual_partitioning(mod, device_handler.partition_table)

if not device_mod:
return None

modifications.append(device_mod)

return modifications

Expand Down Expand Up @@ -191,13 +196,15 @@ def select_disk_config(preset: DiskLayoutConfiguration | None = None) -> DiskLay
)
elif result.get_value() == manual_mode:
preset_mods = preset.device_modifications if preset else []
modifications = _manual_partitioning(preset_mods, devices)
partitions = _manual_partitioning(preset_mods, devices)

if modifications:
return DiskLayoutConfiguration(
config_type=DiskLayoutType.Manual,
device_modifications=modifications,
)
if not partitions:
return preset

return DiskLayoutConfiguration(
config_type=DiskLayoutType.Manual,
device_modifications=partitions,
)

return None

Expand Down
11 changes: 9 additions & 2 deletions archinstall/lib/interactions/manage_users_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def __init__(self, prompt: str, lusers: list[User]):
prompt,
)

def show(self) -> list[User] | None:
return super().run()

@override
def selected_action_display(self, selection: User) -> str:
return selection.username
Expand Down Expand Up @@ -106,6 +109,10 @@ def _add_user(self) -> User | None:
return User(username, password, sudo)


def ask_for_additional_users(prompt: str = '', defined_users: list[User] = []) -> list[User]:
users = UserList(prompt, defined_users).run()
def ask_for_additional_users(prompt: str = '', preset: list[User] = []) -> list[User]:
users = UserList(prompt, preset).show()

if users is None:
return preset

return users
5 changes: 4 additions & 1 deletion archinstall/lib/interactions/network_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def __init__(self, prompt: str, preset: list[Nic]):
prompt,
)

def show(self) -> list[Nic] | None:
return super().run()

@override
def selected_action_display(self, selection: Nic) -> str:
return selection.iface if selection.iface else ''
Expand Down Expand Up @@ -198,7 +201,7 @@ def ask_to_configure_network(preset: NetworkConfiguration | None) -> NetworkConf
return NetworkConfiguration(NicType.NM_IWD)
case NicType.MANUAL:
preset_nics = preset.nics if preset else []
nics = ManualNetworkConfig(tr('Configure interfaces'), preset_nics).run()
nics = ManualNetworkConfig(tr('Configure interfaces'), preset_nics).show()

if nics:
return NetworkConfiguration(NicType.MANUAL, nics)
Expand Down
5 changes: 2 additions & 3 deletions archinstall/lib/menu/list_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def __init__(
:param sub_menu_actions: list of actions available for a chosen entry
type param: list
"""
self._original_data = copy.deepcopy(entries)
self._data = copy.deepcopy(entries)

self._prompt = prompt
Expand All @@ -54,7 +53,7 @@ def is_last_choice_cancel(self) -> bool:
return self._last_choice == self._cancel_action
return False

def run(self) -> list[ValueT]:
def run(self) -> list[ValueT] | None:
additional_options = self._base_actions + self._terminate_actions

while True:
Expand Down Expand Up @@ -94,7 +93,7 @@ def run(self) -> list[ValueT]:
self._last_choice = value

if result.get_value() == self._cancel_action:
return self._original_data # return the original list
return None
else:
return self._data

Expand Down
18 changes: 16 additions & 2 deletions archinstall/lib/mirrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def __init__(self, custom_repositories: list[CustomRepository]):
'',
)

def show(self) -> list[CustomRepository] | None:
return super().run()

@override
def selected_action_display(self, selection: CustomRepository) -> str:
return selection.name
Expand Down Expand Up @@ -158,6 +161,9 @@ def __init__(self, custom_servers: list[CustomServer]):
'',
)

def show(self) -> list[CustomServer] | None:
return super().run()

@override
def selected_action_display(self, selection: CustomServer) -> str:
return selection.url
Expand Down Expand Up @@ -332,12 +338,20 @@ def select_mirror_regions(preset: list[MirrorRegion]) -> list[MirrorRegion]:


def add_custom_mirror_servers(preset: list[CustomServer] = []) -> list[CustomServer]:
custom_mirrors = CustomMirrorServersList(preset).run()
custom_mirrors = CustomMirrorServersList(preset).show()

if not custom_mirrors:
return preset

return custom_mirrors


def select_custom_mirror(preset: list[CustomRepository] = []) -> list[CustomRepository]:
custom_mirrors = CustomMirrorRepositoriesList(preset).run()
custom_mirrors = CustomMirrorRepositoriesList(preset).show()

if not custom_mirrors:
return preset

return custom_mirrors


Expand Down