Skip to content

Commit 77558e2

Browse files
authored
Fix 3598 - Utilize script field from config when present (#3611)
* Fix 3598 - Utilize script field from config when present * Update * Update
1 parent 37b3985 commit 77558e2

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

archinstall/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def main() -> int:
8787
if not arch_config_handler.args.skip_version_check:
8888
_check_new_version()
8989

90-
script = arch_config_handler.args.script
90+
script = arch_config_handler.get_script()
9191

9292
mod_name = f'archinstall.scripts.{script}'
9393
# by loading the module we'll automatically run the script

archinstall/lib/args.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Arguments:
3838
creds_decryption_key: str | None = None
3939
silent: bool = False
4040
dry_run: bool = False
41-
script: str = 'guided'
41+
script: str | None = None
4242
mountpoint: Path = Path('/mnt')
4343
skip_ntp: bool = False
4444
skip_wkd: bool = False
@@ -54,6 +54,7 @@ class Arguments:
5454
@dataclass
5555
class ArchConfig:
5656
version: str | None = None
57+
script: str | None = None
5758
locale_config: LocaleConfiguration | None = None
5859
archinstall_language: Language = field(default_factory=lambda: translation_handler.get_language_by_abbr('en'))
5960
disk_config: DiskLayoutConfiguration | None = None
@@ -93,6 +94,7 @@ def unsafe_json(self) -> dict[str, Any]:
9394
def safe_json(self) -> dict[str, Any]:
9495
config: Any = {
9596
'version': self.version,
97+
'script': self.script,
9698
'archinstall-language': self.archinstall_language.json(),
9799
'hostname': self.hostname,
98100
'kernels': self.kernels,
@@ -130,6 +132,9 @@ def from_config(cls, args_config: dict[str, Any]) -> 'ArchConfig':
130132

131133
arch_config.locale_config = LocaleConfiguration.parse_arg(args_config)
132134

135+
if script := args_config.get('script', None):
136+
arch_config.script = script
137+
133138
if archinstall_lang := args_config.get('archinstall-language', None):
134139
arch_config.archinstall_language = translation_handler.get_language_by_name(archinstall_lang)
135140

@@ -244,6 +249,15 @@ def config(self) -> ArchConfig:
244249
def args(self) -> Arguments:
245250
return self._args
246251

252+
def get_script(self) -> str:
253+
if script := self.args.script:
254+
return script
255+
256+
if script := self.config.script:
257+
return script
258+
259+
return 'guided'
260+
247261
def print_help(self) -> None:
248262
self._parser.print_help()
249263

@@ -312,7 +326,6 @@ def _define_arguments(self) -> ArgumentParser:
312326
)
313327
parser.add_argument(
314328
'--script',
315-
default='guided',
316329
nargs='?',
317330
help='Script to run for installation',
318331
type=str,

tests/data/test_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"archinstall-language": "English",
3+
"script": "test_script",
34
"app_config": {
45
"bluetooth_config": {
56
"enabled": true

tests/test_args.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_default_args(monkeypatch: MonkeyPatch) -> None:
3131
creds_decryption_key=None,
3232
silent=False,
3333
dry_run=False,
34-
script='guided',
34+
script=None,
3535
mountpoint=Path('/mnt'),
3636
skip_ntp=False,
3737
skip_wkd=False,
@@ -127,6 +127,7 @@ def test_config_file_parsing(
127127

128128
assert arch_config == ArchConfig(
129129
version='3.0.2',
130+
script='test_script',
130131
app_config=ApplicationConfiguration(
131132
bluetooth_config=BluetoothConfiguration(enabled=True),
132133
audio_config=AudioConfiguration(audio=Audio.PIPEWIRE),

0 commit comments

Comments
 (0)