summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py40
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