pmb.helpers.pmaports: search apkbuild path only if package exists (!1896)

This commit is contained in:
Daniele Debernardi 2020-03-25 22:32:53 +01:00 committed by Oliver Smith
parent 0c179a5cf9
commit 20de238ff6
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -44,11 +44,12 @@ def guess_main_dev(args, subpkgname):
:returns: full path to the pmaport or None :returns: full path to the pmaport or None
""" """
pkgname = subpkgname[:-4] pkgname = subpkgname[:-4]
paths = _glob_apkbuilds(args, pkgname) if pkgname in get_list(args):
if paths: paths = _glob_apkbuilds(args, pkgname)
logging.debug(subpkgname + ": guessed to be a subpackage of " + if paths:
pkgname + " (just removed '-dev')") logging.debug(subpkgname + ": guessed to be a subpackage of " +
return os.path.dirname(paths[0]) pkgname + " (just removed '-dev')")
return os.path.dirname(paths[0])
logging.debug(subpkgname + ": guessed to be a subpackage of " + pkgname + logging.debug(subpkgname + ": guessed to be a subpackage of " + pkgname +
", which we can't find in pmaports, so it's probably in" ", which we can't find in pmaports, so it's probably in"
@ -86,11 +87,12 @@ def guess_main(args, subpkgname):
pkgname = "-".join(words) pkgname = "-".join(words)
# Look in pmaports # Look in pmaports
paths = _glob_apkbuilds(args, pkgname) if pkgname in get_list(args):
if paths: paths = _glob_apkbuilds(args, pkgname)
logging.debug(subpkgname + ": guessed to be a subpackage of " + if paths:
pkgname) logging.debug(subpkgname + ": guessed to be a subpackage of " +
return os.path.dirname(paths[0]) pkgname)
return os.path.dirname(paths[0])
def find(args, package, must_exist=True): def find(args, package, must_exist=True):
@ -112,13 +114,14 @@ def find(args, package, must_exist=True):
raise RuntimeError("Invalid pkgname: " + package) raise RuntimeError("Invalid pkgname: " + package)
# Search in packages # Search in packages
paths = _glob_apkbuilds(args, package) if package in get_list(args):
if len(paths) > 1: paths = _glob_apkbuilds(args, package)
raise RuntimeError("Package " + package + " found in multiple" if len(paths) > 1:
" aports subfolders. Please put it only in one" raise RuntimeError("Package " + package + " found in multiple"
" folder.") " aports subfolders. Please put it only in one"
elif len(paths) == 1: " folder.")
ret = os.path.dirname(paths[0]) elif len(paths) == 1:
ret = os.path.dirname(paths[0])
# Search in subpackages and provides # Search in subpackages and provides
if not ret: if not ret: