pmb.aportgen: use correct arch for gcc aportgen (MR 2068)

Previously it always used native (x84_64) arch for apkindex
version check.

As pmb.aportgen.core.alpine_apkindex_path() already has arch
parameter, use it to look up correct APKINDEX.

Also fixup test.
This commit is contained in:
Alexey Min 2021-06-13 01:43:15 +03:00
parent aa2c740810
commit 4a8fac6c6e
No known key found for this signature in database
GPG Key ID: EBF5ECFFFEE34DED
3 changed files with 6 additions and 5 deletions

View File

@ -152,11 +152,12 @@ def rewrite(args, pkgname, path_original="", fields={}, replace_pkgname=None,
handle.truncate()
def get_upstream_aport(args, pkgname):
def get_upstream_aport(args, pkgname, arch=None):
"""
Perform a git checkout of Alpine's aports and get the path to the aport.
:param pkgname: package name
:param arch: Alpine architecture (e.g. "armhf"), defaults to native arch
:returns: absolute path on disk where the Alpine aport is checked out
example: /opt/pmbootstrap_work/cache_git/aports/upstream/main/gcc
"""
@ -196,7 +197,7 @@ def get_upstream_aport(args, pkgname):
split = aport_path.split("/")
repo = split[-2]
pkgname = split[-1]
index_path = pmb.helpers.repo.alpine_apkindex_path(args, repo)
index_path = pmb.helpers.repo.alpine_apkindex_path(args, repo, arch)
package = pmb.parse.apkindex.package(args, pkgname, indexes=[index_path])
# Compare version (return when equal)

View File

@ -10,7 +10,7 @@ def generate(args, pkgname):
prefix = pkgname.split("-")[0]
arch = pkgname.split("-")[1]
if prefix == "gcc":
upstream = pmb.aportgen.core.get_upstream_aport(args, "gcc")
upstream = pmb.aportgen.core.get_upstream_aport(args, "gcc", arch)
based_on = "main/gcc (from Alpine)"
elif prefix == "gcc4":
upstream = args.aports + "/main/gcc4"

View File

@ -36,7 +36,7 @@ def test_aportgen_compare_output(args, tmpdir, monkeypatch):
testdata = pmb_test.const.testdata + "/aportgen"
# Override get_upstream_aport() to point to testdata
def func(args, upstream_path):
def func(args, upstream_path, arch=None):
return testdata + "/aports/main/" + upstream_path
monkeypatch.setattr(pmb.aportgen.core, "get_upstream_aport", func)
@ -60,7 +60,7 @@ def test_aportgen_fork_alpine_compare_output(args, tmpdir, monkeypatch):
args.fork_alpine = True
# Override get_upstream_aport() to point to testdata
def func(args, upstream_path):
def func(args, upstream_path, arch=None):
return testdata + "/aports/main/" + upstream_path
monkeypatch.setattr(pmb.aportgen.core, "get_upstream_aport", func)