mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 00:59:48 +00:00
build: fix dir removal traceback
This one is to cover the case where the current directory vanishes out from under us, so os.getcwd() raises an OSError. (Bitbake rev: 7a29ab534388c0095f7f826b16c5cff343927d10) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
8b938dc82c
commit
2d73cd1d32
@@ -182,16 +182,16 @@ def exec_func_python(func, d, runfile, cwd=None):
|
|||||||
"""Execute a python BB 'function'"""
|
"""Execute a python BB 'function'"""
|
||||||
|
|
||||||
bbfile = d.getVar('FILE', True)
|
bbfile = d.getVar('FILE', True)
|
||||||
try:
|
|
||||||
olddir = os.getcwd()
|
|
||||||
except OSError:
|
|
||||||
olddir = None
|
|
||||||
code = _functionfmt.format(function=func, body=d.getVar(func, True))
|
code = _functionfmt.format(function=func, body=d.getVar(func, True))
|
||||||
bb.utils.mkdirhier(os.path.dirname(runfile))
|
bb.utils.mkdirhier(os.path.dirname(runfile))
|
||||||
with open(runfile, 'w') as script:
|
with open(runfile, 'w') as script:
|
||||||
script.write(code)
|
script.write(code)
|
||||||
|
|
||||||
if cwd:
|
if cwd:
|
||||||
|
try:
|
||||||
|
olddir = os.getcwd()
|
||||||
|
except OSError:
|
||||||
|
olddir = None
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -203,8 +203,11 @@ def exec_func_python(func, d, runfile, cwd=None):
|
|||||||
|
|
||||||
raise FuncFailed(func, None)
|
raise FuncFailed(func, None)
|
||||||
finally:
|
finally:
|
||||||
if olddir:
|
if cwd and olddir:
|
||||||
os.chdir(olddir)
|
try:
|
||||||
|
os.chdir(olddir)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
def exec_func_shell(function, d, runfile, cwd=None):
|
def exec_func_shell(function, d, runfile, cwd=None):
|
||||||
"""Execute a shell function from the metadata
|
"""Execute a shell function from the metadata
|
||||||
|
|||||||
Reference in New Issue
Block a user