diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-01-13 07:47:47 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-01-15 11:54:51 +0000 |
commit | 2e620a4785bf3f3c787e4005911513d9474b9904 (patch) | |
tree | 55f08d5375401da47d18ba8e81fad2131b449bd7 /meta/files | |
parent | 4685c3378d3e6325cb7fee1912ea6b903f7f131a (diff) | |
download | poky-2e620a4785bf3f3c787e4005911513d9474b9904.tar.gz |
classes/populate_sdk_ext: check that extensible SDK prepared correctly
After the change to use --setscene-only when running bitbake to prepare
the SDK at the end of installation, add a check that the SDK got
prepared correctly by doing a dry-run and looking at the output for any
real tasks that we don't expect. In order to make this easier, the
preparation shell script was rewritten in python.
(From OE-Core rev: 2306683634435b990e63020fc5cf91753bbaf7b6)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/files')
-rw-r--r-- | meta/files/ext-sdk-prepare.py | 92 | ||||
-rw-r--r-- | meta/files/ext-sdk-prepare.sh | 8 |
2 files changed, 92 insertions, 8 deletions
diff --git a/meta/files/ext-sdk-prepare.py b/meta/files/ext-sdk-prepare.py new file mode 100644 index 0000000000..143e0feba0 --- /dev/null +++ b/meta/files/ext-sdk-prepare.py | |||
@@ -0,0 +1,92 @@ | |||
1 | #!/usr/bin/env python | ||
2 | |||
3 | # Prepare the build system within the extensible SDK | ||
4 | |||
5 | import sys | ||
6 | import os | ||
7 | import subprocess | ||
8 | |||
9 | def exec_watch(cmd, **options): | ||
10 | """Run program with stdout shown on sys.stdout""" | ||
11 | if isinstance(cmd, basestring) and not "shell" in options: | ||
12 | options["shell"] = True | ||
13 | |||
14 | process = subprocess.Popen( | ||
15 | cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **options | ||
16 | ) | ||
17 | |||
18 | buf = '' | ||
19 | while True: | ||
20 | out = process.stdout.read(1) | ||
21 | if out: | ||
22 | sys.stdout.write(out) | ||
23 | sys.stdout.flush() | ||
24 | buf += out | ||
25 | elif out == '' and process.poll() != None: | ||
26 | break | ||
27 | |||
28 | return process.returncode, buf | ||
29 | |||
30 | |||
31 | def main(): | ||
32 | if len(sys.argv) < 2: | ||
33 | print('Please specify target to prepare with') | ||
34 | return 1 | ||
35 | |||
36 | sdk_targets = ' '.join(sys.argv[1:]).split() | ||
37 | print('Preparing SDK for %s...' % ', '.join(sdk_targets)) | ||
38 | |||
39 | ret, out = exec_watch('bitbake %s --setscene-only' % ' '.join(sdk_targets)) | ||
40 | if ret: | ||
41 | return ret | ||
42 | |||
43 | targetlist = [] | ||
44 | for target in sdk_targets: | ||
45 | if ':' in target: | ||
46 | target = target.split(':')[0] | ||
47 | if not target in targetlist: | ||
48 | targetlist.append(target) | ||
49 | |||
50 | recipes = [] | ||
51 | for target in targetlist: | ||
52 | try: | ||
53 | out = subprocess.check_output(('bitbake -e %s' % target).split(), stderr=subprocess.STDOUT) | ||
54 | for line in out.splitlines(): | ||
55 | if line.startswith('FILE='): | ||
56 | splitval = line.rstrip().split('=') | ||
57 | if len(splitval) > 1: | ||
58 | recipes.append(splitval[1].strip('"')) | ||
59 | break | ||
60 | except subprocess.CalledProcessError as e: | ||
61 | print('ERROR: Failed to get recipe for target %s:\n%s' % (target, e.output)) | ||
62 | return 1 | ||
63 | |||
64 | try: | ||
65 | out = subprocess.check_output('bitbake %s -n' % ' '.join(sdk_targets), stderr=subprocess.STDOUT, shell=True) | ||
66 | unexpected = [] | ||
67 | for line in out.splitlines(): | ||
68 | if 'Running task' in line: | ||
69 | for recipe in recipes: | ||
70 | if recipe in line: | ||
71 | break | ||
72 | else: | ||
73 | line = line.split('Running', 1)[-1] | ||
74 | unexpected.append(line.rstrip()) | ||
75 | except subprocess.CalledProcessError as e: | ||
76 | print('ERROR: Failed to execute dry-run:\n%s' % e.output) | ||
77 | return 1 | ||
78 | |||
79 | if unexpected: | ||
80 | print('ERROR: Unexpected tasks left over to be executed:') | ||
81 | for line in unexpected: | ||
82 | print(' ' + line) | ||
83 | return 1 | ||
84 | |||
85 | if __name__ == "__main__": | ||
86 | try: | ||
87 | ret = main() | ||
88 | except Exception: | ||
89 | ret = 1 | ||
90 | import traceback | ||
91 | traceback.print_exc(5) | ||
92 | sys.exit(ret) | ||
diff --git a/meta/files/ext-sdk-prepare.sh b/meta/files/ext-sdk-prepare.sh deleted file mode 100644 index b3f5d93615..0000000000 --- a/meta/files/ext-sdk-prepare.sh +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Prepare the build system within the extensible SDK | ||
4 | |||
5 | target_sdk_dir="$1" | ||
6 | sdk_targets="$2" | ||
7 | |||
8 | bitbake $sdk_targets --setscene-only || exit 1 | ||