aboutsummaryrefslogtreecommitdiffstats
path: root/meta/files
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-01-13 07:47:47 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-13 00:08:25 +0000
commit2306683634435b990e63020fc5cf91753bbaf7b6 (patch)
tree84ec18c6cdbfb96ee6ed6a8b5b675006fdcb9fae /meta/files
parentbd1557bfd726e44c23ab6220867119c57ac6b596 (diff)
downloadopenembedded-core-contrib-2306683634435b990e63020fc5cf91753bbaf7b6.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. 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.py92
-rw-r--r--meta/files/ext-sdk-prepare.sh8
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 @@
+#!/usr/bin/env python
+
+# Prepare the build system within the extensible SDK
+
+import sys
+import os
+import subprocess
+
+def exec_watch(cmd, **options):
+ """Run program with stdout shown on sys.stdout"""
+ if isinstance(cmd, basestring) and not "shell" in options:
+ options["shell"] = True
+
+ process = subprocess.Popen(
+ cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **options
+ )
+
+ buf = ''
+ while True:
+ out = process.stdout.read(1)
+ if out:
+ sys.stdout.write(out)
+ sys.stdout.flush()
+ buf += out
+ elif out == '' and process.poll() != None:
+ break
+
+ return process.returncode, buf
+
+
+def main():
+ if len(sys.argv) < 2:
+ print('Please specify target to prepare with')
+ return 1
+
+ sdk_targets = ' '.join(sys.argv[1:]).split()
+ print('Preparing SDK for %s...' % ', '.join(sdk_targets))
+
+ ret, out = exec_watch('bitbake %s --setscene-only' % ' '.join(sdk_targets))
+ if ret:
+ return ret
+
+ targetlist = []
+ for target in sdk_targets:
+ if ':' in target:
+ target = target.split(':')[0]
+ if not target in targetlist:
+ targetlist.append(target)
+
+ recipes = []
+ for target in targetlist:
+ try:
+ out = subprocess.check_output(('bitbake -e %s' % target).split(), stderr=subprocess.STDOUT)
+ for line in out.splitlines():
+ if line.startswith('FILE='):
+ splitval = line.rstrip().split('=')
+ if len(splitval) > 1:
+ recipes.append(splitval[1].strip('"'))
+ break
+ except subprocess.CalledProcessError as e:
+ print('ERROR: Failed to get recipe for target %s:\n%s' % (target, e.output))
+ return 1
+
+ try:
+ out = subprocess.check_output('bitbake %s -n' % ' '.join(sdk_targets), stderr=subprocess.STDOUT, shell=True)
+ unexpected = []
+ for line in out.splitlines():
+ if 'Running task' in line:
+ for recipe in recipes:
+ if recipe in line:
+ break
+ else:
+ line = line.split('Running', 1)[-1]
+ unexpected.append(line.rstrip())
+ except subprocess.CalledProcessError as e:
+ print('ERROR: Failed to execute dry-run:\n%s' % e.output)
+ return 1
+
+ if unexpected:
+ print('ERROR: Unexpected tasks left over to be executed:')
+ for line in unexpected:
+ print(' ' + line)
+ return 1
+
+if __name__ == "__main__":
+ try:
+ ret = main()
+ except Exception:
+ ret = 1
+ import traceback
+ traceback.print_exc(5)
+ 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 @@
-#!/bin/sh
-
-# Prepare the build system within the extensible SDK
-
-target_sdk_dir="$1"
-sdk_targets="$2"
-
-bitbake $sdk_targets --setscene-only || exit 1