2023-01-22 18:11:10 +00:00
|
|
|
# Copyright 2023 Oliver Smith
|
2020-02-20 20:07:28 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2017-05-26 20:08:45 +00:00
|
|
|
import pmb.aportgen.core
|
2017-10-30 19:56:38 +00:00
|
|
|
import pmb.helpers.git
|
|
|
|
import pmb.helpers.run
|
2017-05-26 20:08:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
def generate(args, pkgname):
|
|
|
|
# Copy original aport
|
2018-09-30 01:53:29 +00:00
|
|
|
prefix = pkgname.split("-")[0]
|
2017-05-26 20:08:45 +00:00
|
|
|
arch = pkgname.split("-")[1]
|
2018-09-30 01:53:29 +00:00
|
|
|
if prefix == "gcc":
|
2021-06-12 22:43:15 +00:00
|
|
|
upstream = pmb.aportgen.core.get_upstream_aport(args, "gcc", arch)
|
2018-09-30 01:53:29 +00:00
|
|
|
based_on = "main/gcc (from Alpine)"
|
2019-02-12 20:57:05 +00:00
|
|
|
elif prefix == "gcc4":
|
2021-08-09 22:15:04 +00:00
|
|
|
upstream = f"{args.aports}/main/gcc4"
|
2019-02-12 20:57:05 +00:00
|
|
|
based_on = "main/gcc4 (from postmarketOS)"
|
2018-09-30 01:53:29 +00:00
|
|
|
elif prefix == "gcc6":
|
2021-08-09 22:15:04 +00:00
|
|
|
upstream = f"{args.aports}/main/gcc6"
|
2018-09-30 01:53:29 +00:00
|
|
|
based_on = "main/gcc6 (from postmarketOS)"
|
|
|
|
else:
|
2021-05-19 19:08:17 +00:00
|
|
|
raise ValueError(f"Invalid prefix '{prefix}', expected gcc, gcc4 or"
|
2018-09-30 01:53:29 +00:00
|
|
|
" gcc6.")
|
2021-08-09 22:15:04 +00:00
|
|
|
pmb.helpers.run.user(args, ["cp", "-r", upstream, f"{args.work}/aportgen"])
|
2017-05-26 20:08:45 +00:00
|
|
|
|
2020-07-29 10:35:08 +00:00
|
|
|
# Rewrite APKBUILD (only building for native covers most use cases and
|
2018-11-08 06:06:21 +00:00
|
|
|
# saves a lot of build time, can be changed on demand)
|
2017-05-26 20:08:45 +00:00
|
|
|
fields = {
|
|
|
|
"pkgname": pkgname,
|
2021-08-09 22:15:04 +00:00
|
|
|
"pkgdesc": f"Stage2 cross-compiler for {arch}",
|
2021-10-16 16:33:27 +00:00
|
|
|
"arch": pmb.config.arch_native,
|
2022-09-11 12:28:20 +00:00
|
|
|
"depends": f"binutils-{arch} mpc1",
|
2021-08-09 21:24:59 +00:00
|
|
|
"makedepends_build": "gcc g++ bison flex texinfo gawk zip"
|
2021-05-19 19:08:17 +00:00
|
|
|
" gmp-dev mpfr-dev mpc1-dev zlib-dev",
|
|
|
|
"makedepends_host": "linux-headers gmp-dev mpfr-dev mpc1-dev isl-dev"
|
|
|
|
f" zlib-dev musl-dev-{arch} binutils-{arch}",
|
2022-09-28 06:32:46 +00:00
|
|
|
"subpackages": "",
|
2018-09-30 01:53:29 +00:00
|
|
|
|
|
|
|
# gcc6: options is already there, so we need to replace it and not only
|
|
|
|
# set it below the header like done below.
|
2022-10-05 17:43:10 +00:00
|
|
|
"options": "!strip",
|
2017-05-26 20:08:45 +00:00
|
|
|
|
|
|
|
"LIBGOMP": "false",
|
|
|
|
"LIBGCC": "false",
|
|
|
|
"LIBATOMIC": "false",
|
|
|
|
"LIBITM": "false",
|
|
|
|
}
|
|
|
|
|
2022-09-28 06:32:46 +00:00
|
|
|
# Latest gcc only, not gcc4 and gcc6
|
|
|
|
if prefix == "gcc":
|
|
|
|
fields["subpackages"] = f"g++-{arch}:gpp" \
|
|
|
|
f" libstdc++-dev-{arch}:libcxx_dev"
|
|
|
|
|
2017-05-26 20:08:45 +00:00
|
|
|
below_header = "CTARGET_ARCH=" + arch + """
|
|
|
|
CTARGET="$(arch_to_hostspec ${CTARGET_ARCH})"
|
2019-12-30 10:46:31 +00:00
|
|
|
LANG_D=false
|
2017-05-26 20:08:45 +00:00
|
|
|
LANG_OBJC=false
|
|
|
|
LANG_JAVA=false
|
|
|
|
LANG_GO=false
|
|
|
|
LANG_FORTRAN=false
|
|
|
|
LANG_ADA=false
|
2022-10-05 17:43:10 +00:00
|
|
|
options="!strip"
|
2017-05-26 20:08:45 +00:00
|
|
|
|
2018-05-13 18:30:02 +00:00
|
|
|
# abuild doesn't try to tries to install "build-base-$CTARGET_ARCH"
|
|
|
|
# when this variable matches "no*"
|
|
|
|
BOOTSTRAP="nobuildbase"
|
|
|
|
|
|
|
|
# abuild will only cross compile when this variable is set, but it
|
|
|
|
# needs to find a valid package database in there for dependency
|
|
|
|
# resolving, so we set it to /.
|
|
|
|
CBUILDROOT="/"
|
|
|
|
|
|
|
|
_cross_configure="--disable-bootstrap --with-sysroot=/usr/$CTARGET"
|
2017-08-12 14:06:02 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
replace_simple = {
|
|
|
|
# Do not package libstdc++, do not add "g++-$ARCH" here (already
|
|
|
|
# did that explicitly in the subpackages variable above, so
|
|
|
|
# pmbootstrap picks it up properly).
|
|
|
|
'*subpackages="$subpackages libstdc++:libcxx:*': None,
|
|
|
|
|
2018-05-13 18:30:02 +00:00
|
|
|
# We set the cross_configure variable at the beginning, so it does not
|
|
|
|
# use CBUILDROOT as sysroot. In the original APKBUILD this is a local
|
|
|
|
# variable, but we make it a global one.
|
|
|
|
'*_cross_configure=*': None,
|
2022-09-11 15:29:53 +00:00
|
|
|
|
|
|
|
# Do not build foreign arch libgcc, we use the one from Alpine (#2168)
|
|
|
|
'_libgcc=true*': '_libgcc=false',
|
2017-05-26 20:08:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-30 01:53:29 +00:00
|
|
|
pmb.aportgen.core.rewrite(args, pkgname, based_on, fields,
|
aportgen: Gracefully handle old aports_upstream (#1291)
In order to get cross-compilers, we generate a few aports (e.g.
binutils-armhf, gcc-armhf) automatically from Alpine's aports.
pmbootstrap was already able to perform a git checkout of Alpine's
aports repository. But it needed to be manually updated. Otherwise
the `pmbootstrap aportgen` command could actually downgrade the aport
instead of updating it to the current version.
After thinking about adding a dedicated pmbootstrap command for
updating git repositories, I thought it would be better to not open
that can of worms (pmbootstrap as general git wrapper? no thanks).
The solution implemented here compares the upstream aport version of
the git checkout of a certain package (e.g. gcc for gcc-armhf) with the
version in Alpine's binary package APKINDEX. When the aport version is
lower than the binary package version, it shows the user how to update
the git repository with just one command:
pmbootstrap chroot --add=git --user -- \
git -C /mnt/pmbootstrap-git/aports_upstream pull
Changes:
* `pmb.aportgen.core.get_upstream_aport()`: new function, that returns
the absolute path to the upstream aport on disk, after checking the
version of the aport against the binary package.
* Use that new function in pmb.aportgen.gcc and pmb.aportgen.binutils
* New function `pmb.helpers.repo.alpine_apkindex_path()`: updates the
APKINDEX if necessary and returns the absolute path to the APKINDEX.
This code was basically present already, but not as function, so now
we have a bit less overhead there.
* `pmbootstrap chroot`: new `--user` argument
* `pmb.parse.apkbuild`: make pkgname check optional, as it fails with
the official gcc APKBUILD before we modify it (the current APKBUILD
parser is not meant to be perfect, as this would require a full shell
parsing implementation).
* Extended `test_aportgen.py` and enabled it by default in
`testcases_fast.sh`. Previously it was disabled due to traffic
concerns (cloning the aports repo, but then again we do a full KDE
plasma mobile installation in Travis now, so that shouldn't matter
too much).
* `testcases_fast.sh`: With "test_aport_in_sync_with_git" removed
from the disabled-by-default list (left over from timestamp based
rebuilds), there were no more test cases disabled by default. I've
changed it, so now the qemu_running_processes test case is disabled,
and added an `--all` parameter to the script to disable no test
cases. Travis runs with the `--all` parameter while it's useful to
do a quick local test without `--all` in roughly 2 minutes instead of
10.
* `aports/cross/binutils-*`: Fix `_mirror` variable to point to current
default Alpine mirror (so the aportgen testcase runs through).
2018-03-11 14:18:21 +00:00
|
|
|
replace_simple=replace_simple,
|
|
|
|
below_header=below_header)
|