repo_missing: don't check arch recursively (!1820)
Remove the recursive check, as it caused an infinite loop. It took a
very long time to complete anyway, even when it worked. The reasoning
for having the recursive check in the first place was, that we would
have device packages with arch=noarch set in the APKBUILD, but which
could only be built for a certain architecture (the device
architecture). Nowadays using arch=noarch in device packages is
forbidden, and we enforce that rule [1]. So the recursive arch check
isn't necessary anymore.
[1] ac6c0a2997
This commit is contained in:
parent
80a7fe8aaf
commit
925c56febe
|
@ -25,7 +25,6 @@ Functions that work on both pmaports and (binary package) repos. See also:
|
||||||
- pmb/helpers/repo.py (work on binary package repos)
|
- pmb/helpers/repo.py (work on binary package repos)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import pmb.helpers.pmaports
|
import pmb.helpers.pmaports
|
||||||
|
@ -171,21 +170,3 @@ def check_arch(args, pkgname, arch, binary=True):
|
||||||
else:
|
else:
|
||||||
arches = pmb.helpers.pmaports.get(args, pkgname)["arch"]
|
arches = pmb.helpers.pmaports.get(args, pkgname)["arch"]
|
||||||
return pmb.helpers.pmaports.check_arches(arches, arch)
|
return pmb.helpers.pmaports.check_arches(arches, arch)
|
||||||
|
|
||||||
|
|
||||||
def check_arch_recurse(args, pkgname, arch):
|
|
||||||
""" Recursively check if a package and its dependencies exist (binary repo)
|
|
||||||
or can be built (pmaports) for a certain architecture.
|
|
||||||
:param pkgname: name of the package
|
|
||||||
:param arch: architecture to check against
|
|
||||||
:returns: True when all the package's dependencies can be built or
|
|
||||||
exist for the arch in question
|
|
||||||
"""
|
|
||||||
for pkgname_i in depends_recurse(args, pkgname, arch):
|
|
||||||
if not check_arch(args, pkgname_i, arch):
|
|
||||||
if pkgname_i != pkgname:
|
|
||||||
logging.verbose(pkgname + ": (indirectly) depends on " +
|
|
||||||
pkgname_i)
|
|
||||||
logging.verbose(pkgname_i + ": can't be built for " + arch)
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
|
@ -54,16 +54,14 @@ def filter_aport_packages(args, arch, pkgnames):
|
||||||
|
|
||||||
def filter_arch_packages(args, arch, pkgnames):
|
def filter_arch_packages(args, arch, pkgnames):
|
||||||
""" Create a subset of pkgnames with packages removed that can not be
|
""" Create a subset of pkgnames with packages removed that can not be
|
||||||
built for a certain arch. The check is recursive, if one of the
|
built for a certain arch.
|
||||||
dependencies of a package can not be built for the arch in question,
|
|
||||||
then it will not be in the final list either.
|
|
||||||
|
|
||||||
:param arch: architecture (e.g. "armhf")
|
:param arch: architecture (e.g. "armhf")
|
||||||
:param pkgnames: list of package names (e.g. ["hello-world", "test12"])
|
:param pkgnames: list of package names (e.g. ["hello-world", "test12"])
|
||||||
:returns: subset of pkgnames (e.g. ["hello-world"]) """
|
:returns: subset of pkgnames (e.g. ["hello-world"]) """
|
||||||
ret = []
|
ret = []
|
||||||
for pkgname in pkgnames:
|
for pkgname in pkgnames:
|
||||||
if pmb.helpers.package.check_arch_recurse(args, pkgname, arch):
|
if pmb.helpers.package.check_arch(args, pkgname, arch, False):
|
||||||
ret += [pkgname]
|
ret += [pkgname]
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -77,11 +75,8 @@ def get_relevant_packages(args, arch, pkgname=None, built=False):
|
||||||
:returns: an alphabetically sorted list of pkgnames, e.g.:
|
:returns: an alphabetically sorted list of pkgnames, e.g.:
|
||||||
["devicepkg-dev", "hello-world", "osk-sdl"] """
|
["devicepkg-dev", "hello-world", "osk-sdl"] """
|
||||||
if pkgname:
|
if pkgname:
|
||||||
if not pmb.helpers.package.check_arch_recurse(args, pkgname, arch):
|
if not pmb.helpers.package.check_arch(args, pkgname, arch, False):
|
||||||
raise RuntimeError(pkgname + " can't be built for " + arch + "."
|
raise RuntimeError(pkgname + " can't be built for " + arch + ".")
|
||||||
" Either itself or one if its dependencies is"
|
|
||||||
" not available for that architecture. Run with"
|
|
||||||
" -v for details.")
|
|
||||||
ret = pmb.helpers.package.depends_recurse(args, pkgname, arch)
|
ret = pmb.helpers.package.depends_recurse(args, pkgname, arch)
|
||||||
else:
|
else:
|
||||||
ret = pmb.helpers.pmaports.get_list(args)
|
ret = pmb.helpers.pmaports.get_list(args)
|
||||||
|
@ -144,8 +139,8 @@ def generate(args, arch, overview, pkgname=None, built=False):
|
||||||
"""
|
"""
|
||||||
# Log message
|
# Log message
|
||||||
packages_str = pkgname if pkgname else "all packages"
|
packages_str = pkgname if pkgname else "all packages"
|
||||||
logging.info("Calculate packages that need to be built ({}, {}) - this may"
|
logging.info("Calculate packages that need to be built ({}, {})"
|
||||||
" take some time".format(packages_str, arch))
|
"".format(packages_str, arch))
|
||||||
|
|
||||||
# Order relevant packages
|
# Order relevant packages
|
||||||
ret = get_relevant_packages(args, arch, pkgname, built)
|
ret = get_relevant_packages(args, arch, pkgname, built)
|
||||||
|
|
|
@ -154,32 +154,3 @@ def test_helpers_package_check_arch_pmaports(args, monkeypatch):
|
||||||
|
|
||||||
fake_pmaport["arch"] = ["all", "!armhf"]
|
fake_pmaport["arch"] = ["all", "!armhf"]
|
||||||
assert func(args, "a", "armhf", False) is False
|
assert func(args, "a", "armhf", False) is False
|
||||||
|
|
||||||
|
|
||||||
def test_helpers_package_check_arch_recurse(args, monkeypatch):
|
|
||||||
""" Test pmb.helpers.package.check_arch_recurse() """
|
|
||||||
# Test data
|
|
||||||
func = pmb.helpers.package.check_arch_recurse
|
|
||||||
depends = ["a", "b", "c"]
|
|
||||||
arch_check_results = {}
|
|
||||||
|
|
||||||
def fake_depends_recurse(args, pkgname, arch):
|
|
||||||
return depends
|
|
||||||
monkeypatch.setattr(pmb.helpers.package, "depends_recurse",
|
|
||||||
fake_depends_recurse)
|
|
||||||
|
|
||||||
def fake_check_arch(args, pkgname, arch):
|
|
||||||
return arch_check_results[pkgname]
|
|
||||||
monkeypatch.setattr(pmb.helpers.package, "check_arch", fake_check_arch)
|
|
||||||
|
|
||||||
# Result: True
|
|
||||||
arch_check_results = {"a": True,
|
|
||||||
"b": True,
|
|
||||||
"c": True}
|
|
||||||
assert func(args, "a", "armhf") is True
|
|
||||||
|
|
||||||
# Result: False
|
|
||||||
arch_check_results = {"a": True,
|
|
||||||
"b": False,
|
|
||||||
"c": True}
|
|
||||||
assert func(args, "a", "armhf") is False
|
|
||||||
|
|
|
@ -79,9 +79,9 @@ def test_filter_arch_packages(args, monkeypatch):
|
||||||
func = pmb.helpers.repo_missing.filter_arch_packages
|
func = pmb.helpers.repo_missing.filter_arch_packages
|
||||||
check_arch = None
|
check_arch = None
|
||||||
|
|
||||||
def stub(args, arch, pmaport):
|
def stub(args, arch, pmaport, binary=True):
|
||||||
return check_arch
|
return check_arch
|
||||||
monkeypatch.setattr(pmb.helpers.package, "check_arch_recurse", stub)
|
monkeypatch.setattr(pmb.helpers.package, "check_arch", stub)
|
||||||
|
|
||||||
check_arch = False
|
check_arch = False
|
||||||
assert func(args, "armhf", ["hello-world"]) == []
|
assert func(args, "armhf", ["hello-world"]) == []
|
||||||
|
@ -94,15 +94,15 @@ def test_get_relevant_packages(args, monkeypatch):
|
||||||
""" Test ...repo_missing.get_relevant_packages() """
|
""" Test ...repo_missing.get_relevant_packages() """
|
||||||
|
|
||||||
# Set up fake return values
|
# Set up fake return values
|
||||||
stub_data = {"check_arch_recurse": False,
|
stub_data = {"check_arch": False,
|
||||||
"depends_recurse": ["a", "b", "c", "d"],
|
"depends_recurse": ["a", "b", "c", "d"],
|
||||||
"filter_arch_packages": ["a", "b", "c"],
|
"filter_arch_packages": ["a", "b", "c"],
|
||||||
"filter_aport_packages": ["b", "a"],
|
"filter_aport_packages": ["b", "a"],
|
||||||
"filter_missing_packages": ["a"]}
|
"filter_missing_packages": ["a"]}
|
||||||
|
|
||||||
def stub(args, arch, pmaport):
|
def stub(args, arch, pmaport, binary=True):
|
||||||
return stub_data["check_arch_recurse"]
|
return stub_data["check_arch"]
|
||||||
monkeypatch.setattr(pmb.helpers.package, "check_arch_recurse", stub)
|
monkeypatch.setattr(pmb.helpers.package, "check_arch", stub)
|
||||||
|
|
||||||
def stub(args, arch, pmaport):
|
def stub(args, arch, pmaport):
|
||||||
return stub_data["depends_recurse"]
|
return stub_data["depends_recurse"]
|
||||||
|
@ -133,7 +133,7 @@ def test_get_relevant_packages(args, monkeypatch):
|
||||||
assert "can't be built" in str(e.value)
|
assert "can't be built" in str(e.value)
|
||||||
|
|
||||||
# Package can be built for given arch
|
# Package can be built for given arch
|
||||||
stub_data["check_arch_recurse"] = True
|
stub_data["check_arch"] = True
|
||||||
assert func(args, "armhf", "a") == ["a"]
|
assert func(args, "armhf", "a") == ["a"]
|
||||||
assert func(args, "armhf", "a", True) == ["a", "b"]
|
assert func(args, "armhf", "a", True) == ["a", "b"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue