"""Execute a python BB 'function'"""
bbfile = d.getVar('FILE', True)
- olddir = os.getcwd()
code = _functionfmt.format(function=func, body=d.getVar(func, True))
bb.utils.mkdirhier(os.path.dirname(runfile))
with open(runfile, 'w') as script:
if cwd:
os.chdir(cwd)
+ try:
+ olddir = os.getcwd()
+ except OSError:
+ olddir = None
try:
comp = utils.better_compile(code, func, bbfile)
raise FuncFailed(func, None)
finally:
- os.chdir(olddir)
+ if cwd and olddir:
+ os.chdir(olddir)
def exec_func_shell(function, d, runfile, cwd=None, fakeroot=False):
"""Execute a shell function from the metadata