]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
build: fix dir removal traceback
authorChris Larson <chris_larson@mentor.com>
Fri, 25 Mar 2011 15:58:52 +0000 (08:58 -0700)
committerChris Larson <chris_larson@mentor.com>
Fri, 25 Mar 2011 15:58:54 +0000 (08:58 -0700)
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>
lib/bb/build.py

index 473857074a2394cfc271ad2f7fcfcbb25345d611..3fb025233fb836162fe158387ebc65ac18459983 100644 (file)
@@ -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