summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-03-25 08:58:52 -0700
committerChris Larson <chris_larson@mentor.com>2011-03-25 08:58:54 -0700
commit7a29ab534388c0095f7f826b16c5cff343927d10 (patch)
treeb30f8b5483c4264a16264c0c3d1ec4b9e2f4c4c9
parent416d24912fcef1d82ce2c02855accd86a29e76b2 (diff)
downloadbitbake-7a29ab534388c0095f7f826b16c5cff343927d10.tar.gz
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. Signed-off-by: Chris Larson <chris_larson@mentor.com>
-rw-r--r--lib/bb/build.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 473857074..3fb025233 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -181,7 +181,6 @@ def exec_func_python(func, d, runfile, cwd=None):
"""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:
@@ -189,6 +188,10 @@ def exec_func_python(func, d, runfile, cwd=None):
if cwd:
os.chdir(cwd)
+ try:
+ olddir = os.getcwd()
+ except OSError:
+ olddir = None
try:
comp = utils.better_compile(code, func, bbfile)
@@ -199,7 +202,8 @@ def exec_func_python(func, d, runfile, cwd=None):
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