From 5ed807c064bbcd92bd26d26cd0686545e79b724d Mon Sep 17 00:00:00 2001 From: Minecrell Date: Mon, 1 Nov 2021 09:46:42 +0100 Subject: [PATCH] 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. --- pmb/helpers/pmaports.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pmb/helpers/pmaports.py b/pmb/helpers/pmaports.py index b1c75e46..22860b84 100644 --- a/pmb/helpers/pmaports.py +++ b/pmb/helpers/pmaports.py @@ -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: