summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-06-24 00:07:03 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-08 09:57:23 +0100
commita702c68c5bd7ab25d74d861bb0dc88249d4d742e (patch)
treeb80be7833fdbda0c22162aec62c5b8c73f4f9a9c
parentc24b6512d73ca54fb0e053e55fc8e0a501d8df0e (diff)
downloadpoky-a702c68c5bd7ab25d74d861bb0dc88249d4d742e.tar.gz
classes/populate_sdk_ext: eliminate double execution on install
Use the new BB_SETSCENE_ENFORCE functionality to avoid having to run bitbake twice on installing the extensible SDK - we can now do it all in one invocation which not only takes less time, but we should also get more meaningful errors for some types of failure, in particular where downloading from an sstate mirror fails. One result of this change is that you get the errors printed on the console during normal output rather than this going to the preparing_build_system.log file first. In OE-Core revision 227d2cbf9e0b8c35fa6644e3d72e0699db9607fa, we changed to always print the contents of preparing_build_system.log on failure, but now at least the error contents of that log is duplicated. Besides, I intentionally didn't print out the contents of that log during normal usage because it's quite verbose - the bug that we were attempting to fix was about not getting this information when seeing failures in the automated tests, thus I've moved printing the log to the test handling code instead. Part of the implementation of [YOCTO #9367]. (From OE-Core rev: e1390c1ef85862b91b067ab24f3c06ca506155ad) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/populate_sdk_ext.bbclass7
-rw-r--r--meta/classes/testsdk.bbclass12
-rw-r--r--meta/files/ext-sdk-prepare.py52
3 files changed, 16 insertions, 55 deletions
diff --git a/meta/classes/populate_sdk_ext.bbclass b/meta/classes/populate_sdk_ext.bbclass
index b9d9543409..df39ff60f1 100644
--- a/meta/classes/populate_sdk_ext.bbclass
+++ b/meta/classes/populate_sdk_ext.bbclass
@@ -223,10 +223,13 @@ python copy_buildsystem () {
223 # warning. 223 # warning.
224 f.write('SIGGEN_LOCKEDSIGS_SSTATE_EXISTS_CHECK = "none"\n\n') 224 f.write('SIGGEN_LOCKEDSIGS_SSTATE_EXISTS_CHECK = "none"\n\n')
225 225
226 # Error if the sigs in the locked-signature file don't match 226 # Warn if the sigs in the locked-signature file don't match
227 # the sig computed from the metadata. 227 # the sig computed from the metadata.
228 f.write('SIGGEN_LOCKEDSIGS_TASKSIG_CHECK = "warn"\n\n') 228 f.write('SIGGEN_LOCKEDSIGS_TASKSIG_CHECK = "warn"\n\n')
229 229
230 # Set up whitelist for run on install
231 f.write('BB_SETSCENE_ENFORCE_WHITELIST = "%:* *:do_shared_workdir *:do_rm_work"\n\n')
232
230 # Hide the config information from bitbake output (since it's fixed within the SDK) 233 # Hide the config information from bitbake output (since it's fixed within the SDK)
231 f.write('BUILDCFG_HEADER = ""\n') 234 f.write('BUILDCFG_HEADER = ""\n')
232 235
@@ -424,7 +427,7 @@ sdk_ext_postinst() {
424 # current working directory when first ran, nor will it set $1 when 427 # current working directory when first ran, nor will it set $1 when
425 # sourcing a script. That is why this has to look so ugly. 428 # sourcing a script. That is why this has to look so ugly.
426 LOGFILE="$target_sdk_dir/preparing_build_system.log" 429 LOGFILE="$target_sdk_dir/preparing_build_system.log"
427 sh -c ". buildtools/environment-setup* > $LOGFILE && cd $target_sdk_dir/`dirname ${oe_init_build_env_path}` && set $target_sdk_dir && . $target_sdk_dir/${oe_init_build_env_path} $target_sdk_dir >> $LOGFILE && python $target_sdk_dir/ext-sdk-prepare.py '${SDK_INSTALL_TARGETS}' >> $LOGFILE 2>&1" || { echo "ERROR: SDK preparation failed: see $LOGFILE"; cat "$LOGFILE"; echo "printf 'ERROR: this SDK was not fully installed and needs reinstalling\n'" >> $env_setup_script ; exit 1 ; } 430 sh -c ". buildtools/environment-setup* > $LOGFILE && cd $target_sdk_dir/`dirname ${oe_init_build_env_path}` && set $target_sdk_dir && . $target_sdk_dir/${oe_init_build_env_path} $target_sdk_dir >> $LOGFILE && python $target_sdk_dir/ext-sdk-prepare.py '${SDK_INSTALL_TARGETS}' >> $LOGFILE 2>&1" || { echo "ERROR: SDK preparation failed: see $LOGFILE for a slightly more detailed log"; echo "printf 'ERROR: this SDK was not fully installed and needs reinstalling\n'" >> $env_setup_script ; exit 1 ; }
428 rm $target_sdk_dir/ext-sdk-prepare.py 431 rm $target_sdk_dir/ext-sdk-prepare.py
429 fi 432 fi
430 echo done 433 echo done
diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass
index 18f7678d37..0b8716edb5 100644
--- a/meta/classes/testsdk.bbclass
+++ b/meta/classes/testsdk.bbclass
@@ -113,10 +113,18 @@ def testsdkext_main(d):
113 testdir = d.expand("${WORKDIR}/testsdkext/") 113 testdir = d.expand("${WORKDIR}/testsdkext/")
114 bb.utils.remove(testdir, True) 114 bb.utils.remove(testdir, True)
115 bb.utils.mkdirhier(testdir) 115 bb.utils.mkdirhier(testdir)
116 sdkdir = os.path.join(testdir, 'tc')
116 try: 117 try:
117 subprocess.check_output("%s -y -d %s/tc" % (tcname, testdir), shell=True) 118 subprocess.check_output("%s -y -d %s" % (tcname, sdkdir), shell=True)
118 except subprocess.CalledProcessError as e: 119 except subprocess.CalledProcessError as e:
119 bb.fatal("Couldn't install the SDK EXT:\n%s" % e.output.decode("utf-8")) 120 msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8")
121 logfn = os.path.join(sdkdir, 'preparing_build_system.log')
122 if os.path.exists(logfn):
123 msg += '\n\nContents of preparing_build_system.log:\n'
124 with open(logfn, 'r') as f:
125 for line in f:
126 msg += line
127 bb.fatal(msg)
120 128
121 try: 129 try:
122 bb.plain("Running SDK Compatibility tests ...") 130 bb.plain("Running SDK Compatibility tests ...")
diff --git a/meta/files/ext-sdk-prepare.py b/meta/files/ext-sdk-prepare.py
index bf0d03336b..3b33c0f9e9 100644
--- a/meta/files/ext-sdk-prepare.py
+++ b/meta/files/ext-sdk-prepare.py
@@ -27,22 +27,6 @@ def exec_watch(cmd, **options):
27 27
28 return process.returncode, buf 28 return process.returncode, buf
29 29
30def check_unexpected(lines, recipes):
31 """Check for unexpected output lines from dry run"""
32 unexpected = []
33 for line in lines.splitlines():
34 if 'Running task' in line:
35 for recipe in recipes:
36 if recipe in line:
37 break
38 else:
39 line = line.split('Running', 1)[-1]
40 if 'do_rm_work' not in line:
41 unexpected.append(line.rstrip())
42 elif 'Running setscene' in line:
43 unexpected.append(line.rstrip())
44 return unexpected
45
46def main(): 30def main():
47 if len(sys.argv) < 2: 31 if len(sys.argv) < 2:
48 sdk_targets = [] 32 sdk_targets = []
@@ -55,44 +39,10 @@ def main():
55 39
56 print('Preparing SDK for %s...' % ', '.join(sdk_targets)) 40 print('Preparing SDK for %s...' % ', '.join(sdk_targets))
57 41
58 ret, out = exec_watch('bitbake %s --setscene-only' % ' '.join(sdk_targets)) 42 ret, out = exec_watch('BB_SETSCENE_ENFORCE=1 bitbake %s' % ' '.join(sdk_targets))
59 if ret: 43 if ret:
60 return ret 44 return ret
61 45
62 targetlist = []
63 for target in sdk_targets:
64 if ':' in target:
65 target = target.split(':')[0]
66 if not target in targetlist:
67 targetlist.append(target)
68
69 recipes = []
70 for target in targetlist:
71 try:
72 out = subprocess.check_output(('bitbake -e %s' % target).split(), stderr=subprocess.STDOUT)
73 for line in out.splitlines():
74 if line.startswith('FILE='):
75 splitval = line.rstrip().split('=')
76 if len(splitval) > 1:
77 recipes.append(splitval[1].strip('"'))
78 break
79 except subprocess.CalledProcessError as e:
80 print('ERROR: Failed to get recipe for target %s:\n%s' % (target, e.output))
81 return 1
82
83 try:
84 out = subprocess.check_output('bitbake %s -n' % ' '.join(sdk_targets), stderr=subprocess.STDOUT, shell=True)
85 unexpected = check_unexpected(out, recipes)
86 except subprocess.CalledProcessError as e:
87 print('ERROR: Failed to execute dry-run:\n%s' % e.output)
88 return 1
89
90 if unexpected:
91 print('ERROR: Unexpected tasks or setscene left over to be executed:')
92 for line in unexpected:
93 print(' ' + line)
94 return 1
95
96if __name__ == "__main__": 46if __name__ == "__main__":
97 try: 47 try:
98 ret = main() 48 ret = main()