checks: Check for createrepo_c

The createrepo package is needed always, but depending on configuration
we should also look for createrepo_c.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-10-25 15:43:19 +02:00
parent f4cd25450b
commit bfd5a39ce6
2 changed files with 49 additions and 3 deletions

View File

@ -76,6 +76,10 @@ def is_genisoimage_needed(conf):
return False return False
return True return True
def is_createrepo_c_needed(conf):
return conf.get('createrepo_c', True)
# The first element in the tuple is package name expected to have the # 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 # executable (2nd element of the tuple). The last element is an optional
# function that should determine if the tool is required based on # function that should determine if the tool is required based on
@ -87,8 +91,15 @@ tools = [
("genisoimage", "/usr/bin/genisoimage", is_genisoimage_needed), ("genisoimage", "/usr/bin/genisoimage", is_genisoimage_needed),
("gettext", "/usr/bin/msgfmt", None), ("gettext", "/usr/bin/msgfmt", None),
("syslinux", "/usr/bin/isohybrid", is_isohybrid_needed), ("syslinux", "/usr/bin/isohybrid", is_isohybrid_needed),
("createrepo", "/usr/bin/createrepo", None), # modifyrepo can always be called
("createrepo", "/usr/bin/mergerepo", None), ("createrepo", "/usr/bin/modifyrepo", None),
# createrepo and mergerepo are not needed by default, only when
# createrepo_c is not configured
("createrepo", "/usr/bin/createrepo", lambda conf: not is_createrepo_c_needed(conf)),
("createrepo", "/usr/bin/mergerepo", lambda conf: not is_createrepo_c_needed(conf)),
("createrepo_c", "/usr/bin/createrepo_c", is_createrepo_c_needed),
("createrepo_c", "/usr/bin/mergerepo_c", is_createrepo_c_needed),
("yum-utils", "/usr/bin/repoquery", None), ("yum-utils", "/usr/bin/repoquery", None),
("git", "/usr/bin/git", None), ("git", "/usr/bin/git", None),
("cvs", "/usr/bin/cvs", None), ("cvs", "/usr/bin/cvs", None),

View File

@ -147,11 +147,46 @@ class CheckDependenciesTestCase(unittest.TestCase):
with mock.patch('sys.stdout', new_callable=StringIO.StringIO) as out: with mock.patch('sys.stdout', new_callable=StringIO.StringIO) as out:
with mock.patch('os.path.exists') as exists: with mock.patch('os.path.exists') as exists:
exists.side_effect = self.dont_find(['/usr/bin/genisoimage']) exists.side_effect = self.dont_find(['/usr/bin/genisoimage'])
with mock.patch('__builtin__.__import__'):
result = checks.check(conf) result = checks.check(conf)
self.assertIn('genisoimage', out.getvalue()) self.assertIn('genisoimage', out.getvalue())
self.assertFalse(result) self.assertFalse(result)
def test_requires_modifyrepo(self):
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/modifyrepo'])
with mock.patch('__builtin__.__import__'):
result = checks.check({})
self.assertIn('createrepo', out.getvalue())
self.assertFalse(result)
def test_requires_createrepo_c(self):
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/createrepo_c'])
with mock.patch('__builtin__.__import__'):
result = checks.check({})
self.assertIn('createrepo_c', out.getvalue())
self.assertFalse(result)
def test_doesnt_require_createrepo_c_if_configured(self):
conf = {
'createrepo_c': False,
}
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/createrepo_c'])
with mock.patch('__builtin__.__import__'):
result = checks.check(conf)
self.assertNotIn('createrepo_c', out.getvalue())
self.assertTrue(result)
class TestUmask(unittest.TestCase): class TestUmask(unittest.TestCase):
def setUp(self): def setUp(self):