Skip to content
Snippets Groups Projects
Verified Commit 2a2e1aab authored by Clayton Craft's avatar Clayton Craft :speech_balloon:
Browse files

pmb.parse.depends.package_provider: add type hinting and fix references

pmb.parse.apkindex.providers now returns a dict of string:ApkindexBlock,
probably from 71772b9b

This adds type hinting to package_provider to reflect this, and fixes
code that calls it to properly deal with the possible return types.
Without this, building FDE images is broken.
parent 4019636f
No related branches found
No related tags found
No related merge requests found
Pipeline #208444 failed
......@@ -1291,8 +1291,10 @@ def create_device_rootfs(args: PmbArgs, step, steps):
unlocker = pmb.parse.depends.package_provider(
"postmarketos-fde-unlocker", install_packages, chroot
)
if unlocker["pkgname"] not in install_packages:
install_packages += [unlocker["pkgname"]]
if not unlocker:
raise RuntimeError("Full disk encryption enabled but unable to find any suitable FDE unlocker app")
if unlocker.pkgname not in install_packages:
install_packages += [unlocker.pkgname]
else:
install_packages += ["postmarketos-base-nofde"]
......
......@@ -29,11 +29,10 @@ def package_from_aports(pkgname_depend):
return {"pkgname": pkgname, "depends": apkbuild["depends"], "version": version}
def package_provider(pkgname, pkgnames_install, suffix: Chroot = Chroot.native()):
def package_provider(pkgname, pkgnames_install, suffix: Chroot = Chroot.native()) -> pmb.core.apkindex_block.ApkindexBlock | None:
"""
:param pkgnames_install: packages to be installed
:returns: a block from the apkindex: {"pkgname": "...", ...}
or None (no provider found)
:returns: ApkindexBlock object or None (no provider found)
"""
# Get all providers
arch = suffix.arch
......@@ -107,7 +106,7 @@ def package_from_index(
# Binary package outdated
if (
package_aport
and pmb.parse.version.compare(package_aport["version"], provider["version"]) == 1
and pmb.parse.version.compare(package_aport["version"], provider.version) == 1
):
logging.verbose(pkgname_depend + ": binary package is outdated")
return package_aport
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment