Fix confusing error message for invalid makedepends (#540)

This happens currently, when a makedepend is invalid:
ERROR: UnboundLocalError: local variable 'pkgname' referenced before assignment

With this patch, you get the meaning full error that should have been printed instead:
ERROR: Could not find package 'invalid-package' in the aports folder and could not find it in any APKINDEX
This commit is contained in:
Oliver Smith 2017-09-19 19:51:43 +00:00 committed by GitHub
parent 558cd40fbf
commit bf6f5cb884
1 changed files with 3 additions and 2 deletions

View File

@ -25,7 +25,7 @@ import pmb.parse.apkindex
def recurse_error_message(pkgname, in_aports, in_apkindexes):
ret = "Could not find package '" + pkgname + "'"
if in_aports:
ret += " aport"
ret += " in the aports folder"
if in_apkindexes:
ret += " and could not find it"
if in_apkindexes:
@ -64,6 +64,7 @@ def recurse(args, pkgnames, arch=None, in_apkindexes=True, in_aports=True,
# Get depends and pkgname from aports
logging.verbose("Get dependencies of: " + pkgname_depend)
depends = None
pkgname = None
if in_aports:
aport = pmb.build.find_aport(args, pkgname_depend, False)
if aport:
@ -88,7 +89,7 @@ def recurse(args, pkgnames, arch=None, in_apkindexes=True, in_aports=True,
if pkgname is None and strict:
raise RuntimeError(
recurse_error_message(
pkgname,
pkgname_depend,
in_aports,
in_apkindexes))