1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-12 19:09:56 +03:00

pmb.parse.depends.package_provider: add type hinting and fix references (MR 2439)

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

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.
This commit is contained in:
Clayton Craft 2024-10-17 23:05:48 -07:00 committed by Newbyte
parent 4019636f72
commit 47dc493701
No known key found for this signature in database
GPG key ID: 8A700086A9FE41FD
2 changed files with 11 additions and 9 deletions

View file

@ -1291,8 +1291,12 @@ 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"]

View file

@ -29,11 +29,12 @@ 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
@ -105,10 +106,7 @@ def package_from_index(
return package_aport
# Binary package outdated
if (
package_aport
and pmb.parse.version.compare(package_aport["version"], provider["version"]) == 1
):
if package_aport and pmb.parse.version.compare(package_aport["version"], provider.version) == 1:
logging.verbose(pkgname_depend + ": binary package is outdated")
return package_aport