diff options
author | Adrien Bustany <adrien.bustany@nokia.com> | 2012-03-02 16:17:43 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-03-02 16:22:46 +0000 |
commit | 2b918b623bf8add454c3726dd4ee189230e6fcbc (patch) | |
tree | 9dc0a1f897ce79ce918a1ec96812211bb972435c /bitbake | |
parent | d86862456da037edca4f6f4722ebeca4e73a38a4 (diff) | |
download | poky-2b918b623bf8add454c3726dd4ee189230e6fcbc.tar.gz |
stderr would previously be appended to stdout, corrupting the result when something was outputed to stderr but exit code was still 0 (non-fatal warning messages). This commit makes the code parse only stdout, but output stderr if an error happened.
(Bitbake rev: 4a480a052f450c4ee061ab0e60a495a45f140cf9)
Signed-off-by: Adrien Bustany <adrien.bustany@nokia.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 07aac4c3a0..42fef69c3c 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -392,6 +392,9 @@ def runfetchcmd(cmd, d, quiet = False, cleanup = []): | |||
392 | Optionally remove the files/directories listed in cleanup upon failure | 392 | Optionally remove the files/directories listed in cleanup upon failure |
393 | """ | 393 | """ |
394 | 394 | ||
395 | import bb.process | ||
396 | import subprocess | ||
397 | |||
395 | # Need to export PATH as binary could be in metadata paths | 398 | # Need to export PATH as binary could be in metadata paths |
396 | # rather than host provided | 399 | # rather than host provided |
397 | # Also include some other variables. | 400 | # Also include some other variables. |
@@ -409,36 +412,27 @@ def runfetchcmd(cmd, d, quiet = False, cleanup = []): | |||
409 | 412 | ||
410 | logger.debug(1, "Running %s", cmd) | 413 | logger.debug(1, "Running %s", cmd) |
411 | 414 | ||
412 | # redirect stderr to stdout | 415 | success = False |
413 | stdout_handle = os.popen(cmd + " 2>&1", "r") | 416 | error_message = "" |
414 | output = "" | 417 | |
415 | 418 | try: | |
416 | while True: | 419 | (output, errors) = bb.process.run(cmd, shell=True, stderr=subprocess.PIPE) |
417 | line = stdout_handle.readline() | 420 | success = True |
418 | if not line: | 421 | except bb.process.NotFoundError as e: |
419 | break | 422 | error_message = "Fetch command %s" % (e.command) |
420 | if not quiet: | 423 | except bb.process.CmdError as e: |
421 | print(line, end=' ') | 424 | error_message = "Fetch command %s could not be run:\n%s" % (e.command, e.msg) |
422 | output += line | 425 | except bb.process.ExecutionError as e: |
423 | 426 | error_message = "Fetch command %s failed with exit code %s, output:\n%s" % (e.command, e.exitcode, e.stderr) | |
424 | status = stdout_handle.close() or 0 | ||
425 | signal = os.WTERMSIG(status) | ||
426 | if os.WIFEXITED(status): | ||
427 | exitstatus = os.WEXITSTATUS(status) | ||
428 | else: | ||
429 | exitstatus = 0 | ||
430 | 427 | ||
431 | if (signal or status != 0): | 428 | if not success: |
432 | for f in cleanup: | 429 | for f in cleanup: |
433 | try: | 430 | try: |
434 | bb.utils.remove(f, True) | 431 | bb.utils.remove(f, True) |
435 | except OSError: | 432 | except OSError: |
436 | pass | 433 | pass |
437 | 434 | ||
438 | if signal: | 435 | raise FetchError(error_message) |
439 | raise FetchError("Fetch command %s failed with signal %s, output:\n%s" % (cmd, signal, output)) | ||
440 | elif exitstatus: | ||
441 | raise FetchError("Fetch command %s failed with exit code %s, output:\n%s" % (cmd, exitstatus, output)) | ||
442 | 436 | ||
443 | return output | 437 | return output |
444 | 438 | ||