From 9d0f1c475117aad8d6c091384b96d7a426598229 Mon Sep 17 00:00:00 2001 From: Paul Sherwood Date: Thu, 15 Jan 2015 19:35:49 +0000 Subject: Log the environment and the whole cmdline that morph runs in build steps And include the chunk name in the build-log name, and force -j1 --- morphlib/builder.py | 5 +++-- morphlib/stagingarea.py | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/morphlib/builder.py b/morphlib/builder.py index 0bb21434..bb214a38 100644 --- a/morphlib/builder.py +++ b/morphlib/builder.py @@ -279,8 +279,8 @@ class ChunkBuilder(BuilderBase): if self.app.settings['build-log-on-stdout'] else None) cache = self.local_artifact_cache - logpath = cache.get_source_metadata_filename( - self.source, self.source.cache_key, 'build-log') + logpath = cache.get_source_metadata_filename(self.source, + self.source.cache_key, self.source.name + '-build-log') _, temppath = tempfile.mkstemp(dir=os.path.dirname(logpath)) @@ -353,6 +353,7 @@ class ChunkBuilder(BuilderBase): if max_jobs is None: max_jobs = self.max_jobs extra_env['MAKEFLAGS'] = '-j%s' % max_jobs + extra_env['MAKEFLAGS'] = '-j1' else: extra_env['MAKEFLAGS'] = '-j1' diff --git a/morphlib/stagingarea.py b/morphlib/stagingarea.py index fd3f6881..f3d8e9f9 100644 --- a/morphlib/stagingarea.py +++ b/morphlib/stagingarea.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2014 Codethink Limited +# Copyright (C) 2012-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -245,8 +245,20 @@ class StagingArea(object): # No cleanup is currently required pass + def log_env(self, log, message, environment=''): # pragma: no cover + '''Log current environment and optional message in chunk build-log''' + logfile = open(log, "a") + env = os.environ if environment == '' else environment + for key in sorted(env): + msg = env[key] if 'PASSWORD' not in key else '(hidden)' + logfile.write('%s=%s\n' % (key, msg)) + logfile.write(message) + logfile.write('\n') + logfile.flush() + def runcmd(self, argv, **kwargs): # pragma: no cover '''Run a command in a chroot in the staging area.''' + assert 'env' not in kwargs kwargs['env'] = dict(self.env) if 'extra_env' in kwargs: @@ -294,6 +306,7 @@ class StagingArea(object): if kwargs.get('logfile') != None: logfile = kwargs.pop('logfile') + self.log_env(logfile, '\n'.join(cmdline), kwargs['env']) teecmd = ['tee', '-a', logfile] exit, out, err = self._app.runcmd_unchecked( cmdline, teecmd, **kwargs) -- cgit v1.2.1