1- from __future__ import annotations
2-
31import time
42from collections .abc import Iterator
3+ from pathlib import Path
54from types import TracebackType
6- from typing import TYPE_CHECKING , ClassVar , Self
5+ from typing import ClassVar , Self
76
87from archinstall .lib .command import SysCommand , SysCommandWorker , locate_binary
98from archinstall .lib .exceptions import SysCallError
109from archinstall .lib .output import error
1110
12- if TYPE_CHECKING :
13- from archinstall .lib .installer import Installer
14-
1511
1612class 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
0 commit comments