|
10 | 10 | from archinstall.lib.crypt import encrypt |
11 | 11 | from archinstall.lib.menu.helpers import Confirmation, Selection |
12 | 12 | from archinstall.lib.menu.util import get_password, prompt_dir |
| 13 | +from archinstall.lib.models.bootloader import Bootloader |
13 | 14 | from archinstall.lib.models.network import NetworkConfiguration |
14 | 15 | from archinstall.lib.output import debug, logger, warn |
15 | 16 | from archinstall.lib.translationhandler import tr |
@@ -59,6 +60,70 @@ def write_debug(self) -> None: |
59 | 60 | debug(' -- Chosen configuration --') |
60 | 61 | debug(self.user_config_to_json()) |
61 | 62 |
|
| 63 | + def as_summary(self) -> str: |
| 64 | + """ |
| 65 | + Render a concise two-column summary of the current configuration. |
| 66 | +
|
| 67 | + The left column holds section labels, the right column holds values. |
| 68 | + Column width adapts to the longest translated label so translations |
| 69 | + do not break the alignment. Rows whose underlying config is not set |
| 70 | + are skipped. |
| 71 | +
|
| 72 | + Returns an empty string if nothing meaningful to show. |
| 73 | + """ |
| 74 | + rows: list[tuple[str, str]] = [] |
| 75 | + |
| 76 | + disk_config = self._config.disk_config |
| 77 | + if disk_config and disk_config.device_modifications: |
| 78 | + disk_parts: list[str] = [] |
| 79 | + for mod in disk_config.device_modifications: |
| 80 | + path = str(mod.device_path) |
| 81 | + root_part = mod.get_root_partition() |
| 82 | + flags: list[str] = [] |
| 83 | + if root_part and root_part.fs_type: |
| 84 | + flags.append(root_part.fs_type.value) |
| 85 | + if disk_config.disk_encryption: |
| 86 | + flags.append(tr('LUKS')) |
| 87 | + disk_parts.append(f'{path} ({" + ".join(flags)})' if flags else path) |
| 88 | + rows.append((tr('Disks'), ', '.join(disk_parts))) |
| 89 | + |
| 90 | + bl_config = self._config.bootloader_config |
| 91 | + if bl_config and bl_config.bootloader != Bootloader.NO_BOOTLOADER: |
| 92 | + rows.append((tr('Bootloader'), bl_config.bootloader.value)) |
| 93 | + |
| 94 | + kernels = self._config.kernels |
| 95 | + if kernels: |
| 96 | + rows.append((tr('Kernel'), ', '.join(kernels))) |
| 97 | + |
| 98 | + profile_config = self._config.profile_config |
| 99 | + if profile_config and profile_config.profile: |
| 100 | + names = profile_config.profile.current_selection_names() |
| 101 | + rows.append((tr('Profile'), ', '.join(names) if names else profile_config.profile.name)) |
| 102 | + if profile_config.greeter: |
| 103 | + rows.append((tr('Greeter'), profile_config.greeter.value)) |
| 104 | + |
| 105 | + packages = self._config.packages |
| 106 | + if packages: |
| 107 | + rows.append((tr('Packages'), str(len(packages)))) |
| 108 | + |
| 109 | + net_config = self._config.network_config |
| 110 | + if isinstance(net_config, NetworkConfiguration): |
| 111 | + rows.append((tr('Network'), net_config.type.display_msg())) |
| 112 | + |
| 113 | + locale_config = self._config.locale_config |
| 114 | + if locale_config: |
| 115 | + rows.append((tr('Locale'), locale_config.sys_lang)) |
| 116 | + |
| 117 | + tz = self._config.timezone |
| 118 | + if tz: |
| 119 | + rows.append((tr('Timezone'), tz)) |
| 120 | + |
| 121 | + if not rows: |
| 122 | + return '' |
| 123 | + |
| 124 | + label_width = max(len(label) for label, _ in rows) + 2 |
| 125 | + return '\n'.join(f'{label:<{label_width}}{value}' for label, value in rows) |
| 126 | + |
62 | 127 | async def confirm_config(self, show_install_warnings: bool = False) -> bool: |
63 | 128 | header = f'{tr("The specified configuration will be applied")}. ' |
64 | 129 | header += tr('Would you like to continue?') + '\n' |
|
0 commit comments