import oelite
from oelite.function import PythonFunction
from oelite.meta import *
import bb.utils
import os


def inlineeval(source, meta, var=None):
    g = meta.get_pythonfunc_globals()
    if var:
        recursion_path = []
        funcimports = {}
        for func in (meta.get_flag(var, "import",
                                   oelite.meta.FULL_EXPANSION)
                     or "").split():
            if func in funcimports:
                continue
            if func in recursion_path:
                raise Exception("circular import %s -> %s"%(recursion_path, func))
            python_function = PythonFunction(meta, func,
                                             recursion_path=recursion_path)
            funcimports[func] = python_function.function
        g.update(funcimports)
    try:
        return eval(source, g, {"d": meta})
    except Exception:
        print "Exception while evaluating inline python code"
        #print "Exception while evaluating inline python code: %s"%(repr(source))
        raise


def exechooks(meta, name, hooks=None):
    if hooks is None:
        hooks = meta.get_hooks(name)
    tmpdir = os.path.join(meta.get("HOOKTMPDIR"), name)
    bb.utils.mkdirhier(tmpdir)
    for function in hooks:
        pn = meta.get("PN")
        if pn:
            name = "%s.%s.%s"%(pn, meta.get("RECIPE_TYPE"), function)
        else:
            name = function
        hook = meta.get_pythonfunc(function, name, tmpdir=tmpdir,
                                   set_ld_library_path=False)
        retval = hook.run(tmpdir)
        if retval is not None and not retval:
            raise oelite.HookFailed(name, function, retval)
    return

@@ -1579,30 +1579,112 @@
  if 
-retval is not None and
+isinstance(retval, basestring):%0A            raise oelite.HookFailed(name, function, retval)%0A        elif
  not

Allow hook functions to return string as error "code"