Add "pmbootstrap build --no-depends" (!1769)
Aborts the build if any dependencies would have to be build first. This is useful for build.postmarketos.org, because we want to build exactly one package in one build job. If dependencies would need to be built, we made a mistake earlier, and not aborting the build makes it harder to find that orginal mistake.
This commit is contained in:
parent
f23afed228
commit
7f9bfee722
|
@ -140,8 +140,17 @@ def build_depends(args, apkbuild, arch, strict):
|
||||||
logging.verbose(pkgname + ": build/install dependencies: " +
|
logging.verbose(pkgname + ": build/install dependencies: " +
|
||||||
", ".join(depends))
|
", ".join(depends))
|
||||||
|
|
||||||
# Build them
|
# --no-depends: check for binary packages
|
||||||
depends_built = []
|
depends_built = []
|
||||||
|
if "no_depends" in args and args.no_depends:
|
||||||
|
for depend in depends:
|
||||||
|
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.")
|
||||||
|
else:
|
||||||
|
# Build the dependencies
|
||||||
for depend in depends:
|
for depend in depends:
|
||||||
if package(args, depend, arch, strict=strict):
|
if package(args, depend, arch, strict=strict):
|
||||||
depends_built += [depend]
|
depends_built += [depend]
|
||||||
|
|
|
@ -496,6 +496,9 @@ def arguments():
|
||||||
" you don't need to build and install the kernel. But it"
|
" you don't need to build and install the kernel. But it"
|
||||||
" is incompatible with how Alpine's abuild handles it.",
|
" is incompatible with how Alpine's abuild handles it.",
|
||||||
dest="ignore_depends")
|
dest="ignore_depends")
|
||||||
|
build.add_argument("-n", "--no-depends", action="store_true",
|
||||||
|
help="never build dependencies, abort instead",
|
||||||
|
dest="no_depends")
|
||||||
build.add_argument("--envkernel", action="store_true",
|
build.add_argument("--envkernel", action="store_true",
|
||||||
help="Create an apk package from the build output of"
|
help="Create an apk package from the build output of"
|
||||||
" a kernel compiled with envkernel.sh.")
|
" a kernel compiled with envkernel.sh.")
|
||||||
|
|
|
@ -174,6 +174,26 @@ def test_build_depends(args, monkeypatch):
|
||||||
assert func(args, apkbuild, "armhf", False) == (["a", "b"], ["a", "b"])
|
assert func(args, apkbuild, "armhf", False) == (["a", "b"], ["a", "b"])
|
||||||
|
|
||||||
|
|
||||||
|
def test_build_depends_no_binary_error(args, monkeypatch):
|
||||||
|
# Shortcut and fake apkbuild
|
||||||
|
func = pmb.build._package.build_depends
|
||||||
|
apkbuild = {"pkgname": "test", "depends": ["some-invalid-package-here"],
|
||||||
|
"makedepends": [], "checkdepends": [], "subpackages": [],
|
||||||
|
"options": []}
|
||||||
|
|
||||||
|
# pmbootstrap build --no-depends
|
||||||
|
args.no_depends = True
|
||||||
|
|
||||||
|
# Missing binary package error
|
||||||
|
with pytest.raises(RuntimeError) as e:
|
||||||
|
func(args, apkbuild, "armhf", True)
|
||||||
|
assert str(e.value).startswith("Missing binary package for dependency")
|
||||||
|
|
||||||
|
# All depends exist
|
||||||
|
apkbuild["depends"] = ["alpine-base"]
|
||||||
|
assert func(args, apkbuild, "armhf", True) == (["alpine-base"], [])
|
||||||
|
|
||||||
|
|
||||||
def test_is_necessary_warn_depends(args, monkeypatch):
|
def test_is_necessary_warn_depends(args, monkeypatch):
|
||||||
# Shortcut and fake apkbuild
|
# Shortcut and fake apkbuild
|
||||||
func = pmb.build._package.is_necessary_warn_depends
|
func = pmb.build._package.is_necessary_warn_depends
|
||||||
|
|
Loading…
Reference in New Issue