From 0f3bfbbddf011c82faf3636a40aec3cf0410652b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 10 Mar 2016 11:23:45 +0100 Subject: [PATCH] [checks] Relax check for genisoimage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rules are similar to isohybrid, but there are no checks for architecture. Signed-off-by: Lubomír Sedlář --- pungi/checks.py | 11 ++++++++++- tests/test_checks.py | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/pungi/checks.py b/pungi/checks.py index 039f6ad2..cff2f4b5 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -41,6 +41,15 @@ def is_isohybrid_needed(conf): return True +def is_genisoimage_needed(conf): + """This is only needed locally for productimg and createiso without runroot. + """ + runroot = conf.get('runroot', False) + will_do_productimg = conf.get('productimg', False) and conf.get('bootable', False) + if runroot and not will_do_productimg: + return False + return True + # The first element in the tuple is package name expected to have the # executable (2nd element of the tuple). The last element is an optional # function that should determine if the tool is required based on @@ -49,7 +58,7 @@ tools = [ ("isomd5sum", "/usr/bin/implantisomd5", None), ("isomd5sum", "/usr/bin/checkisomd5", None), ("jigdo", "/usr/bin/jigdo-lite", is_jigdo_needed), - ("genisoimage", "/usr/bin/genisoimage", None), + ("genisoimage", "/usr/bin/genisoimage", is_genisoimage_needed), ("gettext", "/usr/bin/msgfmt", None), ("syslinux", "/usr/bin/isohybrid", is_isohybrid_needed), ("yum-utils", "/usr/bin/createrepo", None), diff --git a/tests/test_checks.py b/tests/test_checks.py index a957ea33..d3b102d0 100755 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -96,13 +96,38 @@ class CheckDependenciesTestCase(unittest.TestCase): 'runroot': True, } - with mock.patch('platform.machine') as machine: - machine.return_value = 'armhfp' - with mock.patch('os.path.exists') as exists: - exists.side_effect = self.dont_find(['/usr/bin/isohybrid']) - result = checks.check(conf) + with mock.patch('os.path.exists') as exists: + exists.side_effect = self.dont_find(['/usr/bin/isohybrid']) + result = checks.check(conf) self.assertTrue(result) + def test_genisoimg_not_needed_in_runroot(self): + conf = { + 'runroot': True, + } + + with mock.patch('os.path.exists') as exists: + exists.side_effect = self.dont_find(['/usr/bin/genisoimage']) + result = checks.check(conf) + + self.assertTrue(result) + + def test_genisoimg_needed_for_productimg(self): + conf = { + 'runroot': True, + 'productimg': True, + 'bootable': True, + } + + with mock.patch('sys.stdout', new_callable=StringIO.StringIO) as out: + with mock.patch('os.path.exists') as exists: + exists.side_effect = self.dont_find(['/usr/bin/genisoimage']) + result = checks.check(conf) + + self.assertIn('genisoimage', out.getvalue()) + self.assertFalse(result) + + if __name__ == "__main__": unittest.main()