pmb.build.is_necessary: fix case with Alpine's pkg (!1904)

No build is necessary if pmaport can't be built for given arch.
pmbootstrap must use Alpine's binary package in that case, even if the
pmaport version is higher than Alpine's binary package version.

Fixes: #1897
This commit is contained in:
Oliver Smith 2020-04-04 12:45:22 +02:00
parent 44cb06d345
commit b4a05cbcfb
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
2 changed files with 19 additions and 0 deletions

View File

@ -55,6 +55,13 @@ def is_necessary(args, arch, apkbuild, indexes=None):
logging.debug(msg + "No binary package available")
return True
# Can't build pmaport for arch: use Alpine's package (#1897)
if arch and not pmb.helpers.pmaports.check_arches(apkbuild["arch"], arch):
logging.verbose(f"{package}: build is not necessary, because pmaport"
" can't be built for {arch}. Using Alpine's binary"
" package.")
return False
# a) Binary repo has a newer version
version_old = index_data["version"]
if pmb.parse.version.compare(version_old, version_new) == 1:

View File

@ -73,3 +73,15 @@ def test_build_is_necessary_no_binary_available(args):
aport = pmb.helpers.pmaports.find(args, "hello-world")
apkbuild = pmb.parse.apkbuild(args, aport + "/APKBUILD")
assert pmb.build.is_necessary(args, None, apkbuild, indexes) is True
def test_build_is_necessary_cant_build_pmaport_for_arch(args):
""" pmaport version is higher than Alpine's binary package, but pmaport
can't be built for given arch. (#1897) """
apkbuild = {"pkgname": "alpine-base",
"arch": "armhf", # can't build for x86_64!
"pkgver": "9999",
"pkgrel": "0"}
assert pmb.build.is_necessary(args, "x86_64", apkbuild) is False
assert pmb.build.is_necessary(args, "armhf", apkbuild) is True