forked from Mirror/pmbootstrap
helpers: pmaports: Fix package detection for cross g++ and musl-dev (MR 2476)
g++ is a subpackage of gcc, but cannot be detected as such easily by pmbootstrap. This is because g++ is not gcc-g++ or any other variant of such package names. Similarly, the detection for musl-dev-ppc64le and other architectures is broken, since the -dev suffix detection does not work if there is an architecture suffix. To fix it, add special case handling for cross toolchain and packages and have that fixup the -dev cases and hardcode g++ as a subpackage of gcc. To reproduce: - Generate ppc64le cross packages: pmbootstrap aportgen gcc-ppc64le musl-ppc64le - Build a package (to trigger building cross compilers): pmbootstrap build hello-world --arch=ppc64le Signed-off-by: Jens Reidel <adrian@travitia.xyz>
This commit is contained in:
parent
9ca0ada582
commit
e2354ec26f
1 changed files with 35 additions and 0 deletions
|
@ -68,6 +68,35 @@ def guess_main_dev(subpkgname: str) -> Path | None:
|
|||
return None
|
||||
|
||||
|
||||
def guess_main_cross(subpkgname: str) -> Path | None:
|
||||
"""Check if a subpackage that is part of the cross toolchain is in pmaports or not, and log the appropriate message.
|
||||
|
||||
Don't call this function directly, use guess_main() instead.
|
||||
|
||||
:param subpkgname: subpackage name
|
||||
:returns: full path to the pmaport or None
|
||||
"""
|
||||
# If it contains -dev-, assume the parent package is the same, without the infix
|
||||
if "-dev-" in subpkgname:
|
||||
pkgname = subpkgname.replace("-dev-", "-")
|
||||
else:
|
||||
pkgname = subpkgname.replace("g++", "gcc")
|
||||
|
||||
path = _find_apkbuilds().get(pkgname)
|
||||
if path:
|
||||
logging.verbose(subpkgname + ": guessed to be a subpackage of " + pkgname)
|
||||
return path.parent
|
||||
|
||||
logging.verbose(
|
||||
subpkgname
|
||||
+ ": guessed to be a subpackage of "
|
||||
+ pkgname
|
||||
+ ", which we can't find in pmaports, so it's probably in"
|
||||
" Alpine"
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
def guess_main(subpkgname: str) -> Path | None:
|
||||
"""Find the main package by assuming it is a prefix of the subpkgname.
|
||||
|
||||
|
@ -90,6 +119,12 @@ def guess_main(subpkgname: str) -> Path | None:
|
|||
if subpkgname.endswith("-dev"):
|
||||
return guess_main_dev(subpkgname)
|
||||
|
||||
# cross/* packages have a bunch of subpackages that do not have the main
|
||||
# package name as a prefix (i.e. g++-*). Further, the -dev check fails here
|
||||
# since the name ends with the name of the architecture.
|
||||
if any(subpkgname.endswith("-" + str(arch)) for arch in Arch.supported()):
|
||||
return guess_main_cross(subpkgname)
|
||||
|
||||
# Iterate until the cut up subpkgname is gone
|
||||
words = subpkgname.split("-")
|
||||
while len(words) > 1:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue