pmbootstrap-meow/pmb/install/ui.py
Caleb Connolly 71e7af57e6
pmb.helpers.logging: wrap logging module (MR 2252)
We use a custom verbose log level in pmbootstrap, unfortunately it isn't
possible to correctly type this due to some limitations in the logging
library [1], [2].

Given that our usecase is fairly simple, we can just wrap the module
with our own so we only have to tell mypy to ignore the error once
instead of at every callsite.

[1]: https://github.com/cryptax/droidlysis/issues/15
[2]: https://github.com/python/typing/discussions/980

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:37 +02:00

37 lines
1.1 KiB
Python

# Copyright 2023 Dylan Van Assche
# SPDX-License-Identifier: GPL-3.0-or-later
from pmb.helpers import logging
from pmb.core.types import PmbArgs
import pmb.helpers.pmaports
def get_groups(args: PmbArgs):
""" Get all groups to which the user additionally must be added.
The list of groups are listed in _pmb_groups of the UI and
UI-extras package.
:returns: list of groups, e.g. ["feedbackd", "udev"] """
ret = []
if args.ui == "none":
return ret
# UI package
meta = f"postmarketos-ui-{args.ui}"
apkbuild = pmb.helpers.pmaports.get(args, meta)
groups = apkbuild["_pmb_groups"]
if groups:
logging.debug(f"{meta}: install _pmb_groups:"
f" {', '.join(groups)}")
ret += groups
# UI-extras subpackage
meta_extras = f"{meta}-extras"
if args.ui_extras and meta_extras in apkbuild["subpackages"]:
groups = apkbuild["subpackages"][meta_extras]["_pmb_groups"]
if groups:
logging.debug(f"{meta_extras}: install _pmb_groups:"
f" {', '.join(groups)}")
ret += groups
return ret