summaryrefslogtreecommitdiff
path: root/morphlib/app.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-09 13:04:26 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-09 13:58:53 +0000
commit7e67d265288dee88018475fb72e63dcca14e494c (patch)
tree6bdc9d5e52fbcffbb387bb14a4da55b869ac4189 /morphlib/app.py
parentcb880f3554d9cf8daa3839dcd7a7ed2c336df85b (diff)
downloadmorph-7e67d265288dee88018475fb72e63dcca14e494c.tar.gz
Give less scary error messages when a containerised command fails
This affects errors encountered at build time and at system-integration time. New errors look like this: ERROR: Command failed: baserock/system-integration/02-install-gerrit-gerrit-installation-binaries-misc-0000: Containerisation settings: {'mounts': (('dev/shm', 'tmpfs', 'none'), ('tmp', 'tmpfs', 'none')), 'mount_proc': True, 'root': '/var/tmp/staging/tmp1YQ2yN/minimal-system-x86_64-generic.inst'} Error output: + install -D /usr/share/gerrit/gerrit-2.9.war /home/gerrit2/gerrit/gerrit-2.9.war -o gerrit2 -g gerrit2 -m 644 install: can't change ownership of /home/gerrit2/gerrit/gerrit-2.9.war: Operation not permitted Previously the error message would have been this: Command failed: unshare --mount -- sh -ec. mount --make-rprivate / root="$1" shift while true; do case "$1" in --) shift break ;; *) mount_point="$1" mount_type="$2" mount_source="$3" shift 3 path="$root/$mount_point" mount -t "$mount_type" "$mount_source" "$path" ;; esac done exec "$@" - /var/tmp/staging/tmppeA1Iw/gerrit-x86_64.inst/ dev/shm tmpfs none tmp tmpfs none -- linux-user-chroot --chdir . --mount-proc proc /var/tmp/staging/tmppeA1Iw/gerrit-x86_64.inst/ baserock/system-integration/02-install-gerrit-gerrit-installation-binaries-misc-0000 + install -D /usr/share/gerrit/gerrit-2.9.war /home/gerrit2/gerrit/gerrit-2.9.war -o gerrit2 -g gerrit2 -m 644 install: can't change ownership of /home/gerrit2/gerrit/gerrit-2.9.war: Operation not permitted
Diffstat (limited to 'morphlib/app.py')
-rw-r--r--morphlib/app.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index 930e023d..b5bcb601 100644
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -348,7 +348,7 @@ class Morph(cliapp.Application):
self.output.write('%s %s\n' % (timestamp, text))
self.output.flush()
- def runcmd(self, argv, *args, **kwargs):
+ def _prepare_for_runcmd(self, argv, args, kwargs):
if 'env' not in kwargs:
kwargs['env'] = dict(os.environ)
@@ -377,9 +377,14 @@ class Morph(cliapp.Application):
morphlib.util.log_environment_changes(self, kwargs['env'], prev)
self.prev_env = kwargs['env']
- # run the command line
+ def runcmd(self, argv, *args, **kwargs):
+ self._prepare_for_runcmd(argv, args, kwargs)
return cliapp.Application.runcmd(self, argv, *args, **kwargs)
+ def runcmd_unchecked(self, argv, *args, **kwargs):
+ self._prepare_for_runcmd(argv, args, kwargs)
+ return cliapp.Application.runcmd_unchecked(self, argv, *args, **kwargs)
+
def parse_args(self, args, configs_only=False):
return self.settings.parse_args(args,
configs_only=configs_only,