repo_missing: return pkgnames, not subpkgnames (!1757)

"breeze-icons" depends on "qt5-qtbase-dev", but
"pmbootstrap repo_missing" should return "qt5-qtbase" instead.

This patch fixes it, as one can see with:
$ pmbootstrap repo_missing --built breeze-icons --overview
This commit is contained in:
Oliver Smith 2019-02-15 15:32:39 +01:00
parent 5dd53a3e0a
commit f3ba0de360
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 34 additions and 18 deletions

View file

@ -32,7 +32,7 @@ import pmb.helpers.pmaports
import pmb.helpers.repo
def get(args, pkgname, arch):
def get(args, pkgname, arch, replace_subpkgnames=False):
""" Find a package in pmaports, and as fallback in the APKINDEXes of the
binary packages.
:param pkgname: package name (e.g. "hello-world")
@ -41,6 +41,8 @@ def get(args, pkgname, arch):
arch to see whether the package exists at all. So make
sure to check the returned arch against what you wanted
with check_arch(). Example: "armhf"
:param replace_subpkgnames: replace all subpkgnames with their main
pkgnames in the depends (see #1733)
:returns: data from the parsed APKBUILD or APKINDEX in the following
format: {"arch": ["noarch"],
"depends": ["busybox-extras", "lddtree", ...],
@ -50,8 +52,9 @@ def get(args, pkgname, arch):
# Cached result
cache_key = "pmb.helpers.package.get"
if (arch in args.cache[cache_key] and
pkgname in args.cache[cache_key][arch]):
return args.cache[cache_key][arch][pkgname]
pkgname in args.cache[cache_key][arch] and
replace_subpkgnames in args.cache[cache_key][arch][pkgname]):
return args.cache[cache_key][arch][pkgname][replace_subpkgnames]
# Find in pmaports
ret = None
@ -59,7 +62,7 @@ def get(args, pkgname, arch):
if pmaport:
ret = {"arch": pmaport["arch"],
"depends": pmb.build._package.get_depends(args, pmaport),
"pkgname": pkgname,
"pkgname": pmaport["pkgname"],
"provides": pmaport["provides"],
"version": pmaport["pkgver"] + "-r" + pmaport["pkgrel"]}
@ -86,11 +89,22 @@ def get(args, pkgname, arch):
if ret and isinstance(ret["arch"], str):
ret["arch"] = [ret["arch"]]
# Replace subpkgnames if desired
if replace_subpkgnames:
depends_new = []
for depend in ret["depends"]:
depend = get(args, depend, arch)["pkgname"]
if depend not in depends_new:
depends_new += [depend]
ret["depends"] = depends_new
# Save to cache and return
if ret:
if arch not in args.cache[cache_key]:
args.cache[cache_key][arch] = {}
args.cache[cache_key][arch][pkgname] = ret
if pkgname not in args.cache[cache_key][arch]:
args.cache[cache_key][arch][pkgname] = {}
args.cache[cache_key][arch][pkgname][replace_subpkgnames] = ret
return ret
# Could not find the package
@ -122,8 +136,10 @@ def depends_recurse(args, pkgname, arch):
for depend in package["depends"]:
if depend not in ret:
queue += [depend]
if pkgname_queue not in ret:
ret += [pkgname_queue]
# Add the pkgname (not possible subpkgname) to ret
if package["pkgname"] not in ret:
ret += [package["pkgname"]]
ret.sort()
# Save to cache and return

View file

@ -120,7 +120,7 @@ def generate_output_format(args, arch, pkgnames):
"depends": ["hello-world"]}] """
ret = []
for pkgname in pkgnames:
entry = pmb.helpers.package.get(args, pkgname, arch)
entry = pmb.helpers.package.get(args, pkgname, arch, True)
ret += [{"pkgname": entry["pkgname"],
"repo": pmb.helpers.pmaports.get_repo(args, pkgname),
"version": entry["version"],

View file

@ -101,10 +101,10 @@ def test_helpers_package_depends_recurse(args):
""" Test pmb.helpers.package.depends_recurse() """
# Put fake data into the pmb.helpers.package.get() cache
cache = {"a": {"depends": ["b", "c"]},
"b": {"depends": []},
"c": {"depends": ["d"]},
"d": {"depends": ["b"]}}
cache = {"a": {False: {"pkgname": "a", "depends": ["b", "c"]}},
"b": {False: {"pkgname": "b", "depends": []}},
"c": {False: {"pkgname": "c", "depends": ["d"]}},
"d": {False: {"pkgname": "d", "depends": ["b"]}}}
args.cache["pmb.helpers.package.get"]["armhf"] = cache
# Normal runs
@ -121,22 +121,22 @@ def test_helpers_package_check_arch_package(args):
""" Test pmb.helpers.package.check_arch(): binary = True """
# Put fake data into the pmb.helpers.package.get() cache
func = pmb.helpers.package.check_arch
cache = {"a": {"arch": []}}
cache = {"a": {False: {"arch": []}}}
args.cache["pmb.helpers.package.get"]["armhf"] = cache
cache["a"]["arch"] = ["all !armhf"]
cache["a"][False]["arch"] = ["all !armhf"]
assert func(args, "a", "armhf") is False
cache["a"]["arch"] = ["all"]
cache["a"][False]["arch"] = ["all"]
assert func(args, "a", "armhf") is True
cache["a"]["arch"] = ["noarch"]
cache["a"][False]["arch"] = ["noarch"]
assert func(args, "a", "armhf") is True
cache["a"]["arch"] = ["armhf"]
cache["a"][False]["arch"] = ["armhf"]
assert func(args, "a", "armhf") is True
cache["a"]["arch"] = ["aarch64"]
cache["a"][False]["arch"] = ["aarch64"]
assert func(args, "a", "armhf") is False