pmb.helpers.pmaports: parse guessed APKBUILD first for speed up (MR 2132)

At the moment we have to parse all APKBUILDs to find subpackages,
even if they are guessed easily shortly after. To speed this up,
let's guess first but verify the guess by only parsing that particular
APKBUILD. If the subpackage/provides is in there we seem to have found it.
This commit is contained in:
Minecrell 2021-11-01 09:46:42 +01:00 committed by Oliver Smith
parent eb3e38d15c
commit 5ed807c064
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
1 changed files with 9 additions and 2 deletions

View File

@ -155,6 +155,13 @@ def find(args, package, must_exist=True):
if path:
ret = os.path.dirname(path)
# Try to guess based on the subpackage name
guess = guess_main(args, package)
if guess:
# ... but see if we were right
if _find_package_in_apkbuild(args, package, f'{guess}/APKBUILD'):
ret = guess
# Search in subpackages and provides
if not ret:
for path_current in _find_apkbuilds(args).values():
@ -162,9 +169,9 @@ def find(args, package, must_exist=True):
ret = os.path.dirname(path_current)
break
# Guess a main package
# Use the guess otherwise
if not ret:
ret = guess_main(args, package)
ret = guess
# Crash when necessary
if ret is None and must_exist: