Fix 3598 - Utilize script field from config when present (#3611)
* Fix 3598 - Utilize script field from config when present * Update * Update
This commit is contained in:
parent
37b3985625
commit
77558e2be5
|
|
@ -87,7 +87,7 @@ def main() -> int:
|
|||
if not arch_config_handler.args.skip_version_check:
|
||||
_check_new_version()
|
||||
|
||||
script = arch_config_handler.args.script
|
||||
script = arch_config_handler.get_script()
|
||||
|
||||
mod_name = f'archinstall.scripts.{script}'
|
||||
# by loading the module we'll automatically run the script
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class Arguments:
|
|||
creds_decryption_key: str | None = None
|
||||
silent: bool = False
|
||||
dry_run: bool = False
|
||||
script: str = 'guided'
|
||||
script: str | None = None
|
||||
mountpoint: Path = Path('/mnt')
|
||||
skip_ntp: bool = False
|
||||
skip_wkd: bool = False
|
||||
|
|
@ -54,6 +54,7 @@ class Arguments:
|
|||
@dataclass
|
||||
class ArchConfig:
|
||||
version: str | None = None
|
||||
script: str | None = None
|
||||
locale_config: LocaleConfiguration | None = None
|
||||
archinstall_language: Language = field(default_factory=lambda: translation_handler.get_language_by_abbr('en'))
|
||||
disk_config: DiskLayoutConfiguration | None = None
|
||||
|
|
@ -93,6 +94,7 @@ class ArchConfig:
|
|||
def safe_json(self) -> dict[str, Any]:
|
||||
config: Any = {
|
||||
'version': self.version,
|
||||
'script': self.script,
|
||||
'archinstall-language': self.archinstall_language.json(),
|
||||
'hostname': self.hostname,
|
||||
'kernels': self.kernels,
|
||||
|
|
@ -130,6 +132,9 @@ class ArchConfig:
|
|||
|
||||
arch_config.locale_config = LocaleConfiguration.parse_arg(args_config)
|
||||
|
||||
if script := args_config.get('script', None):
|
||||
arch_config.script = script
|
||||
|
||||
if archinstall_lang := args_config.get('archinstall-language', None):
|
||||
arch_config.archinstall_language = translation_handler.get_language_by_name(archinstall_lang)
|
||||
|
||||
|
|
@ -244,6 +249,15 @@ class ArchConfigHandler:
|
|||
def args(self) -> Arguments:
|
||||
return self._args
|
||||
|
||||
def get_script(self) -> str:
|
||||
if script := self.args.script:
|
||||
return script
|
||||
|
||||
if script := self.config.script:
|
||||
return script
|
||||
|
||||
return 'guided'
|
||||
|
||||
def print_help(self) -> None:
|
||||
self._parser.print_help()
|
||||
|
||||
|
|
@ -312,7 +326,6 @@ class ArchConfigHandler:
|
|||
)
|
||||
parser.add_argument(
|
||||
'--script',
|
||||
default='guided',
|
||||
nargs='?',
|
||||
help='Script to run for installation',
|
||||
type=str,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"archinstall-language": "English",
|
||||
"script": "test_script",
|
||||
"app_config": {
|
||||
"bluetooth_config": {
|
||||
"enabled": true
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ def test_default_args(monkeypatch: MonkeyPatch) -> None:
|
|||
creds_decryption_key=None,
|
||||
silent=False,
|
||||
dry_run=False,
|
||||
script='guided',
|
||||
script=None,
|
||||
mountpoint=Path('/mnt'),
|
||||
skip_ntp=False,
|
||||
skip_wkd=False,
|
||||
|
|
@ -127,6 +127,7 @@ def test_config_file_parsing(
|
|||
|
||||
assert arch_config == ArchConfig(
|
||||
version='3.0.2',
|
||||
script='test_script',
|
||||
app_config=ApplicationConfiguration(
|
||||
bluetooth_config=BluetoothConfiguration(enabled=True),
|
||||
audio_config=AudioConfiguration(audio=Audio.PIPEWIRE),
|
||||
|
|
|
|||
Loading…
Reference in New Issue