forked from Mirror/pmbootstrap
pmb.config.other: Don't require selected UI package to exist (MR 2530)
Without this, `$ pmbootstrap init` crashes if a nonexistent UI package is selected. This can happen if one previously selected a UI package in a former checkout of pmaports, but then switched away to a different one that doesn't have the UI package. For example, if someone is working on a new UI in a feature branch and then switches away from it, or if a UI is removed from the canonical pmaports repository altogether.
This commit is contained in:
parent
5a2eafd3af
commit
9a31fe43b3
1 changed files with 10 additions and 4 deletions
|
@ -11,24 +11,30 @@ from pmb.meta import Cache
|
|||
def is_systemd_selected(config: Config) -> bool:
|
||||
if "systemd" not in pmb.config.pmaports.read_config_repos():
|
||||
return False
|
||||
if pmb.helpers.ui.check_option(config.ui, "pmb:systemd-never", with_extra_repos="disabled"):
|
||||
if pmb.helpers.ui.check_option(
|
||||
config.ui, "pmb:systemd-never", with_extra_repos="disabled", must_exist=False
|
||||
):
|
||||
return False
|
||||
if config.systemd == SystemdConfig.ALWAYS:
|
||||
return True
|
||||
if config.systemd == SystemdConfig.NEVER:
|
||||
return False
|
||||
return pmb.helpers.ui.check_option(config.ui, "pmb:systemd", with_extra_repos="disabled")
|
||||
current_ui_needs_systemd = pmb.helpers.ui.check_option(
|
||||
config.ui, "pmb:systemd", with_extra_repos="disabled", must_exist=False
|
||||
)
|
||||
|
||||
return current_ui_needs_systemd if current_ui_needs_systemd is not None else False
|
||||
|
||||
|
||||
def systemd_selected_str(config: Config) -> tuple[str, str]:
|
||||
if "systemd" not in pmb.config.pmaports.read_config_repos():
|
||||
return "no", "not supported by pmaports branch"
|
||||
if pmb.helpers.ui.check_option(config.ui, "pmb:systemd-never"):
|
||||
if pmb.helpers.ui.check_option(config.ui, "pmb:systemd-never", must_exist=False):
|
||||
return "no", "not supported by selected UI"
|
||||
if config.systemd == SystemdConfig.ALWAYS:
|
||||
return "yes", "'always' selected in 'pmbootstrap init'"
|
||||
if config.systemd == SystemdConfig.NEVER:
|
||||
return "no", "'never' selected in 'pmbootstrap init'"
|
||||
if pmb.helpers.ui.check_option(config.ui, "pmb:systemd"):
|
||||
if pmb.helpers.ui.check_option(config.ui, "pmb:systemd", must_exist=False):
|
||||
return "yes", "default for selected UI"
|
||||
return "no", "default for selected UI"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue