aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/populate_sdk_ext.bbclass2
-rw-r--r--meta/classes/testsdk.bbclass12
-rw-r--r--meta/files/ext-sdk-prepare.py67
3 files changed, 54 insertions, 27 deletions
diff --git a/meta/classes/populate_sdk_ext.bbclass b/meta/classes/populate_sdk_ext.bbclass
index 67297e57ee..5e1a485b5c 100644
--- a/meta/classes/populate_sdk_ext.bbclass
+++ b/meta/classes/populate_sdk_ext.bbclass
@@ -427,7 +427,7 @@ sdk_ext_postinst() {
# current working directory when first ran, nor will it set $1 when
# sourcing a script. That is why this has to look so ugly.
LOGFILE="$target_sdk_dir/preparing_build_system.log"
- 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 ; }
+ 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 $LOGFILE '${SDK_INSTALL_TARGETS}'" || { 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 ; }
rm $target_sdk_dir/ext-sdk-prepare.py
fi
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):
testdir = d.expand("${WORKDIR}/testsdkext/")
bb.utils.remove(testdir, True)
bb.utils.mkdirhier(testdir)
+ sdkdir = os.path.join(testdir, 'tc')
try:
- subprocess.check_output("%s -y -d %s/tc" % (tcname, testdir), shell=True)
+ subprocess.check_output("%s -y -d %s" % (tcname, sdkdir), shell=True)
except subprocess.CalledProcessError as e:
- bb.fatal("Couldn't install the SDK EXT:\n%s" % e.output.decode("utf-8"))
+ msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8")
+ logfn = os.path.join(sdkdir, 'preparing_build_system.log')
+ if os.path.exists(logfn):
+ msg += '\n\nContents of preparing_build_system.log:\n'
+ with open(logfn, 'r') as f:
+ for line in f:
+ msg += line
+ bb.fatal(msg)
try:
bb.plain("Running SDK Compatibility tests ...")
diff --git a/meta/files/ext-sdk-prepare.py b/meta/files/ext-sdk-prepare.py
index 3b33c0f9e9..8b15982843 100644
--- a/meta/files/ext-sdk-prepare.py
+++ b/meta/files/ext-sdk-prepare.py
@@ -5,43 +5,62 @@
import sys
import os
import subprocess
+import signal
-def exec_watch(cmd, **options):
- """Run program with stdout shown on sys.stdout"""
- if isinstance(cmd, str) and not "shell" in options:
- options["shell"] = True
+def reenable_sigint():
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
- 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
+def run_command_interruptible(cmd):
+ """
+ Run a command with output displayed on the console, but ensure any Ctrl+C is
+ processed only by the child process.
+ """
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
+ try:
+ ret = subprocess.call(cmd, shell=True, preexec_fn=reenable_sigint)
+ finally:
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
+ return ret
- return process.returncode, buf
+def get_last_consolelog():
+ '''Return the most recent console log file'''
+ logdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'tmp', 'log', 'cooker')
+ if os.path.exists(logdir):
+ mcdir = os.listdir(logdir)
+ if mcdir:
+ logdir = os.path.join(logdir, mcdir[0])
+ logfiles = [os.path.join(logdir, fn) for fn in os.listdir(logdir)]
+ logfiles.sort(key=os.path.getmtime)
+ if logfiles:
+ return os.path.join(logdir, logfiles[-1])
+ return None
def main():
if len(sys.argv) < 2:
+ print('Please specify output log file')
+ return 1
+ logfile = sys.argv[1]
+ if len(sys.argv) < 3:
sdk_targets = []
else:
- sdk_targets = ' '.join(sys.argv[1:]).split()
+ sdk_targets = ' '.join(sys.argv[2:]).split()
if not sdk_targets:
# Just do a parse so the cache is primed
- ret, _ = exec_watch('bitbake -p')
+ ret = run_command_interruptible('bitbake -p --quiet')
return ret
- print('Preparing SDK for %s...' % ', '.join(sdk_targets))
+ with open(logfile, 'a') as logf:
+ logf.write('Preparing SDK for %s...\n' % ', '.join(sdk_targets))
- ret, out = exec_watch('BB_SETSCENE_ENFORCE=1 bitbake %s' % ' '.join(sdk_targets))
- if ret:
- return ret
+ ret = run_command_interruptible('BB_SETSCENE_ENFORCE=1 bitbake --quiet %s' % ' '.join(sdk_targets))
+ lastlog = get_last_consolelog()
+ if lastlog:
+ with open(lastlog, 'r') as f:
+ for line in f:
+ logf.write(line)
+ if ret:
+ print('ERROR: SDK preparation failed: see %s' % logfile)
+ return ret
if __name__ == "__main__":
try: