mirror of
https://git.yoctoproject.org/poky
synced 2026-04-21 03:32:12 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
d86862456d
commit
2b918b623b
@@ -392,6 +392,9 @@ def runfetchcmd(cmd, d, quiet = False, cleanup = []):
|
||||
Optionally remove the files/directories listed in cleanup upon failure
|
||||
"""
|
||||
|
||||
import bb.process
|
||||
import subprocess
|
||||
|
||||
# Need to export PATH as binary could be in metadata paths
|
||||
# rather than host provided
|
||||
# Also include some other variables.
|
||||
@@ -409,36 +412,27 @@ def runfetchcmd(cmd, d, quiet = False, cleanup = []):
|
||||
|
||||
logger.debug(1, "Running %s", cmd)
|
||||
|
||||
# redirect stderr to stdout
|
||||
stdout_handle = os.popen(cmd + " 2>&1", "r")
|
||||
output = ""
|
||||
success = False
|
||||
error_message = ""
|
||||
|
||||
while True:
|
||||
line = stdout_handle.readline()
|
||||
if not line:
|
||||
break
|
||||
if not quiet:
|
||||
print(line, end=' ')
|
||||
output += line
|
||||
try:
|
||||
(output, errors) = bb.process.run(cmd, shell=True, stderr=subprocess.PIPE)
|
||||
success = True
|
||||
except bb.process.NotFoundError as e:
|
||||
error_message = "Fetch command %s" % (e.command)
|
||||
except bb.process.CmdError as e:
|
||||
error_message = "Fetch command %s could not be run:\n%s" % (e.command, e.msg)
|
||||
except bb.process.ExecutionError as e:
|
||||
error_message = "Fetch command %s failed with exit code %s, output:\n%s" % (e.command, e.exitcode, e.stderr)
|
||||
|
||||
status = stdout_handle.close() or 0
|
||||
signal = os.WTERMSIG(status)
|
||||
if os.WIFEXITED(status):
|
||||
exitstatus = os.WEXITSTATUS(status)
|
||||
else:
|
||||
exitstatus = 0
|
||||
|
||||
if (signal or status != 0):
|
||||
if not success:
|
||||
for f in cleanup:
|
||||
try:
|
||||
bb.utils.remove(f, True)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if signal:
|
||||
raise FetchError("Fetch command %s failed with signal %s, output:\n%s" % (cmd, signal, output))
|
||||
elif exitstatus:
|
||||
raise FetchError("Fetch command %s failed with exit code %s, output:\n%s" % (cmd, exitstatus, output))
|
||||
raise FetchError(error_message)
|
||||
|
||||
return output
|
||||
|
||||
|
||||
Reference in New Issue
Block a user