forked from Mirror/pmbootstrap
pmb.helpers.package.get: no crash if dep missing (!1909)
Fix the function, so it does not crash anymore when the replace_subpkgnames argument is set and a dependency cannot be resolved. Instead, print a useful warning that shows which pmaport caused the error (that has always been a pain to figure out), and simply don't replace the potential subpkgname with the real pkgname, just use the dependency name as-is. Resolve annoying crashes in bpo dependency resolving, like this one (caused by a few linux-* pmaports for bad downstream kernels that depend on python, not apparent at all from the message): [09:08:15] Calculate packages that need to be built (all packages, aarch64) [09:08:26] ERROR: Package 'python': Could not find aport, and could not find this package in any APKINDEX! Related: https://builds.sr.ht/~postmarketos/job/184022
This commit is contained in:
parent
29a3cb2b8c
commit
b18ec9a693
1 changed files with 23 additions and 10 deletions
|
@ -6,12 +6,13 @@ Functions that work on both pmaports and (binary package) repos. See also:
|
||||||
- pmb/helpers/repo.py (work on binary package repos)
|
- pmb/helpers/repo.py (work on binary package repos)
|
||||||
"""
|
"""
|
||||||
import copy
|
import copy
|
||||||
|
import logging
|
||||||
|
|
||||||
import pmb.helpers.pmaports
|
import pmb.helpers.pmaports
|
||||||
import pmb.helpers.repo
|
import pmb.helpers.repo
|
||||||
|
|
||||||
|
|
||||||
def get(args, pkgname, arch, replace_subpkgnames=False):
|
def get(args, pkgname, arch, replace_subpkgnames=False, must_exist=True):
|
||||||
""" Find a package in pmaports, and as fallback in the APKINDEXes of the
|
""" Find a package in pmaports, and as fallback in the APKINDEXes of the
|
||||||
binary packages.
|
binary packages.
|
||||||
:param pkgname: package name (e.g. "hello-world")
|
:param pkgname: package name (e.g. "hello-world")
|
||||||
|
@ -22,12 +23,14 @@ def get(args, pkgname, arch, replace_subpkgnames=False):
|
||||||
with check_arch(). Example: "armhf"
|
with check_arch(). Example: "armhf"
|
||||||
:param replace_subpkgnames: replace all subpkgnames with their main
|
:param replace_subpkgnames: replace all subpkgnames with their main
|
||||||
pkgnames in the depends (see #1733)
|
pkgnames in the depends (see #1733)
|
||||||
:returns: data from the parsed APKBUILD or APKINDEX in the following
|
:param must_exist: raise an exception, if not found
|
||||||
format: {"arch": ["noarch"],
|
:returns: * data from the parsed APKBUILD or APKINDEX in the following
|
||||||
"depends": ["busybox-extras", "lddtree", ...],
|
format: {"arch": ["noarch"],
|
||||||
"pkgname": "postmarketos-mkinitfs",
|
"depends": ["busybox-extras", "lddtree", ...],
|
||||||
"provides": ["mkinitfs=0..1"],
|
"pkgname": "postmarketos-mkinitfs",
|
||||||
"version": "0.0.4-r10"} """
|
"provides": ["mkinitfs=0..1"],
|
||||||
|
"version": "0.0.4-r10"}
|
||||||
|
* None if the package was not found """
|
||||||
# Cached result
|
# Cached result
|
||||||
cache_key = "pmb.helpers.package.get"
|
cache_key = "pmb.helpers.package.get"
|
||||||
if (arch in args.cache[cache_key] and
|
if (arch in args.cache[cache_key] and
|
||||||
|
@ -78,9 +81,17 @@ def get(args, pkgname, arch, replace_subpkgnames=False):
|
||||||
if replace_subpkgnames:
|
if replace_subpkgnames:
|
||||||
depends_new = []
|
depends_new = []
|
||||||
for depend in ret["depends"]:
|
for depend in ret["depends"]:
|
||||||
depend = get(args, depend, arch)["pkgname"]
|
depend_data = get(args, depend, arch, must_exist=False)
|
||||||
if depend not in depends_new:
|
if not depend_data:
|
||||||
depends_new += [depend]
|
logging.warning(f"WARNING: {pkgname}: failed to resolve"
|
||||||
|
f" dependency '{depend}'")
|
||||||
|
# Can't replace potential subpkgname
|
||||||
|
if depend not in depends_new:
|
||||||
|
depends_new += [depend]
|
||||||
|
continue
|
||||||
|
depend_pkgname = depend_data["pkgname"]
|
||||||
|
if depend_pkgname not in depends_new:
|
||||||
|
depends_new += [depend_pkgname]
|
||||||
ret["depends"] = depends_new
|
ret["depends"] = depends_new
|
||||||
|
|
||||||
# Save to cache and return
|
# Save to cache and return
|
||||||
|
@ -93,6 +104,8 @@ def get(args, pkgname, arch, replace_subpkgnames=False):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
# Could not find the package
|
# Could not find the package
|
||||||
|
if not must_exist:
|
||||||
|
return None
|
||||||
raise RuntimeError("Package '" + pkgname + "': Could not find aport, and"
|
raise RuntimeError("Package '" + pkgname + "': Could not find aport, and"
|
||||||
" could not find this package in any APKINDEX!")
|
" could not find this package in any APKINDEX!")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue