Skip to content

Commit 5355c71

Browse files
authored
Add --skip-boot to allow for bypassing installation of a bootloader (#3677)
* Adding the option to skip boot loader * Fixed a variable complaint * Fixed ruff and mypy * Fixed mypy * Fixed mypy * Fixed import recursion * Fixed ruff * Fixed circular imports * Fixed ruff * Hiding the menu option for bootloader when --skip-boot is given. Still setting it default to None to avoid it sneaking into the config file or being set behind the scenes causing if statements to trigger. * Created an Enum None type for Bootloader called NO_BOOTLOADER * Fixed ruff * Spelling error * Hiding NO_BOOTLOADER if --skip-boot is omitted * Fixed TUI error when bootloader was missing * Fixed mypy complaints * Fixed ruff complaint * Made the Bootloader option visible during --skip-boot and set the default value to NO_BOOTLOADER when --skip-boot is present
1 parent ee6dcbe commit 5355c71

7 files changed

Lines changed: 51 additions & 16 deletions

File tree

archinstall/lib/args.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Arguments:
4343
mountpoint: Path = Path('/mnt')
4444
skip_ntp: bool = False
4545
skip_wkd: bool = False
46+
skip_boot: bool = False
4647
debug: bool = False
4748
offline: bool = False
4849
no_pkg_lookups: bool = False
@@ -62,7 +63,7 @@ class ArchConfig:
6263
profile_config: ProfileConfiguration | None = None
6364
mirror_config: MirrorConfiguration | None = None
6465
network_config: NetworkConfiguration | None = None
65-
bootloader: Bootloader = field(default=Bootloader.get_default())
66+
bootloader: Bootloader | None = None
6667
uki: bool = False
6768
app_config: ApplicationConfiguration | None = None
6869
auth_config: AuthenticationConfiguration | None = None
@@ -107,7 +108,7 @@ def safe_json(self) -> dict[str, Any]:
107108
'timezone': self.timezone,
108109
'services': self.services,
109110
'custom_commands': self.custom_commands,
110-
'bootloader': self.bootloader.json(),
111+
'bootloader': self.bootloader.json() if self.bootloader else None,
111112
'app_config': self.app_config.json() if self.app_config else None,
112113
'auth_config': self.auth_config.json() if self.auth_config else None,
113114
}
@@ -179,7 +180,7 @@ def from_config(cls, args_config: dict[str, Any]) -> 'ArchConfig':
179180
if bootloader_config := args_config.get('bootloader', None):
180181
arch_config.bootloader = Bootloader.from_arg(bootloader_config)
181182

182-
if args_config.get('uki') and not arch_config.bootloader.has_uki_support():
183+
if args_config.get('uki') and (arch_config.bootloader is None or not arch_config.bootloader.has_uki_support()):
183184
arch_config.uki = False
184185

185186
# deprecated: backwards compatibility
@@ -367,6 +368,12 @@ def _define_arguments(self) -> ArgumentParser:
367368
help='Disables checking if archlinux keyring wkd sync is complete.',
368369
default=False,
369370
)
371+
parser.add_argument(
372+
'--skip-boot',
373+
action='store_true',
374+
help='Disables installation of a boot loader (note: only use this when problems arise with the boot loader step).',
375+
default=False,
376+
)
370377
parser.add_argument(
371378
'--debug',
372379
action='store_true',

archinstall/lib/global_menu.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, arch_config: ArchConfig) -> None:
5151
super().__init__(self._item_group, config=arch_config)
5252

5353
def _get_menu_options(self) -> list[MenuItem]:
54-
return [
54+
menu_options = [
5555
MenuItem(
5656
text=tr('Archinstall language'),
5757
action=self._select_archinstall_language,
@@ -189,6 +189,8 @@ def _get_menu_options(self) -> list[MenuItem]:
189189
),
190190
]
191191

192+
return menu_options
193+
192194
def _safe_config(self) -> None:
193195
# data: dict[str, Any] = {}
194196
# for item in self._item_group.items:
@@ -416,11 +418,13 @@ def _validate_bootloader(self) -> str | None:
416418
XXX: The caller is responsible for wrapping the string with the translation
417419
shim if necessary.
418420
"""
419-
bootloader = self._item_group.find_by_key('bootloader').value
421+
bootloader: Bootloader | None = None
420422
root_partition: PartitionModification | None = None
421423
boot_partition: PartitionModification | None = None
422424
efi_partition: PartitionModification | None = None
423425

426+
bootloader = self._item_group.find_by_key('bootloader').value
427+
424428
if disk_config := self._item_group.find_by_key('disk_config').value:
425429
for layout in disk_config.device_modifications:
426430
if root_partition := layout.get_root_partition():

archinstall/lib/interactions/system_conf.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from archinstall.tui.result import ResultType
77
from archinstall.tui.types import Alignment, FrameProperties, FrameStyle, Orientation, PreviewStyle
88

9+
from ..args import arch_config_handler
910
from ..hardware import GfxDriver, SysInfo
1011
from ..models.bootloader import Bootloader
1112

@@ -47,14 +48,25 @@ def select_kernel(preset: list[str] = []) -> list[str]:
4748

4849
def ask_for_bootloader(preset: Bootloader | None) -> Bootloader | None:
4950
# Systemd is UEFI only
51+
options = []
52+
hidden_options = []
53+
default = None
54+
header = None
55+
56+
if arch_config_handler.args.skip_boot:
57+
default = Bootloader.NO_BOOTLOADER
58+
else:
59+
hidden_options += [Bootloader.NO_BOOTLOADER]
60+
5061
if not SysInfo.has_uefi():
51-
options = [Bootloader.Grub, Bootloader.Limine]
52-
default = Bootloader.Grub
62+
options += [Bootloader.Grub, Bootloader.Limine]
63+
if not default:
64+
default = Bootloader.Grub
5365
header = tr('UEFI is not detected and some options are disabled')
5466
else:
55-
options = [b for b in Bootloader]
56-
default = Bootloader.Systemd
57-
header = None
67+
options += [b for b in Bootloader if b not in hidden_options]
68+
if not default:
69+
default = Bootloader.Systemd
5870

5971
items = [MenuItem(o.value, value=o) for o in options]
6072
group = MenuItemGroup(items)

archinstall/lib/models/bootloader.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99

1010
class Bootloader(Enum):
11+
NO_BOOTLOADER = 'No bootloader'
1112
Systemd = 'Systemd-boot'
1213
Grub = 'Grub'
1314
Efistub = 'Efistub'
@@ -25,11 +26,17 @@ def json(self) -> str:
2526

2627
@staticmethod
2728
def values() -> list[str]:
28-
return [e.value for e in Bootloader]
29+
from ..args import arch_config_handler
30+
31+
return [e.value for e in Bootloader if e != Bootloader.NO_BOOTLOADER or arch_config_handler.args.skip_boot is True]
2932

3033
@classmethod
31-
def get_default(cls) -> Bootloader:
32-
if SysInfo.has_uefi():
34+
def get_default(cls) -> None | Bootloader:
35+
from ..args import arch_config_handler
36+
37+
if arch_config_handler.args.skip_boot:
38+
return Bootloader.NO_BOOTLOADER
39+
elif SysInfo.has_uefi():
3340
return Bootloader.Systemd
3441
else:
3542
return Bootloader.Grub

archinstall/scripts/guided.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ def perform_installation(mountpoint: Path) -> None:
9999
if config.swap:
100100
installation.setup_swap('zram')
101101

102-
if config.bootloader == Bootloader.Grub and SysInfo.has_uefi():
103-
installation.add_additional_packages('grub')
102+
if config.bootloader and config.bootloader != Bootloader.NO_BOOTLOADER:
103+
if config.bootloader == Bootloader.Grub and SysInfo.has_uefi():
104+
installation.add_additional_packages('grub')
104105

105-
installation.add_bootloader(config.bootloader, config.uki)
106+
installation.add_bootloader(config.bootloader, config.uki)
106107

107108
# If user selected to copy the current ISO network configuration
108109
# Perform a copy of the config

archinstall/tui/menu_item.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def get_item_text(self, item: MenuItem) -> str:
196196

197197
max_width = self._max_items_text_width
198198
display_text = item.get_display_value()
199+
199200
default_text = self._default_suffix(item)
200201

201202
text = unicode_ljust(str(item.text), max_width, ' ')

tests/test_args.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def test_default_args(monkeypatch: MonkeyPatch) -> None:
3636
mountpoint=Path('/mnt'),
3737
skip_ntp=False,
3838
skip_wkd=False,
39+
skip_boot=False,
3940
debug=False,
4041
offline=False,
4142
no_pkg_lookups=False,
@@ -66,6 +67,7 @@ def test_correct_parsing_args(
6667
'/tmp',
6768
'--skip-ntp',
6869
'--skip-wkd',
70+
'--skip-boot',
6971
'--debug',
7072
'--offline',
7173
'--no-pkg-lookups',
@@ -91,6 +93,7 @@ def test_correct_parsing_args(
9193
mountpoint=Path('/tmp'),
9294
skip_ntp=True,
9395
skip_wkd=True,
96+
skip_boot=True,
9497
debug=True,
9598
offline=True,
9699
no_pkg_lookups=True,

0 commit comments

Comments
 (0)