From ec8890db916c7ba978e897664ce8e354bd06e1d2 Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Mar 10 2016 16:19:56 +0000 Subject: [checks] Don't always require jigdo If the configuration specifically requests no jigdos, there is no point in checking for the binary existence. This is not 100% reliable. The jigdo option defaults to True, so if the option is not specified the binary is required even if there are no images configured. Signed-off-by: Lubomír Sedlář --- diff --git a/bin/pungi-koji b/bin/pungi-koji index 6217f61..9bbc732 100755 --- a/bin/pungi-koji +++ b/bin/pungi-koji @@ -149,11 +149,6 @@ def main(): parser.error("please specify a config") opts.config = os.path.abspath(opts.config) - # check if all requirements are met - import pungi.checks - if not pungi.checks.check(): - sys.exit(1) - import kobo.conf import kobo.log import productmd.composeinfo @@ -173,6 +168,11 @@ def main(): conf = kobo.conf.PyConfigParser() conf.load_from_file(opts.config) + # check if all requirements are met + import pungi.checks + if not pungi.checks.check(conf): + sys.exit(1) + if opts.target_dir: compose_dir = Compose.get_compose_dir(opts.target_dir, conf, compose_type=compose_type, compose_label=opts.label) else: diff --git a/pungi/checks.py b/pungi/checks.py index da535ac..c355576 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -18,19 +18,27 @@ import os.path +def is_jigdo_needed(conf): + return conf.get('create_jigdo', 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 +# configuration. tools = [ - ("isomd5sum", "/usr/bin/implantisomd5"), - ("isomd5sum", "/usr/bin/checkisomd5"), - ("jigdo", "/usr/bin/jigdo-lite"), - ("genisoimage", "/usr/bin/genisoimage"), - ("gettext", "/usr/bin/msgfmt"), - ("syslinux", "/usr/bin/isohybrid"), - ("yum-utils", "/usr/bin/createrepo"), - ("yum-utils", "/usr/bin/mergerepo"), - ("yum-utils", "/usr/bin/repoquery"), - ("git", "/usr/bin/git"), - ("cvs", "/usr/bin/cvs"), - ("gettext", "/usr/bin/msgfmt"), + ("isomd5sum", "/usr/bin/implantisomd5", None), + ("isomd5sum", "/usr/bin/checkisomd5", None), + ("jigdo", "/usr/bin/jigdo-lite", is_jigdo_needed), + ("genisoimage", "/usr/bin/genisoimage", None), + ("gettext", "/usr/bin/msgfmt", None), + ("syslinux", "/usr/bin/isohybrid", None), + ("yum-utils", "/usr/bin/createrepo", None), + ("yum-utils", "/usr/bin/mergerepo", None), + ("yum-utils", "/usr/bin/repoquery", None), + ("git", "/usr/bin/git", None), + ("cvs", "/usr/bin/cvs", None), + ("gettext", "/usr/bin/msgfmt", None), ] imports = [ @@ -42,7 +50,7 @@ imports = [ ] -def check(): +def check(conf): fail = False # Check python modules @@ -54,7 +62,10 @@ def check(): fail = True # Check tools - for package, path in tools: + for package, path, test_if_required in tools: + if test_if_required and not test_if_required(conf): + # The config says this file is not required, so we won't even check it. + continue if not os.path.exists(path): print("Program '%s' doesn't exist. Install package '%s'." % (path, package)) fail = True diff --git a/tests/data/dummy-pungi.conf b/tests/data/dummy-pungi.conf index ae20684..d2de06f 100644 --- a/tests/data/dummy-pungi.conf +++ b/tests/data/dummy-pungi.conf @@ -109,3 +109,5 @@ createiso_skip = [ 'src': True }), ] + +create_jigdo = False