Fix circular bootloader dependency (#3686)
This commit is contained in:
parent
dd5a86165c
commit
91609c16b5
|
|
@ -131,7 +131,7 @@ class ArchConfig:
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_config(cls, args_config: dict[str, Any]) -> 'ArchConfig':
|
def from_config(cls, args_config: dict[str, Any], args: Arguments) -> 'ArchConfig':
|
||||||
arch_config = ArchConfig()
|
arch_config = ArchConfig()
|
||||||
|
|
||||||
arch_config.locale_config = LocaleConfiguration.parse_arg(args_config)
|
arch_config.locale_config = LocaleConfiguration.parse_arg(args_config)
|
||||||
|
|
@ -178,7 +178,7 @@ class ArchConfig:
|
||||||
arch_config.network_config = NetworkConfiguration.parse_arg(net_config)
|
arch_config.network_config = NetworkConfiguration.parse_arg(net_config)
|
||||||
|
|
||||||
if bootloader_config := args_config.get('bootloader', None):
|
if bootloader_config := args_config.get('bootloader', None):
|
||||||
arch_config.bootloader = Bootloader.from_arg(bootloader_config)
|
arch_config.bootloader = Bootloader.from_arg(bootloader_config, args.skip_boot)
|
||||||
|
|
||||||
if args_config.get('uki') and (arch_config.bootloader is None or not arch_config.bootloader.has_uki_support()):
|
if args_config.get('uki') and (arch_config.bootloader is None or not arch_config.bootloader.has_uki_support()):
|
||||||
arch_config.uki = False
|
arch_config.uki = False
|
||||||
|
|
@ -250,12 +250,13 @@ class ArchConfig:
|
||||||
class ArchConfigHandler:
|
class ArchConfigHandler:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self._parser: ArgumentParser = self._define_arguments()
|
self._parser: ArgumentParser = self._define_arguments()
|
||||||
self._args: Arguments = self._parse_args()
|
args: Arguments = self._parse_args()
|
||||||
|
self._args = args
|
||||||
|
|
||||||
config = self._parse_config()
|
config = self._parse_config()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._config = ArchConfig.from_config(config)
|
self._config = ArchConfig.from_config(config, args)
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
warn(str(err))
|
warn(str(err))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,6 @@ class Bootloader(Enum):
|
||||||
def json(self) -> str:
|
def json(self) -> str:
|
||||||
return self.value
|
return self.value
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def values() -> list[str]:
|
|
||||||
from ..args import arch_config_handler
|
|
||||||
|
|
||||||
return [e.value for e in Bootloader if e != Bootloader.NO_BOOTLOADER or arch_config_handler.args.skip_boot is True]
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_default(cls) -> Bootloader:
|
def get_default(cls) -> Bootloader:
|
||||||
from ..args import arch_config_handler
|
from ..args import arch_config_handler
|
||||||
|
|
@ -42,12 +36,15 @@ class Bootloader(Enum):
|
||||||
return Bootloader.Grub
|
return Bootloader.Grub
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_arg(cls, bootloader: str) -> Bootloader:
|
def from_arg(cls, bootloader: str, skip_boot: bool) -> Bootloader:
|
||||||
# to support old configuration files
|
# to support old configuration files
|
||||||
bootloader = bootloader.capitalize()
|
bootloader = bootloader.capitalize()
|
||||||
|
|
||||||
if bootloader not in cls.values():
|
bootloader_options = [e.value for e in Bootloader if e != Bootloader.NO_BOOTLOADER or skip_boot is True]
|
||||||
values = ', '.join(cls.values())
|
|
||||||
|
if bootloader not in bootloader_options:
|
||||||
|
values = ', '.join(bootloader_options)
|
||||||
warn(f'Invalid bootloader value "{bootloader}". Allowed values: {values}')
|
warn(f'Invalid bootloader value "{bootloader}". Allowed values: {values}')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
return Bootloader(bootloader)
|
return Bootloader(bootloader)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue