Skip to content
Snippets Groups Projects
Unverified Commit e2354ec2 authored by Jens Reidel's avatar Jens Reidel
Browse files

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: default avatarJens Reidel <adrian@travitia.xyz>
parent 9ca0ada5
Branches
Tags
1 merge request!2476Support ppc64le and fix cross architecture bootstrapping
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment