Add kernel enum (#4489)
This commit is contained in:
parent
074dfbb178
commit
9010ccf9eb
|
|
@ -21,6 +21,7 @@ from archinstall.lib.models.device import DiskEncryption, DiskLayoutConfiguratio
|
|||
from archinstall.lib.models.locale import LocaleConfiguration
|
||||
from archinstall.lib.models.mirrors import MirrorConfiguration
|
||||
from archinstall.lib.models.network import NetworkConfiguration
|
||||
from archinstall.lib.models.package_types import DEFAULT_KERNEL
|
||||
from archinstall.lib.models.packages import Repository
|
||||
from archinstall.lib.models.pacman import PacmanConfiguration
|
||||
from archinstall.lib.models.profile import ProfileConfiguration
|
||||
|
|
@ -71,7 +72,7 @@ class ArchConfig:
|
|||
auth_config: AuthenticationConfiguration | None = None
|
||||
swap: ZramConfiguration | None = None
|
||||
hostname: str = 'archlinux'
|
||||
kernels: list[str] = field(default_factory=lambda: ['linux'])
|
||||
kernels: list[str] = field(default_factory=lambda: [DEFAULT_KERNEL.value])
|
||||
ntp: bool = True
|
||||
packages: list[str] = field(default_factory=list)
|
||||
pacman_config: PacmanConfiguration = field(default_factory=PacmanConfiguration.default)
|
||||
|
|
|
|||
|
|
@ -3,29 +3,24 @@ from typing import assert_never
|
|||
from archinstall.lib.hardware import GfxDriver, SysInfo
|
||||
from archinstall.lib.menu.helpers import Confirmation, Selection
|
||||
from archinstall.lib.models.application import ZramAlgorithm, ZramConfiguration
|
||||
from archinstall.lib.models.package_types import DEFAULT_KERNEL, Kernel
|
||||
from archinstall.lib.translationhandler import tr
|
||||
from archinstall.tui.ui.menu_item import MenuItem, MenuItemGroup
|
||||
from archinstall.tui.ui.result import ResultType
|
||||
|
||||
|
||||
async def select_kernel(preset: list[str] = []) -> list[str]:
|
||||
async def select_kernel(preset: list[Kernel] = []) -> list[Kernel]:
|
||||
"""
|
||||
Asks the user to select a kernel for system.
|
||||
|
||||
:return: The string as a selected kernel
|
||||
:rtype: string
|
||||
"""
|
||||
kernels = ['linux', 'linux-lts', 'linux-zen', 'linux-hardened']
|
||||
default_kernel = 'linux'
|
||||
group = MenuItemGroup.from_enum(Kernel, sort_items=True, preset=preset)
|
||||
group.set_default_by_value(DEFAULT_KERNEL)
|
||||
group.set_focus_by_value(DEFAULT_KERNEL)
|
||||
|
||||
items = [MenuItem(k, value=k) for k in kernels]
|
||||
|
||||
group = MenuItemGroup(items, sort_items=True)
|
||||
group.set_default_by_value(default_kernel)
|
||||
group.set_focus_by_value(default_kernel)
|
||||
group.set_selected_by_value(preset)
|
||||
|
||||
result = await Selection[str](
|
||||
result = await Selection[Kernel](
|
||||
group,
|
||||
header=tr('Select which kernel(s) to install'),
|
||||
allow_skip=True,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ from archinstall.lib.models.device import DiskLayoutConfiguration, DiskLayoutTyp
|
|||
from archinstall.lib.models.locale import LocaleConfiguration
|
||||
from archinstall.lib.models.mirrors import MirrorConfiguration
|
||||
from archinstall.lib.models.network import NetworkConfiguration, NicType
|
||||
from archinstall.lib.models.package_types import DEFAULT_KERNEL
|
||||
from archinstall.lib.models.packages import Repository
|
||||
from archinstall.lib.models.pacman import PacmanConfiguration
|
||||
from archinstall.lib.models.profile import ProfileConfiguration
|
||||
|
|
@ -103,7 +104,7 @@ class GlobalMenu(AbstractMenu[None]):
|
|||
),
|
||||
MenuItem(
|
||||
text=tr('Kernels'),
|
||||
value=['linux'],
|
||||
value=[DEFAULT_KERNEL],
|
||||
action=select_kernel,
|
||||
preview_action=self._prev_kernel,
|
||||
mandatory=True,
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ from archinstall.lib.models.device import (
|
|||
from archinstall.lib.models.locale import LocaleConfiguration
|
||||
from archinstall.lib.models.mirrors import MirrorConfiguration
|
||||
from archinstall.lib.models.network import Nic
|
||||
from archinstall.lib.models.package_types import DEFAULT_KERNEL, Kernel
|
||||
from archinstall.lib.models.packages import Repository
|
||||
from archinstall.lib.models.pacman import PacmanConfiguration
|
||||
from archinstall.lib.models.users import User
|
||||
|
|
@ -60,7 +61,7 @@ from archinstall.lib.plugins import plugins
|
|||
from archinstall.lib.translationhandler import tr
|
||||
|
||||
# Any package that the Installer() is responsible for (optional and the default ones)
|
||||
__packages__ = ['base', 'sudo', 'linux-firmware', 'linux', 'linux-lts', 'linux-zen', 'linux-hardened']
|
||||
__packages__ = ['base', 'sudo', 'linux-firmware'] + [k.value for k in Kernel]
|
||||
|
||||
# Additional packages that are installed if the user is running the Live ISO with accessibility tools enabled
|
||||
__accessibility_packages__ = ['brltty', 'espeakup', 'alsa-utils']
|
||||
|
|
@ -80,7 +81,7 @@ class Installer:
|
|||
It also wraps :py:func:`~archinstall.Installer.pacstrap` among other things.
|
||||
"""
|
||||
self._base_packages = base_packages or __packages__[:3]
|
||||
self.kernels = kernels or ['linux']
|
||||
self.kernels = kernels or [DEFAULT_KERNEL.value]
|
||||
self._disk_config = disk_config
|
||||
|
||||
self._disk_encryption = disk_config.disk_encryption or DiskEncryption(EncryptionType.NO_ENCRYPTION)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
from enum import StrEnum, auto
|
||||
from typing import Final
|
||||
|
||||
|
||||
class Kernel(StrEnum):
|
||||
LINUX = auto()
|
||||
LINUX_LTS = 'linux-lts'
|
||||
LINUX_ZEN = 'linux-zen'
|
||||
LINUX_HARDENED = 'linux-hardened'
|
||||
|
||||
|
||||
DEFAULT_KERNEL: Final = Kernel.LINUX
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
from collections.abc import Awaitable, Callable
|
||||
from collections.abc import Awaitable, Callable, Iterable
|
||||
from dataclasses import dataclass, field
|
||||
from enum import Enum
|
||||
from functools import cached_property
|
||||
|
|
@ -148,7 +148,7 @@ class MenuItemGroup:
|
|||
cls,
|
||||
enum_cls: type[Enum],
|
||||
sort_items: bool = False,
|
||||
preset: Enum | None = None,
|
||||
preset: Iterable[Enum] | Enum | None = None,
|
||||
) -> Self:
|
||||
items = [MenuItem(elem.value, value=elem) for elem in enum_cls]
|
||||
group = cls(items, sort_items=sort_items)
|
||||
|
|
|
|||
Loading…
Reference in New Issue