Skip to content

Commit 2f18b8d

Browse files
authored
Fix 1747 | Additional post-installation menu options (#3393)
* Provide more post installation options * Update
1 parent 130d1a6 commit 2f18b8d

3 files changed

Lines changed: 46 additions & 25 deletions

File tree

archinstall/lib/interactions/general_conf.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from enum import Enum
34
from pathlib import Path
45
from typing import TYPE_CHECKING, assert_never
56

@@ -24,6 +25,12 @@
2425
_: Callable[[str], DeferredTranslation]
2526

2627

28+
class PostInstallationAction(Enum):
29+
EXIT = str(_('Exit archinstall'))
30+
REBOOT = str(_('Reboot system'))
31+
CHROOT = str(_('chroot into installation for post-installation configurations'))
32+
33+
2734
def ask_ntp(preset: bool = True) -> bool:
2835
header = str(_('Would you like to use automatic time synchronization (NTP) with the default time servers?\n')) + '\n'
2936
header += str(_(
@@ -281,19 +288,25 @@ def validator(s: str) -> str | None:
281288
return downloads
282289

283290

284-
def ask_chroot() -> bool:
285-
prompt = str(_('Would you like to chroot into the newly created installation and perform post-installation configuration?')) + '\n'
286-
group = MenuItemGroup.yes_no()
291+
def ask_post_installation() -> PostInstallationAction:
292+
header = str(_('Installation completed')) + '\n\n'
293+
header += str(_('What would you like to do next?')) + '\n'
294+
295+
items = [MenuItem(action.value, value=action) for action in PostInstallationAction]
296+
group = MenuItemGroup(items)
287297

288298
result = SelectMenu(
289299
group,
290-
header=prompt,
300+
header=header,
301+
allow_skip=False,
291302
alignment=Alignment.CENTER,
292-
columns=2,
293-
orientation=Orientation.HORIZONTAL,
294303
).run()
295304

296-
return result.item() == MenuItem.yes()
305+
match result.type_:
306+
case ResultType.Selection:
307+
return result.get_value()
308+
case _:
309+
raise ValueError('Post installation action not handled')
297310

298311

299312
def ask_abort() -> None:

archinstall/scripts/guided.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from pathlib import Path
23

34
from archinstall import SysInfo
@@ -7,7 +8,7 @@
78
from archinstall.lib.disk.utils import disk_layouts
89
from archinstall.lib.global_menu import GlobalMenu
910
from archinstall.lib.installer import Installer, accessibility_tools_in_use, run_custom_user_commands
10-
from archinstall.lib.interactions.general_conf import ask_chroot
11+
from archinstall.lib.interactions.general_conf import PostInstallationAction, ask_post_installation
1112
from archinstall.lib.models import AudioConfiguration, Bootloader
1213
from archinstall.lib.models.device_model import (
1314
DiskLayoutConfiguration,
@@ -147,19 +148,22 @@ def perform_installation(mountpoint: Path) -> None:
147148

148149
installation.genfstab()
149150

150-
info("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation")
151+
debug(f"Disk states after installing:\n{disk_layouts()}")
151152

152153
if not arch_config_handler.args.silent:
153154
with Tui():
154-
chroot = ask_chroot()
155+
action = ask_post_installation()
155156

156-
if chroot:
157-
try:
158-
installation.drop_to_shell()
159-
except Exception:
157+
match action:
158+
case PostInstallationAction.EXIT:
160159
pass
161-
162-
debug(f"Disk states after installing:\n{disk_layouts()}")
160+
case PostInstallationAction.REBOOT:
161+
os.system('reboot')
162+
case PostInstallationAction.CHROOT:
163+
try:
164+
installation.drop_to_shell()
165+
except Exception:
166+
pass
163167

164168

165169
def guided() -> None:

examples/interactive_installation.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from pathlib import Path
23

34
from archinstall import SysInfo, debug, error, info
@@ -7,7 +8,7 @@
78
from archinstall.lib.disk.utils import disk_layouts
89
from archinstall.lib.global_menu import GlobalMenu
910
from archinstall.lib.installer import Installer, accessibility_tools_in_use, run_custom_user_commands
10-
from archinstall.lib.interactions.general_conf import ask_chroot
11+
from archinstall.lib.interactions.general_conf import PostInstallationAction, ask_post_installation
1112
from archinstall.lib.models import AudioConfiguration, Bootloader
1213
from archinstall.lib.models.device_model import (
1314
DiskLayoutConfiguration,
@@ -146,19 +147,22 @@ def perform_installation(mountpoint: Path) -> None:
146147

147148
installation.genfstab()
148149

149-
info("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation")
150+
debug(f"Disk states after installing:\n{disk_layouts()}")
150151

151152
if not arch_config_handler.args.silent:
152153
with Tui():
153-
chroot = ask_chroot()
154+
action = ask_post_installation()
154155

155-
if chroot:
156-
try:
157-
installation.drop_to_shell()
158-
except Exception:
156+
match action:
157+
case PostInstallationAction.EXIT:
159158
pass
160-
161-
debug(f"Disk states after installing:\n{disk_layouts()}")
159+
case PostInstallationAction.REBOOT:
160+
os.system('reboot')
161+
case PostInstallationAction.CHROOT:
162+
try:
163+
installation.drop_to_shell()
164+
except Exception:
165+
pass
162166

163167

164168
def guided() -> None:

0 commit comments

Comments
 (0)