From 80bd2543474a7cf6d28256c22323cbefeeaf28d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 4 Nov 2021 10:17:02 +0100 Subject: [PATCH] Check dependencies after config validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way the checks can rely on default values from the config. Signed-off-by: Lubomír Sedlář --- pungi/checks.py | 4 ++-- pungi/scripts/pungi_koji.py | 5 +++-- tests/test_checks.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pungi/checks.py b/pungi/checks.py index b1ecf61b..329c94fc 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -53,7 +53,7 @@ from . import util def is_jigdo_needed(conf): - return conf.get("create_jigdo", False) + return conf.get("create_jigdo") def is_isohybrid_needed(conf): @@ -93,7 +93,7 @@ def is_xorrisofs_needed(conf): def is_createrepo_c_needed(conf): - return conf.get("createrepo_c", True) + return conf.get("createrepo_c") # The first element in the tuple is package name expected to have the diff --git a/pungi/scripts/pungi_koji.py b/pungi/scripts/pungi_koji.py index e393220d..b8669d8d 100644 --- a/pungi/scripts/pungi_koji.py +++ b/pungi/scripts/pungi_koji.py @@ -265,8 +265,6 @@ def main(): # check if all requirements are met import pungi.checks - if not pungi.checks.check(conf): - sys.exit(1) pungi.checks.check_umask(logger) if not pungi.checks.check_skip_phases( logger, opts.skip_phase + conf.get("skip_phases", []), opts.just_phase @@ -297,6 +295,9 @@ def main(): fail_to_start("Config validation failed", errors=errors) sys.exit(1) + 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 diff --git a/tests/test_checks.py b/tests/test_checks.py index 788f727a..9d53b119 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -147,7 +147,7 @@ class CheckDependenciesTestCase(unittest.TestCase): with mock.patch("sys.stdout", new_callable=StringIO) as out: with mock.patch("os.path.exists") as exists: exists.side_effect = self.dont_find(["/usr/bin/createrepo_c"]) - result = checks.check({}) + result = checks.check({"createrepo_c": True}) self.assertIn("createrepo_c", out.getvalue()) self.assertFalse(result)