pmb.helpers.pmaports: cache get_list results (!1896)

This commit is contained in:
Daniele Debernardi 2020-03-25 22:42:41 +01:00 committed by Oliver Smith
parent 20de238ff6
commit 11c36fcf65
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
2 changed files with 9 additions and 0 deletions

View File

@ -132,6 +132,7 @@ def add_cache(args):
"pmb.helpers.package.depends_recurse": {},
"pmb.helpers.package.get": {},
"pmb.helpers.pmaports._glob_apkbuilds": {},
"pmb.helpers.pmaports.get_list": {},
"pmb.helpers.repo.update": repo_update})

View File

@ -27,10 +27,18 @@ def _glob_apkbuilds(args, pkgname='*'):
def get_list(args, pkgname='*'):
""" :returns: list of all pmaport pkgnames (["hello-world", ...]) """
# Try to get a cached result first (we assume, that the aports don't change
# in one pmbootstrap call)
if pkgname in args.cache["pmb.helpers.pmaports.get_list"]:
return args.cache["pmb.helpers.pmaports.get_list"][pkgname]
ret = []
for apkbuild in _glob_apkbuilds(args, pkgname):
ret.append(os.path.basename(os.path.dirname(apkbuild)))
ret.sort()
# Save result in cache
args.cache["pmb.helpers.pmaports.get_list"][pkgname] = ret
return ret