Skip to content

Commit f19f8d1

Browse files
authored
Replace Installer with path parameter in Boot (#4268)
1 parent 76d6f08 commit f19f8d1

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

archinstall/lib/boot.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
from __future__ import annotations
2-
31
import time
42
from collections.abc import Iterator
3+
from pathlib import Path
54
from types import TracebackType
6-
from typing import TYPE_CHECKING, ClassVar, Self
5+
from typing import ClassVar, Self
76

87
from archinstall.lib.command import SysCommand, SysCommandWorker, locate_binary
98
from archinstall.lib.exceptions import SysCallError
109
from archinstall.lib.output import error
1110

12-
if TYPE_CHECKING:
13-
from archinstall.lib.installer import Installer
14-
1511

1612
class Boot:
1713
_active_boot: ClassVar[Self | None] = None
1814

19-
def __init__(self, installation: Installer):
20-
self.instance = installation
15+
def __init__(self, path: Path | str):
16+
if isinstance(path, Path):
17+
path = str(path)
18+
19+
self.path = path
2120
self.container_name = 'archinstall'
2221
self.session: SysCommandWorker | None = None
2322
self.ready = False
2423

2524
def __enter__(self) -> Self:
26-
if Boot._active_boot and Boot._active_boot.instance != self.instance:
25+
if Boot._active_boot and Boot._active_boot.path != self.path:
2726
raise KeyError('Archinstall only supports booting up one instance and another session is already active.')
2827

2928
if Boot._active_boot:
@@ -36,7 +35,7 @@ def __enter__(self) -> Self:
3635
[
3736
'systemd-nspawn',
3837
'-D',
39-
str(self.instance.target),
38+
self.path,
4039
'--timezone=off',
4140
'-b',
4241
'--no-pager',
@@ -61,7 +60,7 @@ def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseExceptio
6160
if exc_type is not None:
6261
error(
6362
str(exc_value),
64-
f'The error above occurred in a temporary boot-up of the installation {self.instance}',
63+
f'The error above occurred in a temporary boot-up of the installation {self.path!r}',
6564
)
6665

6766
shutdown = None
@@ -85,7 +84,7 @@ def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseExceptio
8584
session_exit_code = self.session.exit_code if self.session else -1
8685

8786
raise SysCallError(
88-
f'Could not shut down temporary boot of {self.instance}: {session_exit_code}/{shutdown_exit_code}',
87+
f'Could not shut down temporary boot of {self.path!r}: {session_exit_code}/{shutdown_exit_code}',
8988
exit_code=next(filter(bool, [session_exit_code, shutdown_exit_code])),
9089
)
9190

archinstall/lib/installer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,7 +2020,7 @@ def set_keyboard_language(self, language: str) -> bool:
20202020

20212021
# In accordance with https://github.com/archlinux/archinstall/issues/107#issuecomment-841701968
20222022
# Setting an empty keymap first, allows the subsequent call to set layout for both console and x11.
2023-
with Boot(self) as session:
2023+
with Boot(self.target) as session:
20242024
os.system('systemd-run --machine=archinstall --pty localectl set-keymap ""')
20252025

20262026
try:
@@ -2046,7 +2046,7 @@ def set_x11_keyboard_language(self, language: str) -> bool:
20462046
error(f'Invalid x11-keyboard language specified: {language}')
20472047
return False
20482048

2049-
with Boot(self) as session:
2049+
with Boot(self.target) as session:
20502050
session.SysCommand(['localectl', 'set-x11-keymap', '""'])
20512051

20522052
try:

0 commit comments

Comments
 (0)