diff options
author | Paul Sherwood <paul.sherwood@codethink.co.uk> | 2015-01-15 19:35:49 +0000 |
---|---|---|
committer | Paul Sherwood <paul.sherwood@codethink.co.uk> | 2015-03-16 07:34:50 +0000 |
commit | 9d0f1c475117aad8d6c091384b96d7a426598229 (patch) | |
tree | 65decc3f7693db0ee5c7302c336d13ff9e5c5235 | |
parent | 0761c88989af492ea2c48b9612cb856d53de3992 (diff) | |
download | morph-baserock/ps/log-env-and-full-cmdline.tar.gz |
Log the environment and the whole cmdline that morph runs in build stepsbaserock/ps/log-env-and-full-cmdline
And include the chunk name in the build-log name, and force -j1
-rw-r--r-- | morphlib/builder.py | 5 | ||||
-rw-r--r-- | 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) |