From 94f519d01cecd6a5caa3870e8f0c8078695b8438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 3 Dec 2015 14:19:15 +0100 Subject: [PATCH] Update lorax wrapper to use --installpkgs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The lorax wrapper class now understands the --installpkgs argument and can use it to pass multiple package names to the command. There is a simple test to make sure the commands includes all specified options. A bug is fixed where the bug URL would not be correctly included. Signed-off-by: Lubomír Sedlář --- pungi/wrappers/lorax.py | 9 +++++-- tests/test_lorax_wrapper.py | 52 +++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100755 tests/test_lorax_wrapper.py diff --git a/pungi/wrappers/lorax.py b/pungi/wrappers/lorax.py index 80d7f9f8..133c0e4c 100644 --- a/pungi/wrappers/lorax.py +++ b/pungi/wrappers/lorax.py @@ -21,7 +21,9 @@ from kobo.shortcuts import force_list class LoraxWrapper(object): - def get_lorax_cmd(self, product, version, release, repo_baseurl, output_dir, variant=None, bugurl=None, nomacboot=False, noupgrade=False, is_final=False, buildarch=None, volid=None): + def get_lorax_cmd(self, product, version, release, repo_baseurl, output_dir, + variant=None, bugurl=None, nomacboot=False, noupgrade=False, + is_final=False, buildarch=None, volid=None, buildinstallpackages=None): cmd = ["lorax"] cmd.append("--product=%s" % product) cmd.append("--version=%s" % version) @@ -36,7 +38,7 @@ class LoraxWrapper(object): cmd.append("--variant=%s" % variant) if bugurl is not None: - cmd.append("--bugurl=%s" % variant) + cmd.append("--bugurl=%s" % bugurl) if nomacboot: cmd.append("--nomacboot") @@ -53,6 +55,9 @@ class LoraxWrapper(object): if volid: cmd.append("--volid=%s" % volid) + if buildinstallpackages: + cmd.extend(["--installpkgs=%s" % package for package in buildinstallpackages]) + output_dir = os.path.abspath(output_dir) cmd.append(output_dir) diff --git a/tests/test_lorax_wrapper.py b/tests/test_lorax_wrapper.py new file mode 100755 index 00000000..938ea9d7 --- /dev/null +++ b/tests/test_lorax_wrapper.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- + +import unittest + +import os +import sys + +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) + +from pungi.wrappers.lorax import LoraxWrapper + + +class LoraxWrapperTest(unittest.TestCase): + + def setUp(self): + self.lorax = LoraxWrapper() + + def test_get_command_with_minimal_arguments(self): + cmd = self.lorax.get_lorax_cmd("product", "version", "release", + "/mnt/repo_baseurl", "/mnt/output_dir") + + self.assertEqual(cmd[0], 'lorax') + self.assertItemsEqual(cmd[1:], + ['--product=product', + '--version=version', + '--release=release', + '--source=file:///mnt/repo_baseurl', + '/mnt/output_dir']) + + def test_get_command_with_all_arguments(self): + cmd = self.lorax.get_lorax_cmd("product", "version", "release", + "/mnt/repo_baseurl", "/mnt/output_dir", + variant="Server", bugurl="http://example.com/", + nomacboot=True, noupgrade=True, is_final=True, + buildarch='x86_64', volid='VOLUME_ID', + buildinstallpackages=['bash', 'vim']) + + self.assertEqual(cmd[0], 'lorax') + self.assertItemsEqual(cmd[1:], + ['--product=product', '--version=version', + '--release=release', '--variant=Server', + '--source=file:///mnt/repo_baseurl', + '--bugurl=http://example.com/', + '--buildarch=x86_64', '--volid=VOLUME_ID', + '--nomacboot', '--noupgrade', '--isfinal', + '--installpkgs=bash', '--installpkgs=vim', + '/mnt/output_dir']) + + +if __name__ == "__main__": + unittest.main()