parse: deviceinfo: make Deviceinfo a class (MR 2252)

Introduce a Deviceinfo class and use it rather than the dictionary. This
gives us sweet sweet autocomplete, and lays the foundation for having a
proper deviceinfo validator in the future.

Additionally, continue refactoring out args...

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-06-06 15:05:59 +02:00 committed by Oliver Smith
parent b51d31acab
commit 97bd8b96ec
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
27 changed files with 372 additions and 288 deletions

View file

@ -92,7 +92,7 @@ def command_qemu(args: PmbArgs, device: str, arch, img_path, img_path_2nd=None):
"""
Generate the full qemu command with arguments to run postmarketOS
"""
cmdline = pmb.parse.deviceinfo()["kernel_cmdline"]
cmdline = pmb.parse.deviceinfo().kernel_cmdline
if args.cmdline:
cmdline = args.cmdline
@ -221,7 +221,7 @@ def command_qemu(args: PmbArgs, device: str, arch, img_path, img_path_2nd=None):
"if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF.fd"]
# Kernel Virtual Machine (KVM) support
native = pmb.config.arch_native == pmb.parse.deviceinfo()["arch"]
native = pmb.config.arch_native == pmb.parse.deviceinfo().arch
if args.qemu_kvm and native and os.path.exists("/dev/kvm"):
command += ["-enable-kvm"]
command += ["-cpu", "host"]
@ -338,7 +338,7 @@ def run(args: PmbArgs):
raise RuntimeError("'pmbootstrap qemu' can be only used with one of "
"the QEMU device packages. Run 'pmbootstrap init' "
"and select the 'qemu' vendor.")
arch = pmb.parse.arch.alpine_to_qemu(pmb.parse.deviceinfo()["arch"])
arch = pmb.parse.arch.alpine_to_qemu(pmb.parse.deviceinfo().arch)
img_path = system_image(device)
img_path_2nd = None