diff options
| -rw-r--r-- | bitbake/lib/bb/build.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index 04979acbd3..a4deb00b88 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
| @@ -188,6 +188,11 @@ class LogTee(object): | |||
| 188 | def exec_func(func, d, dirs = None, pythonexception=False): | 188 | def exec_func(func, d, dirs = None, pythonexception=False): |
| 189 | """Execute a BB 'function'""" | 189 | """Execute a BB 'function'""" |
| 190 | 190 | ||
| 191 | try: | ||
| 192 | oldcwd = os.getcwd() | ||
| 193 | except: | ||
| 194 | oldcwd = None | ||
| 195 | |||
| 191 | body = d.getVar(func, False) | 196 | body = d.getVar(func, False) |
| 192 | if not body: | 197 | if not body: |
| 193 | if body is None: | 198 | if body is None: |
| @@ -211,9 +216,7 @@ def exec_func(func, d, dirs = None, pythonexception=False): | |||
| 211 | bb.utils.mkdirhier(adir) | 216 | bb.utils.mkdirhier(adir) |
| 212 | adir = dirs[-1] | 217 | adir = dirs[-1] |
| 213 | else: | 218 | else: |
| 214 | adir = d.getVar('B', True) | 219 | adir = None |
| 215 | bb.utils.mkdirhier(adir) | ||
| 216 | |||
| 217 | ispython = flags.get('python') | 220 | ispython = flags.get('python') |
| 218 | 221 | ||
| 219 | lockflag = flags.get('lockfiles') | 222 | lockflag = flags.get('lockfiles') |
| @@ -257,6 +260,13 @@ def exec_func(func, d, dirs = None, pythonexception=False): | |||
| 257 | else: | 260 | else: |
| 258 | exec_func_shell(func, d, runfile, cwd=adir) | 261 | exec_func_shell(func, d, runfile, cwd=adir) |
| 259 | 262 | ||
| 263 | if oldcwd and os.getcwd() != oldcwd: | ||
| 264 | try: | ||
| 265 | bb.warn("Task %s changed cwd to %s" % (func, os.getcwd())) | ||
| 266 | os.chdir(oldcwd) | ||
| 267 | except: | ||
| 268 | pass | ||
| 269 | |||
| 260 | _functionfmt = """ | 270 | _functionfmt = """ |
| 261 | {function}(d) | 271 | {function}(d) |
| 262 | """ | 272 | """ |
| @@ -272,7 +282,8 @@ def exec_func_python(func, d, runfile, cwd=None, pythonexception=False): | |||
| 272 | if cwd: | 282 | if cwd: |
| 273 | try: | 283 | try: |
| 274 | olddir = os.getcwd() | 284 | olddir = os.getcwd() |
| 275 | except OSError: | 285 | except OSError as e: |
| 286 | bb.warn("%s: Cannot get cwd: %s" % (func, e)) | ||
| 276 | olddir = None | 287 | olddir = None |
| 277 | os.chdir(cwd) | 288 | os.chdir(cwd) |
| 278 | 289 | ||
| @@ -298,8 +309,8 @@ def exec_func_python(func, d, runfile, cwd=None, pythonexception=False): | |||
| 298 | if cwd and olddir: | 309 | if cwd and olddir: |
| 299 | try: | 310 | try: |
| 300 | os.chdir(olddir) | 311 | os.chdir(olddir) |
| 301 | except OSError: | 312 | except OSError as e: |
| 302 | pass | 313 | bb.warn("%s: Cannot restore cwd %s: %s" % (func, olddir, e)) |
| 303 | 314 | ||
| 304 | def shell_trap_code(): | 315 | def shell_trap_code(): |
| 305 | return '''#!/bin/sh\n | 316 | return '''#!/bin/sh\n |
