diff --git a/pmb/helpers/pmaports.py b/pmb/helpers/pmaports.py index 38aa1af6..3ea6e08a 100644 --- a/pmb/helpers/pmaports.py +++ b/pmb/helpers/pmaports.py @@ -222,20 +222,21 @@ def find(package, must_exist=True, subpackages=True, with_extra_repos="default") # Parse the APKBUILD and verify if the guess was right if _find_package_in_apkbuild(package, guess / "APKBUILD"): ret = guess - else: - # Otherwise parse all APKBUILDs (takes time!), is the - # package we are looking for a subpackage of any of those? - for path_current in _find_apkbuilds().values(): - if _find_package_in_apkbuild(package, path_current): - ret = path_current.parent - break - # If we still didn't find anything, as last resort: assume our - # initial guess was right and the APKBUILD parser just didn't - # find the subpackage in there because it is behind shell logic - # that we don't parse. - if not ret: - ret = guess + if not guess or (guess and not ret): + # Otherwise parse all APKBUILDs (takes time!), is the + # package we are looking for a subpackage of any of those? + for path_current in _find_apkbuilds().values(): + if _find_package_in_apkbuild(package, path_current): + ret = path_current.parent + break + + # If we still didn't find anything, as last resort: assume our + # initial guess was right and the APKBUILD parser just didn't + # find the subpackage in there because it is behind shell logic + # that we don't parse. + if not ret: + ret = guess # Crash when necessary if ret is None and must_exist: