pkg resolver: don't guess if pmaport was found
If we found an APKBUILD already, with the exact name of the package we are looking for, then don't also guess what other package could contain the package as subpackage. The guess was thrown away with the previous logic, but it caused misleading verbose logs like: lomiri-history-service: guessed to be a subpackage of lomiri Also this is slightly faster. While at it, tweak the related comments to make this easier to understand. Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20231121222457.2871-1-ollieparanoid@postmarketos.org%3E
This commit is contained in:
parent
8b8f25227f
commit
bcfdc3fb1b
|
@ -153,28 +153,32 @@ def find(args, package, must_exist=True):
|
|||
if "*" in package:
|
||||
raise RuntimeError("Invalid pkgname: " + package)
|
||||
|
||||
# Search in packages
|
||||
# Try to find an APKBUILD with the exact pkgname we are looking for
|
||||
path = _find_apkbuilds(args).get(package)
|
||||
if path:
|
||||
ret = os.path.dirname(path)
|
||||
else:
|
||||
# No luck, take a guess what APKBUILD could have the package we are
|
||||
# looking for as subpackage
|
||||
guess = guess_main(args, package)
|
||||
if guess:
|
||||
# Parse the APKBUILD and verify if the guess was right
|
||||
if _find_package_in_apkbuild(package, f'{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(args).values():
|
||||
if _find_package_in_apkbuild(package, path_current):
|
||||
ret = os.path.dirname(path_current)
|
||||
break
|
||||
|
||||
# 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(package, f'{guess}/APKBUILD'):
|
||||
ret = guess
|
||||
|
||||
# Search in subpackages and provides
|
||||
if not ret:
|
||||
for path_current in _find_apkbuilds(args).values():
|
||||
if _find_package_in_apkbuild(package, path_current):
|
||||
ret = os.path.dirname(path_current)
|
||||
break
|
||||
|
||||
# Use the guess otherwise
|
||||
if not ret:
|
||||
ret = guess
|
||||
# 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:
|
||||
|
|
Loading…
Reference in New Issue