forked from Mirror/pmbootstrap
init: ask whether to install systemd (MR 2273)
Add the following question to "pmbootstrap init": [22:12:57] Based on your UI selection, 'default' will result in installing systemd. [22:12:57] Install systemd? (default/always/never) [default]: Determine whether the UI prefers to have systemd or not, based on "pmb:systemd" in the UI package's APKBUILD. Determine whether the currently selected branch supports systemd, by checking for a "[repo:systemd]" section in pmaports.cfg. This section will also contain bootstrap information, to be used in future patches.
This commit is contained in:
parent
c6e8a89ea3
commit
e96ca36376
5 changed files with 59 additions and 1 deletions
|
@ -93,6 +93,7 @@ config_keys = [
|
||||||
"ssh_key_glob",
|
"ssh_key_glob",
|
||||||
"ssh_keys",
|
"ssh_keys",
|
||||||
"sudo_timer",
|
"sudo_timer",
|
||||||
|
"systemd",
|
||||||
"timezone",
|
"timezone",
|
||||||
"ui",
|
"ui",
|
||||||
"ui_extras",
|
"ui_extras",
|
||||||
|
@ -128,6 +129,7 @@ defaults = {
|
||||||
"ssh_key_glob": "~/.ssh/id_*.pub",
|
"ssh_key_glob": "~/.ssh/id_*.pub",
|
||||||
"ssh_keys": False,
|
"ssh_keys": False,
|
||||||
"sudo_timer": False,
|
"sudo_timer": False,
|
||||||
|
"systemd": "default",
|
||||||
"timezone": "GMT",
|
"timezone": "GMT",
|
||||||
"ui": "console",
|
"ui": "console",
|
||||||
"ui_extras": False,
|
"ui_extras": False,
|
||||||
|
@ -792,6 +794,7 @@ apkbuild_custom_valid_options = [
|
||||||
"pmb:cross-native",
|
"pmb:cross-native",
|
||||||
"pmb:gpu-accel",
|
"pmb:gpu-accel",
|
||||||
"pmb:strict",
|
"pmb:strict",
|
||||||
|
"pmb:systemd",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Variables from deviceinfo. Reference: <https://postmarketos.org/deviceinfo>
|
# Variables from deviceinfo. Reference: <https://postmarketos.org/deviceinfo>
|
||||||
|
|
|
@ -189,6 +189,24 @@ def ask_for_ui_extras(args, ui):
|
||||||
default=args.ui_extras)
|
default=args.ui_extras)
|
||||||
|
|
||||||
|
|
||||||
|
def ask_for_systemd(args, ui):
|
||||||
|
if "systemd" not in pmb.config.pmaports.read_config_repos(args):
|
||||||
|
return args.systemd
|
||||||
|
|
||||||
|
default_is_systemd = pmb.helpers.ui.check_option(args, ui, "pmb:systemd")
|
||||||
|
not_str = " " if default_is_systemd else " not "
|
||||||
|
logging.info("Based on your UI selection, 'default' will result"
|
||||||
|
f" in{not_str}installing systemd.")
|
||||||
|
|
||||||
|
choices = ["default", "always", "never"]
|
||||||
|
answer = pmb.helpers.cli.ask("Install systemd?",
|
||||||
|
choices,
|
||||||
|
args.systemd,
|
||||||
|
validation_regex=f"^({'|'.join(choices)})$",
|
||||||
|
complete=choices)
|
||||||
|
return answer
|
||||||
|
|
||||||
|
|
||||||
def ask_for_keymaps(args, info):
|
def ask_for_keymaps(args, info):
|
||||||
if "keymaps" not in info or info["keymaps"].strip() == "":
|
if "keymaps" not in info or info["keymaps"].strip() == "":
|
||||||
return ""
|
return ""
|
||||||
|
@ -673,6 +691,10 @@ def frontend(args):
|
||||||
ui = ask_for_ui(args, info)
|
ui = ask_for_ui(args, info)
|
||||||
cfg["pmbootstrap"]["ui"] = ui
|
cfg["pmbootstrap"]["ui"] = ui
|
||||||
cfg["pmbootstrap"]["ui_extras"] = str(ask_for_ui_extras(args, ui))
|
cfg["pmbootstrap"]["ui_extras"] = str(ask_for_ui_extras(args, ui))
|
||||||
|
|
||||||
|
# systemd
|
||||||
|
cfg["pmbootstrap"]["systemd"] = ask_for_systemd(args, ui)
|
||||||
|
|
||||||
ask_for_provider_select_pkg(args, f"postmarketos-ui-{ui}",
|
ask_for_provider_select_pkg(args, f"postmarketos-ui-{ui}",
|
||||||
cfg["providers"])
|
cfg["providers"])
|
||||||
ask_for_additional_options(args, cfg)
|
ask_for_additional_options(args, cfg)
|
||||||
|
|
|
@ -81,6 +81,28 @@ def check_version_pmbootstrap(min):
|
||||||
" of pmbootstrap from git.")
|
" of pmbootstrap from git.")
|
||||||
|
|
||||||
|
|
||||||
|
def read_config_repos(args):
|
||||||
|
""" Read the sections starting with "repo:" from pmaports.cfg. """
|
||||||
|
# Try cache first
|
||||||
|
cache_key = "pmb.config.pmaports.read_config_repos"
|
||||||
|
if pmb.helpers.other.cache[cache_key]:
|
||||||
|
return pmb.helpers.other.cache[cache_key]
|
||||||
|
|
||||||
|
cfg = configparser.ConfigParser()
|
||||||
|
cfg.read(f"{args.aports}/pmaports.cfg")
|
||||||
|
|
||||||
|
ret = {}
|
||||||
|
for section in cfg.keys():
|
||||||
|
if not section.startswith("repo:"):
|
||||||
|
continue
|
||||||
|
repo = section.split("repo:", 1)[1]
|
||||||
|
ret[repo] = cfg[section]
|
||||||
|
|
||||||
|
# Cache and return
|
||||||
|
pmb.helpers.other.cache[cache_key] = ret
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def read_config(args):
|
def read_config(args):
|
||||||
""" Read and verify pmaports.cfg. """
|
""" Read and verify pmaports.cfg. """
|
||||||
# Try cache first
|
# Try cache first
|
||||||
|
|
|
@ -312,4 +312,5 @@ def init_cache():
|
||||||
"pmb.helpers.package.get": {},
|
"pmb.helpers.package.get": {},
|
||||||
"pmb.helpers.repo.update": repo_update,
|
"pmb.helpers.repo.update": repo_update,
|
||||||
"pmb.helpers.git.parse_channels_cfg": {},
|
"pmb.helpers.git.parse_channels_cfg": {},
|
||||||
"pmb.config.pmaports.read_config": None}
|
"pmb.config.pmaports.read_config": None,
|
||||||
|
"pmb.config.pmaports.read_config_repos": None}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
|
import pmb.helpers.pmaports
|
||||||
import pmb.parse
|
import pmb.parse
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,3 +22,12 @@ def list(args, arch):
|
||||||
if pmb.helpers.package.check_arch(args, apkbuild["pkgname"], arch):
|
if pmb.helpers.package.check_arch(args, apkbuild["pkgname"], arch):
|
||||||
ret.append((ui, apkbuild["pkgdesc"]))
|
ret.append((ui, apkbuild["pkgdesc"]))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
def check_option(args, ui, option):
|
||||||
|
"""
|
||||||
|
Check if an option, such as pmb:systemd, is inside an UI's APKBUILD.
|
||||||
|
"""
|
||||||
|
pkgname = f"postmarketos-ui-{ui}"
|
||||||
|
apkbuild = pmb.helpers.pmaports.get(args, pkgname, subpackages=False)
|
||||||
|
return option in apkbuild["options"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue