pmb.flasher: Remove use of args (MR 2441)

Also adapt pmb/install/recovery.py to new API for variables.py.

[ci:skip-build]: already built successfully in CI
This commit is contained in:
Newbyte 2024-10-21 00:04:54 +02:00
parent 2305cc5db6
commit 37ec73c07c
No known key found for this signature in database
GPG key ID: 8A700086A9FE41FD
9 changed files with 140 additions and 56 deletions

View file

@ -3,15 +3,21 @@
import pmb.config.pmaports
from pmb.core.chroot import Chroot
from pmb.core.context import get_context
from pmb.types import PmbArgs
def variables(args: PmbArgs, flavor: str, method: str):
def variables(
flavor: str | None,
method: str,
cmdline: str | None,
no_reboot: bool | None,
partition: str | None,
resume: bool | None,
) -> dict[str, str]:
device = get_context().config.device
deviceinfo = pmb.parse.deviceinfo()
_cmdline = deviceinfo.kernel_cmdline or ""
if "cmdline" in args and args.cmdline:
_cmdline = args.cmdline
if cmdline:
_cmdline = cmdline
flash_pagesize = deviceinfo.flash_pagesize
@ -54,22 +60,22 @@ def variables(args: PmbArgs, flavor: str, method: str):
_partition_vbmeta = deviceinfo.flash_heimdall_partition_vbmeta or None
_partition_dtbo = deviceinfo.flash_heimdall_partition_dtbo or None
if "partition" in args and args.partition:
if partition:
# Only one operation is done at same time so it doesn't matter
# sharing the arg
_partition_kernel = args.partition
_partition_rootfs = args.partition
_partition_vbmeta = args.partition
_partition_dtbo = args.partition
_partition_kernel = partition
_partition_rootfs = partition
_partition_vbmeta = partition
_partition_dtbo = partition
_dtb = deviceinfo.dtb + ".dtb"
_no_reboot = ""
if getattr(args, "no_reboot", False):
if no_reboot:
_no_reboot = "--no-reboot"
_resume = ""
if getattr(args, "resume", False):
if resume:
_resume = "--resume"
fvars = {