From 9a72ea8f6d08c929a01a1015e58eb58cc3b9646c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 9 Nov 2016 08:50:37 +0100 Subject: [PATCH] lorax-wrapper: Put all log files into compose logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tell lorax to use a specific directory for log files so that we preserve them despite koji not having any idea about them. Fixes: #457 Signed-off-by: Lubomír Sedlář --- pungi/phases/buildinstall.py | 12 ++++++++++-- pungi/wrappers/lorax.py | 6 +++++- tests/test_buildinstall.py | 30 ++++++++++++++++++++---------- tests/test_lorax_wrapper.py | 4 +++- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py index 556635f9..6ed2a847 100644 --- a/pungi/phases/buildinstall.py +++ b/pungi/phases/buildinstall.py @@ -28,7 +28,7 @@ from productmd.images import Image from pungi.arch import get_valid_arches from pungi.util import get_buildroot_rpms, get_volid, get_arch_variant_data -from pungi.util import get_file_size, get_mtime, failable +from pungi.util import get_file_size, get_mtime, failable, makedirs from pungi.wrappers.lorax import LoraxWrapper from pungi.wrappers.kojiwrapper import KojiWrapper from pungi.wrappers import iso @@ -64,6 +64,13 @@ class BuildinstallPhase(PhaseBase): if not data.get('nomacboot', True): nomacboot = False output_dir = os.path.join(output_dir, variant.uid) + + # The paths module will modify the filename (by inserting arch). But we + # only care about the directory anyway. + log_filename = 'buildinstall-%s-logs/dumym' % variant.uid + log_dir = os.path.dirname(self.compose.paths.log.log_file(arch, log_filename)) + makedirs(log_dir) + lorax = LoraxWrapper() lorax_cmd = lorax.get_lorax_cmd(self.compose.conf["release_name"], self.compose.conf["release_version"], @@ -77,7 +84,8 @@ class BuildinstallPhase(PhaseBase): volid=volid, nomacboot=nomacboot, bugurl=bugurl, - noupgrade=noupgrade) + noupgrade=noupgrade, + log_dir=log_dir) return 'rm -rf %s && %s' % (pipes.quote(output_dir), ' '.join([pipes.quote(x) for x in lorax_cmd])) diff --git a/pungi/wrappers/lorax.py b/pungi/wrappers/lorax.py index 8f249fd3..12263fa9 100644 --- a/pungi/wrappers/lorax.py +++ b/pungi/wrappers/lorax.py @@ -25,7 +25,8 @@ class LoraxWrapper(object): variant=None, bugurl=None, nomacboot=False, noupgrade=False, is_final=False, buildarch=None, volid=None, buildinstallpackages=None, add_template=None, add_arch_template=None, - add_template_var=None, add_arch_template_var=None): + add_template_var=None, add_arch_template_var=None, + log_dir=None): cmd = ["lorax"] cmd.append("--product=%s" % product) cmd.append("--version=%s" % version) @@ -63,6 +64,9 @@ class LoraxWrapper(object): cmd.extend(process_args('--add-template-var=%s', add_template_var)) cmd.extend(process_args('--add-arch-template-var=%s', add_arch_template_var)) + if log_dir: + cmd.append('--logfile=%s' % os.path.join(log_dir, 'lorax.log')) + output_dir = os.path.abspath(output_dir) cmd.append(output_dir) diff --git a/tests/test_buildinstall.py b/tests/test_buildinstall.py index 15491c56..00f7aa42 100644 --- a/tests/test_buildinstall.py +++ b/tests/test_buildinstall.py @@ -88,17 +88,20 @@ class TestBuildinstallPhase(PungiTestCase): self.topdir + '/work/x86_64/buildinstall/Server', buildarch='x86_64', is_final=True, nomacboot=True, noupgrade=True, volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'], - bugurl=None), + bugurl=None, + log_dir=self.topdir + '/logs/x86_64/buildinstall-Server-logs'), mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo', self.topdir + '/work/amd64/buildinstall/Server', buildarch='amd64', is_final=True, nomacboot=True, noupgrade=True, volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'], - bugurl=None), + bugurl=None, + log_dir=self.topdir + '/logs/amd64/buildinstall-Server-logs'), mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo', self.topdir + '/work/amd64/buildinstall/Client', buildarch='amd64', is_final=True, nomacboot=True, noupgrade=True, volid='vol_id', variant='Client', buildinstallpackages=[], - bugurl=None)]) + bugurl=None, + log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')]) self.assertItemsEqual( get_volid.mock_calls, [mock.call(compose, 'x86_64', variant=compose.variants['Server'], disc_type='DVD'), @@ -139,7 +142,8 @@ class TestBuildinstallPhase(PungiTestCase): self.topdir + '/work/amd64/buildinstall/Client', buildarch='amd64', is_final=True, nomacboot=True, noupgrade=True, volid='vol_id', variant='Client', buildinstallpackages=[], - bugurl=None)], + bugurl=None, + log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')], any_order=True) self.assertItemsEqual( get_volid.mock_calls, @@ -229,17 +233,20 @@ class TestBuildinstallPhase(PungiTestCase): self.topdir + '/work/x86_64/buildinstall/Server', buildarch='x86_64', is_final=True, nomacboot=True, noupgrade=True, volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'], - bugurl='http://example.com'), + bugurl='http://example.com', + log_dir=self.topdir + '/logs/x86_64/buildinstall-Server-logs'), mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo', self.topdir + '/work/amd64/buildinstall/Server', buildarch='amd64', is_final=True, nomacboot=True, noupgrade=False, volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'], - bugurl=None), + bugurl=None, + log_dir=self.topdir + '/logs/amd64/buildinstall-Server-logs'), mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo', self.topdir + '/work/amd64/buildinstall/Client', buildarch='amd64', is_final=True, nomacboot=False, noupgrade=True, volid='vol_id', variant='Client', buildinstallpackages=[], - bugurl=None)]) + bugurl=None, + log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')]) self.assertItemsEqual( get_volid.mock_calls, [mock.call(compose, 'x86_64', variant=compose.variants['Server'], disc_type='dvd'), @@ -289,17 +296,20 @@ class TestBuildinstallPhase(PungiTestCase): self.topdir + '/work/x86_64/buildinstall/Server', buildarch='x86_64', is_final=True, nomacboot=False, noupgrade=False, volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'], - bugurl=None), + bugurl=None, + log_dir=self.topdir + '/logs/x86_64/buildinstall-Server-logs'), mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo', self.topdir + '/work/amd64/buildinstall/Server', buildarch='amd64', is_final=True, nomacboot=True, noupgrade=False, volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'], - bugurl=None), + bugurl=None, + log_dir=self.topdir + '/logs/amd64/buildinstall-Server-logs'), mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo', self.topdir + '/work/amd64/buildinstall/Client', buildarch='amd64', is_final=True, nomacboot=True, noupgrade=False, volid='vol_id', variant='Client', buildinstallpackages=[], - bugurl=None)]) + bugurl=None, + log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')]) self.assertItemsEqual( get_volid.mock_calls, [mock.call(compose, 'x86_64', variant=compose.variants['Server'], disc_type='dvd'), diff --git a/tests/test_lorax_wrapper.py b/tests/test_lorax_wrapper.py index 0dfd6cdf..8dc1a4dd 100644 --- a/tests/test_lorax_wrapper.py +++ b/tests/test_lorax_wrapper.py @@ -41,7 +41,8 @@ class LoraxWrapperTest(unittest.TestCase): add_template=['t1', 't2'], add_arch_template=['ta1', 'ta2'], add_template_var=['v1', 'v2'], - add_arch_template_var=['va1', 'va2']) + add_arch_template_var=['va1', 'va2'], + log_dir='/tmp') self.assertEqual(cmd[0], 'lorax') self.assertItemsEqual(cmd[1:], @@ -56,6 +57,7 @@ class LoraxWrapperTest(unittest.TestCase): '--add-arch-template=ta1', '--add-arch-template=ta2', '--add-template-var=v1', '--add-template-var=v2', '--add-arch-template-var=va1', '--add-arch-template-var=va2', + '--logfile=/tmp/lorax.log', '/mnt/output_dir'])