From 44cb06d345ecd7e22b15c5b9062edd8ac18c8b99 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Tue, 31 Mar 2020 22:50:51 +0200 Subject: [PATCH] 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 --- pmb/build/_package.py | 8 ++++++++ test/test_build_package.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/pmb/build/_package.py b/pmb/build/_package.py index 727d892c..3f53fc52 100644 --- a/pmb/build/_package.py +++ b/pmb/build/_package.py @@ -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: diff --git a/test/test_build_package.py b/test/test_build_package.py index 1e491e7c..829a71fa 100644 --- a/test/test_build_package.py +++ b/test/test_build_package.py @@ -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