build: package: proper missing dep error (MR 2388)

When a dependency cannot be found in source or binary packages of the
selected architecture, then don't look for binary packages in other
architectures package indexes.

This leads to a confusing error down the line when building packages for
extra_repos_systemd (and e.g. stable branches), because we don't have
binary packages for all arches that pmbootstrap supports, and so it
tries to fetch a non-existing APKINDEX.

Instead, print a nice error about a non-existing dependency.
This commit is contained in:
Oliver Smith 2024-09-17 01:29:20 +02:00
parent 94d917681e
commit fcbc96b2f1
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 20 additions and 4 deletions

View file

@ -269,7 +269,12 @@ def prioritise_build_queue(disarray: list[BuildQueueItem]) -> list[BuildQueueIte
for dep in item["depends"]: for dep in item["depends"]:
# This might be a subpkgname, replace with the main pkgname # This might be a subpkgname, replace with the main pkgname
# (e.g."linux-pam-dev" -> "linux-pam") # (e.g."linux-pam-dev" -> "linux-pam")
dep = pmb.helpers.package.get(dep, item["arch"])["pkgname"] dep_data = pmb.helpers.package.get(
dep, item["arch"], must_exist=False, try_other_arches=False
)
if not dep_data:
raise NonBugError(f"{item['name']}: dependency not found: {dep}")
dep = dep_data["pkgname"]
if dep in all_pkgnames: if dep in all_pkgnames:
unmet_deps.setdefault(item["name"], []).append(dep) unmet_deps.setdefault(item["name"], []).append(dep)

View file

@ -39,8 +39,18 @@ def get(
) -> dict[str, Any] | None: ... ) -> dict[str, Any] | None: ...
@Cache("pkgname", "arch", "replace_subpkgnames") @overload
def get(pkgname, arch, replace_subpkgnames=False, must_exist=True): def get(
pkgname: str,
arch: Arch,
replace_subpkgnames: bool = False,
must_exist: bool = True,
try_other_arches: bool = True,
) -> dict[str, Any] | None: ...
@Cache("pkgname", "arch", "replace_subpkgnames", "try_other_arches")
def get(pkgname, arch, replace_subpkgnames=False, must_exist=True, try_other_arches=True):
"""Find a package in pmaports, and as fallback in the APKINDEXes of the binary packages. """Find a package in pmaports, and as fallback in the APKINDEXes of the binary packages.
:param pkgname: package name (e.g. "hello-world") :param pkgname: package name (e.g. "hello-world")
@ -51,6 +61,7 @@ def get(pkgname, arch, replace_subpkgnames=False, must_exist=True):
:param replace_subpkgnames: replace all subpkgnames with their main pkgnames in the depends :param replace_subpkgnames: replace all subpkgnames with their main pkgnames in the depends
(see #1733) (see #1733)
:param must_exist: raise an exception, if not found :param must_exist: raise an exception, if not found
:param try_other_arches: set to False to not attempt to find other arches
:returns: * data from the parsed APKBUILD or APKINDEX in the following format: :returns: * data from the parsed APKBUILD or APKINDEX in the following format:
{"arch": ["noarch"], "depends": ["busybox-extras", "lddtree", ...], {"arch": ["noarch"], "depends": ["busybox-extras", "lddtree", ...],
@ -83,7 +94,7 @@ def get(pkgname, arch, replace_subpkgnames=False, must_exist=True):
ret = ret_repo ret = ret_repo
# Find in APKINDEX (other arches) # Find in APKINDEX (other arches)
if not ret: if not ret and try_other_arches:
pmb.helpers.repo.update() pmb.helpers.repo.update()
for arch_i in Arch.supported(): for arch_i in Arch.supported():
if arch_i != arch: if arch_i != arch: