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,8 @@
import pmb.config
import pmb.config.workdir
import pmb.helpers.git
from pmb.core.types import PmbArgs
from pmb.types import Config, PmbArgs
from pmb.core import get_context
from typing import List, Tuple
@ -15,8 +16,8 @@ def print_status_line(key: str, value: str):
print(f"{key.ljust(padding)} {value}")
def print_channel(args: PmbArgs) -> None:
pmaports_cfg = pmb.config.pmaports.read_config(args)
def print_channel(config: Config) -> None:
pmaports_cfg = pmb.config.pmaports.read_config()
channel = pmaports_cfg["channel"]
# Get branch name (if on branch) or current commit
@ -32,28 +33,29 @@ def print_channel(args: PmbArgs) -> None:
print_status_line("Channel", value)
def print_device(args: PmbArgs) -> None:
def print_device(args: PmbArgs, config: Config) -> None:
kernel = ""
if pmb.parse._apkbuild.kernels(args, args.device):
kernel = f", kernel: {args.kernel}"
if pmb.parse._apkbuild.kernels(config.device):
kernel = f", kernel: {config.kernel}"
value = f"{args.device} ({args.deviceinfo['arch']}{kernel})"
value = f"{config.device} ({args.deviceinfo['arch']}{kernel})"
print_status_line("Device", value)
def print_ui(args: PmbArgs) -> None:
print_status_line("UI", args.ui)
def print_ui(config: Config) -> None:
print_status_line("UI", config.ui)
def print_systemd(args: PmbArgs) -> None:
yesno, reason = pmb.config.other.systemd_selected_str(args)
def print_systemd(config: Config) -> None:
yesno, reason = pmb.config.other.systemd_selected_str(config)
print_status_line("systemd", f"{yesno} ({reason})")
def print_status(args: PmbArgs) -> None:
""" :param details: if True, print each passing check instead of a summary
:returns: True if all checks passed, False otherwise """
print_channel(args)
print_device(args)
print_ui(args)
print_systemd(args)
config = get_context().config
print_channel(config)
print_device(args, config)
print_ui(config)
print_systemd(config)