summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-05-02 15:27:27 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-11 10:33:41 +0100
commit107c35e87ed08c99abad009bb1b9f90e587be56b (patch)
tree2e865a0c075d9f6ba4b629b944464419025e9fa7 /scripts
parentaa4de3c8c5617e8d59cc3085463dc8493edc20df (diff)
downloadpoky-107c35e87ed08c99abad009bb1b9f90e587be56b.tar.gz
combo-layer: runcmd() enhancements
Allow setting the environment. Due to a subprocess quirk, it must always be set explicitly (reuses the one from the previous call if not set, instead of falling back to os.environ). Embedding nul characters will be useful for parsing git output more reliably; support dumping such output a bit better. (From OE-Core rev: 0af4fadafce690fc8357196cf7247bd222c08d10) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/combo-layer6
1 files changed, 3 insertions, 3 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer
index 41d69f8ddb..9297d5973d 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -174,7 +174,7 @@ class Configuration(object):
174 logger.error("ERROR: patchutils package is missing, please install it (e.g. # apt-get install patchutils)") 174 logger.error("ERROR: patchutils package is missing, please install it (e.g. # apt-get install patchutils)")
175 sys.exit(1) 175 sys.exit(1)
176 176
177def runcmd(cmd,destdir=None,printerr=True,out=None): 177def runcmd(cmd,destdir=None,printerr=True,out=None,env=None):
178 """ 178 """
179 execute command, raise CalledProcessError if fail 179 execute command, raise CalledProcessError if fail
180 return output if succeed 180 return output if succeed
@@ -186,7 +186,7 @@ def runcmd(cmd,destdir=None,printerr=True,out=None):
186 else: 186 else:
187 err = os.tmpfile() 187 err = os.tmpfile()
188 try: 188 try:
189 subprocess.check_call(cmd, stdout=out, stderr=err, cwd=destdir, shell=isinstance(cmd, str)) 189 subprocess.check_call(cmd, stdout=out, stderr=err, cwd=destdir, shell=isinstance(cmd, str), env=env or os.environ)
190 except subprocess.CalledProcessError,e: 190 except subprocess.CalledProcessError,e:
191 err.seek(0) 191 err.seek(0)
192 if printerr: 192 if printerr:
@@ -195,7 +195,7 @@ def runcmd(cmd,destdir=None,printerr=True,out=None):
195 195
196 err.seek(0) 196 err.seek(0)
197 output = err.read() 197 output = err.read()
198 logger.debug("output: %s" % output ) 198 logger.debug("output: %s" % output.replace(chr(0), '\\0'))
199 return output 199 return output
200 200
201def action_init(conf, args): 201def action_init(conf, args):