parent
30d1a5cada
commit
ae97f9d738
|
@ -78,11 +78,19 @@ def get_depends(args, apkbuild):
|
|||
|
||||
:returns: list of dependency pkgnames (eg. ["sdl2", "sdl2_net"])
|
||||
"""
|
||||
# Read makedepends and depends
|
||||
ret = list(apkbuild["makedepends"])
|
||||
if "ignore_depends" not in args or not args.ignore_depends:
|
||||
ret += apkbuild["depends"]
|
||||
ret = sorted(set(ret))
|
||||
|
||||
return sorted(set(ret))
|
||||
# Don't recurse forever when a package depends on itself (#948)
|
||||
for pkgname in [apkbuild["pkgname"]] + list(apkbuild["subpackages"]):
|
||||
if pkgname in ret:
|
||||
logging.verbose(apkbuild["pkgname"] + ": ignoring dependency on"
|
||||
" itself: " + pkgname)
|
||||
ret.remove(pkgname)
|
||||
return ret
|
||||
|
||||
|
||||
def build_depends(args, apkbuild, arch, strict):
|
||||
|
|
|
@ -112,7 +112,8 @@ def test_check_arch(args):
|
|||
|
||||
def test_get_depends(monkeypatch):
|
||||
func = pmb.build._package.get_depends
|
||||
apkbuild = {"depends": ["a"], "makedepends": ["c", "b"]}
|
||||
apkbuild = {"pkgname": "test", "depends": ["a"], "makedepends": ["c", "b"],
|
||||
"subpackages": ["d"]}
|
||||
|
||||
# Depends + makedepends
|
||||
args = args_patched(monkeypatch, ["pmbootstrap", "build", "test"])
|
||||
|
@ -124,11 +125,22 @@ def test_get_depends(monkeypatch):
|
|||
args = args_patched(monkeypatch, ["pmbootstrap", "build", "-i", "test"])
|
||||
assert func(args, apkbuild) == ["b", "c"]
|
||||
|
||||
# Package depends on its own subpackage
|
||||
apkbuild["makedepends"] = ["d"]
|
||||
args = args_patched(monkeypatch, ["pmbootstrap", "build", "test"])
|
||||
assert func(args, apkbuild) == ["a"]
|
||||
|
||||
# Package depends on itself
|
||||
apkbuild["makedepends"] = ["c", "b", "test"]
|
||||
args = args_patched(monkeypatch, ["pmbootstrap", "build", "test"])
|
||||
assert func(args, apkbuild) == ["a", "b", "c"]
|
||||
|
||||
|
||||
def test_build_depends(args, monkeypatch):
|
||||
# Shortcut and fake apkbuild
|
||||
func = pmb.build._package.build_depends
|
||||
apkbuild = {"pkgname": "test", "depends": ["a"], "makedepends": ["b"]}
|
||||
apkbuild = {"pkgname": "test", "depends": ["a"], "makedepends": ["b"],
|
||||
"subpackages": ["d"]}
|
||||
|
||||
# No depends built (first makedepends + depends, then only makedepends)
|
||||
monkeypatch.setattr(pmb.build._package, "package", return_none)
|
||||
|
|
Loading…
Reference in New Issue