WIP: start ripping out args (MR 2252)

Cease merging pmbootstrap.cfg into args, implement a Context type to let
us pull globals out of thin air (as an intermediate workaround) and rip
args out of a lot of the codebase.

This is just a first pass, after this we can split all the state that
leaked over into Context into types with narrower scopes (like a
BuildContext(), etc).

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-05-25 03:59:04 +02:00 committed by Oliver Smith
parent bfea00e03a
commit 34dd9d42ba
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
129 changed files with 1393 additions and 1300 deletions

View file

@ -3,7 +3,7 @@
import os
import glob
from pmb.core import get_context
from pmb.core.types import PmbArgs
from pmb.types import PmbArgs
import pmb.helpers.pmaports
import pmb.helpers.package
import pmb.parse
@ -19,7 +19,7 @@ def list_ui(args: PmbArgs, arch):
" customization. The \"console\" UI should be selected if"
" a graphical UI is not desired.")]
context = get_context() # noqa: F821
for path in sorted(context.aports.glob("main/postmarketos-ui-*")):
for path in sorted(context.config.aports.glob("main/postmarketos-ui-*")):
apkbuild = pmb.parse.apkbuild(path)
ui = os.path.basename(path).split("-", 2)[2]
if pmb.helpers.package.check_arch(args, apkbuild["pkgname"], arch):
@ -27,10 +27,10 @@ def list_ui(args: PmbArgs, arch):
return ret
def check_option(args: PmbArgs, ui, option):
def check_option(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)
apkbuild = pmb.helpers.pmaports.get(pkgname, subpackages=False)
return option in apkbuild["options"]