From 7db4ee53fb5398dd8f4ae8f56778735fe6531178 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Thu, 19 Mar 2015 09:34:58 +0000 Subject: Morph build 2ee8190abe87461992f5b7ed85fe2ee9 System branch: master --- morphlib/util.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'morphlib/util.py') diff --git a/morphlib/util.py b/morphlib/util.py index 6f735387..a3a07cce 100644 --- a/morphlib/util.py +++ b/morphlib/util.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2014 Codethink Limited +# Copyright (C) 2011-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 @@ -10,12 +10,12 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . import contextlib import itertools import os +import pipes import re import subprocess import textwrap @@ -41,7 +41,6 @@ try: from multiprocessing import cpu_count except NotImplementedError: # pragma: no cover cpu_count = lambda: 1 -import os def indent(string, spaces=4): @@ -465,6 +464,10 @@ def get_host_architecture(): # pragma: no cover 'i686': 'x86_32', 'armv7l': 'armv7l', 'armv7b': 'armv7b', + 'armv8l': 'armv8l', + 'armv8b': 'armv8b', + 'aarch64': 'armv8l64', + 'aarch64b': 'armv8b64', 'ppc64': 'ppc64' } @@ -626,3 +629,18 @@ def containerised_cmdline(args, cwd='.', root='/', binds=(), cmdargs.append(root) cmdargs.extend(args) return unshared_cmdline(cmdargs, root=root, **kwargs) + + +def error_message_for_containerised_commandline( + argv, err, container_kwargs): # pragma: no cover + '''Return a semi-readable error message for a containerised command.''' + + # This function should do some formatting of the container_kwargs dict, + # rather than just dumping it in the error message, but that is better than + # nothing. + + argv_string = ' '.join(map(pipes.quote, argv)) + return 'Command failed: %s:\n' \ + 'Containerisation settings: %s\n' \ + 'Error output:\n%s' \ + % (argv_string, container_kwargs, err) -- cgit v1.2.1