diff options
Diffstat (limited to 'scripts/lib/compatlayer/__init__.py')
-rw-r--r-- | scripts/lib/compatlayer/__init__.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/scripts/lib/compatlayer/__init__.py b/scripts/lib/compatlayer/__init__.py index 86f86eb657..9eb862dc6b 100644 --- a/scripts/lib/compatlayer/__init__.py +++ b/scripts/lib/compatlayer/__init__.py | |||
@@ -4,6 +4,7 @@ | |||
4 | # Released under the MIT license (see COPYING.MIT) | 4 | # Released under the MIT license (see COPYING.MIT) |
5 | 5 | ||
6 | import os | 6 | import os |
7 | import subprocess | ||
7 | from enum import Enum | 8 | from enum import Enum |
8 | 9 | ||
9 | class LayerType(Enum): | 10 | class LayerType(Enum): |
@@ -199,8 +200,20 @@ def add_layer(bblayersconf, layer, layers, logger): | |||
199 | 200 | ||
200 | return True | 201 | return True |
201 | 202 | ||
203 | def check_command(error_msg, cmd): | ||
204 | ''' | ||
205 | Run a command under a shell, capture stdout and stderr in a single stream, | ||
206 | throw an error when command returns non-zero exit code. Returns the output. | ||
207 | ''' | ||
208 | |||
209 | p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | ||
210 | output, _ = p.communicate() | ||
211 | if p.returncode: | ||
212 | msg = "%s\nCommand: %s\nOutput:\n%s" % (error_msg, cmd, output.decode('utf-8')) | ||
213 | raise RuntimeError(msg) | ||
214 | return output | ||
215 | |||
202 | def get_signatures(builddir, failsafe=False): | 216 | def get_signatures(builddir, failsafe=False): |
203 | import subprocess | ||
204 | import re | 217 | import re |
205 | 218 | ||
206 | # some recipes needs to be excluded like meta-world-pkgdata | 219 | # some recipes needs to be excluded like meta-world-pkgdata |
@@ -214,12 +227,8 @@ def get_signatures(builddir, failsafe=False): | |||
214 | if failsafe: | 227 | if failsafe: |
215 | cmd += '-k ' | 228 | cmd += '-k ' |
216 | cmd += '-S none world' | 229 | cmd += '-S none world' |
217 | p = subprocess.Popen(cmd, shell=True, | 230 | check_command('Generating signatures failed. This might be due to some parse error and/or general layer incompatibilities.', |
218 | stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 231 | cmd) |
219 | output, _ = p.communicate() | ||
220 | if p.returncode: | ||
221 | msg = "Generating signatures failed. This might be due to some parse error and/or general layer incompatibilities.\nCommand: %s\nOutput:\n%s" % (cmd, output.decode('utf-8')) | ||
222 | raise RuntimeError(msg) | ||
223 | sigs_file = os.path.join(builddir, 'locked-sigs.inc') | 232 | sigs_file = os.path.join(builddir, 'locked-sigs.inc') |
224 | 233 | ||
225 | sig_regex = re.compile("^(?P<task>.*:.*):(?P<hash>.*) .$") | 234 | sig_regex = re.compile("^(?P<task>.*:.*):(?P<hash>.*) .$") |