pmb build --no-depends: stop on outdated pkgs too (!1900)

The --no-depends option is supposed to stop pmbootstrap if it was
instructed to build a package, but a dependency must be built first. So
far, this only covers the case if there is no binary package for a dependency.
Make it stop if the binary package exists, but is outdated, too.

Fixes: #1895
This commit is contained in:
Oliver Smith 2020-03-31 22:50:51 +02:00 committed by Minecrell
parent 4e31ddcdd8
commit 44cb06d345
No known key found for this signature in database
GPG Key ID: B77CE638A6C2E562
2 changed files with 39 additions and 0 deletions

View File

@ -129,11 +129,19 @@ def build_depends(args, apkbuild, arch, strict):
if "no_depends" in args and args.no_depends:
pmb.helpers.repo.update(args, arch)
for depend in depends:
# Check if binary package is missing
if not pmb.parse.apkindex.package(args, depend, arch, False):
raise RuntimeError("Missing binary package for dependency '" +
depend + "' of '" + pkgname + "', but"
" pmbootstrap won't build any depends since"
" it was started with --no-depends.")
# Check if binary package is outdated
apkbuild_dep = get_apkbuild(args, depend, arch)
if apkbuild_dep and pmb.build.is_necessary(args, arch, apkbuild_dep):
raise RuntimeError(f"Binary package for dependency '{depend}'"
f" of '{pkgname}' is outdated, but"
f" pmbootstrap won't build any depends"
f" since it was started with --no-depends.")
else:
# Build the dependencies
for depend in depends:

View File

@ -172,6 +172,37 @@ def test_build_depends_no_binary_error(args, monkeypatch):
assert func(args, apkbuild, "armhf", True) == (["alpine-base"], [])
def test_build_depends_binary_outdated(args, monkeypatch):
""" pmbootstrap runs with --no-depends and dependency binary package is
outdated (#1895) """
# Override pmb.parse.apkindex.package(): pretend hello-world is missing
# and binutils-aarch64 is outdated
func_orig = pmb.parse.apkindex.package
def func_patch(args, package, *args2, **kwargs):
print(f"func_patch: called for package: {package}")
if package == "hello-world":
print(f"pretending that it does not exist")
return None
if package == "binutils-aarch64":
print(f"pretending that it is outdated")
ret = func_orig(args, package, *args2, **kwargs)
ret["version"] = "0-r0"
return ret
return func_orig(args, package, *args2, **kwargs)
monkeypatch.setattr(pmb.parse.apkindex, "package", func_patch)
# Build hello-world with --no-depends and expect failure
args.no_depends = True
pkgname = "hello-world"
arch = "aarch64"
force = False
strict = True
with pytest.raises(RuntimeError) as e:
pmb.build.package(args, pkgname, arch, force, strict)
assert "'binutils-aarch64' of 'gcc-aarch64' is outdated" in str(e.value)
def test_is_necessary_warn_depends(args, monkeypatch):
# Shortcut and fake apkbuild
func = pmb.build._package.is_necessary_warn_depends