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

@ -18,7 +18,7 @@ def odin(context: Context, flavor, folder: Path):
for devices configured with the flasher method 'heimdall-isorec'
and with boot.img for devices with 'heimdall-bootimg'
"""
pmb.flasher.init(context.device)
pmb.flasher.init(context.device, "heimdall-isorec")
suffix = Chroot(ChrootType.ROOTFS, context.device)
deviceinfo = pmb.parse.deviceinfo(context.device)
@ -29,7 +29,7 @@ def odin(context: Context, flavor, folder: Path):
suffix_flavor = ""
# Validate method
method = deviceinfo["flash_method"]
method = deviceinfo.flash_method or ""
if not method.startswith("heimdall-"):
raise RuntimeError("An odin flashable tar is not supported"
f" for the flash method '{method}' specified"
@ -37,8 +37,8 @@ def odin(context: Context, flavor, folder: Path):
" Only 'heimdall' methods are supported.")
# Partitions
partition_kernel = deviceinfo["flash_heimdall_partition_kernel"] or "KERNEL"
partition_initfs = deviceinfo["flash_heimdall_partition_initfs"] or "RECOVERY"
partition_kernel = deviceinfo.flash_heimdall_partition_kernel or "KERNEL"
partition_initfs = deviceinfo.flash_heimdall_partition_initfs or "RECOVERY"
# Temporary folder
temp_folder = "/tmp/odin-flashable-tar"