diff options
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/build.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index bbf3ae1729..80bb887383 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
@@ -182,16 +182,16 @@ def exec_func_python(func, d, runfile, cwd=None): | |||
182 | """Execute a python BB 'function'""" | 182 | """Execute a python BB 'function'""" |
183 | 183 | ||
184 | bbfile = d.getVar('FILE', True) | 184 | bbfile = d.getVar('FILE', True) |
185 | try: | ||
186 | olddir = os.getcwd() | ||
187 | except OSError: | ||
188 | olddir = None | ||
189 | code = _functionfmt.format(function=func, body=d.getVar(func, True)) | 185 | code = _functionfmt.format(function=func, body=d.getVar(func, True)) |
190 | bb.utils.mkdirhier(os.path.dirname(runfile)) | 186 | bb.utils.mkdirhier(os.path.dirname(runfile)) |
191 | with open(runfile, 'w') as script: | 187 | with open(runfile, 'w') as script: |
192 | script.write(code) | 188 | script.write(code) |
193 | 189 | ||
194 | if cwd: | 190 | if cwd: |
191 | try: | ||
192 | olddir = os.getcwd() | ||
193 | except OSError: | ||
194 | olddir = None | ||
195 | os.chdir(cwd) | 195 | os.chdir(cwd) |
196 | 196 | ||
197 | try: | 197 | try: |
@@ -203,8 +203,11 @@ def exec_func_python(func, d, runfile, cwd=None): | |||
203 | 203 | ||
204 | raise FuncFailed(func, None) | 204 | raise FuncFailed(func, None) |
205 | finally: | 205 | finally: |
206 | if olddir: | 206 | if cwd and olddir: |
207 | os.chdir(olddir) | 207 | try: |
208 | os.chdir(olddir) | ||
209 | except OSError: | ||
210 | pass | ||
208 | 211 | ||
209 | def exec_func_shell(function, d, runfile, cwd=None): | 212 | def exec_func_shell(function, d, runfile, cwd=None): |
210 | """Execute a shell function from the metadata | 213 | """Execute a shell function from the metadata |