From fe2be4f17eba93dc38fa570313e519ff47cb2fd7 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Jan 26 2019 08:32:17 +0000 Subject: Allow setting the "check_deps" Pungi option using the "check_deps" compose flag. This is needed when user wants to abort the compose in case the dependencies between packages cannot be satisfied. This is not the default behaviour, but it is useful when creating compose for tests. --- diff --git a/README.md b/README.md index b4e7c4e..657ecff 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,7 @@ If the `packages` is not set, all packages in Koji tag or all packages in a `bui - `flags` - List of flags to further modify the compose output: - `no_deps` - For `tag` `source_type`, do not resolve dependencies between packages and include only packages listed in the `packages` in the compose. For `module` `source_type`, do not resolve dependencies between modules and include only the requested module in the compose. - `include_unpublished_pulp_repos` - For `pulp` `source_type`, include also unpublished repositories for input content-sets. + - `check_deps` - When set, abort the compose when some package has broken dependencies. - `sigkeys` - List of signature keys IDs. Only packages signed by one of these keys will be included in a compose. If there is no signed version of a package, compose will fail. It is also possible to pass an empty-string in a list meaning unsigned packages are allowed. For example if you want to prefer packages signed by key with ID `123` and also allow unsigned packages to appear in a compose, you can do it by setting sigkeys to `["123", ""]`. - `results` - List of additional results which will be generated as part of a compose. Valid keys are: - `iso` - Generates non-installable ISO files with RPMs from a compose. diff --git a/common/odcs/common/types.py b/common/odcs/common/types.py index a4920b4..ffb1d53 100644 --- a/common/odcs/common/types.py +++ b/common/odcs/common/types.py @@ -99,6 +99,8 @@ COMPOSE_FLAGS = { "no_inheritance": 2, # For "pulp" source_type, include unpublished Pulp repos. "include_unpublished_pulp_repos": 4, + # Abort the compose when some package has broken dependencies. + "check_deps": 8, } INVERSE_COMPOSE_FLAGS = {v: k for k, v in COMPOSE_FLAGS.items()} diff --git a/server/conf/pungi.conf b/server/conf/pungi.conf index ed2d84f..d60cef3 100644 --- a/server/conf/pungi.conf +++ b/server/conf/pungi.conf @@ -76,7 +76,7 @@ gather_method = '{{ config.gather_method }}' {%- if config.comps_file %} comps_file = '{{ config.comps_file }}' {%- endif %} -check_deps = False +check_deps = {{ config.check_deps }} greedy_method = 'build' # CREATEREPO @@ -110,3 +110,5 @@ translate_paths = [ koji_profile = '{{ config.koji_profile }}' +repoclosure_strictness = [('.*', {'*': 'off'})] + diff --git a/server/odcs/server/backend.py b/server/odcs/server/backend.py index d10a747..774347b 100644 --- a/server/odcs/server/backend.py +++ b/server/odcs/server/backend.py @@ -642,7 +642,7 @@ def generate_pungi_compose(compose): arches=compose.arches.split(" "), multilib_arches=multilib_arches, multilib_method=compose.multilib_method, - builds=builds) + builds=builds, flags=compose.flags) if compose.flags & COMPOSE_FLAGS["no_deps"]: pungi_cfg.gather_method = "nodeps" if compose.flags & COMPOSE_FLAGS["no_inheritance"]: diff --git a/server/odcs/server/pungi.py b/server/odcs/server/pungi.py index 58b5027..c55283b 100644 --- a/server/odcs/server/pungi.py +++ b/server/odcs/server/pungi.py @@ -36,7 +36,7 @@ from odcs.server import conf, log, db from odcs.server import comps from odcs.common.types import ( PungiSourceType, COMPOSE_RESULTS, MULTILIB_METHODS, - INVERSE_PUNGI_SOURCE_TYPE_NAMES) + INVERSE_PUNGI_SOURCE_TYPE_NAMES, COMPOSE_FLAGS) from odcs.server.utils import makedirs, clone_repo, copytree @@ -112,7 +112,8 @@ class RawPungiConfig(BasePungiConfig): class PungiConfig(BasePungiConfig): def __init__(self, release_name, release_version, source_type, source, packages=None, arches=None, sigkeys=None, results=0, - multilib_arches=None, multilib_method=0, builds=None): + multilib_arches=None, multilib_method=0, builds=None, + flags=0): self.release_name = release_name self.release_version = release_version self.bootable = False @@ -166,6 +167,8 @@ class PungiConfig(BasePungiConfig): else: raise ValueError("Unknown source_type %r" % source_type) + self.check_deps = flags & COMPOSE_FLAGS["check_deps"] + @property def source_type_str(self): return INVERSE_PUNGI_SOURCE_TYPE_NAMES[self.source_type] diff --git a/server/tests/test_pungi.py b/server/tests/test_pungi.py index 7991289..646fcea 100644 --- a/server/tests/test_pungi.py +++ b/server/tests/test_pungi.py @@ -34,7 +34,7 @@ from odcs.server.pungi import ( import odcs.server.pungi from odcs.server import conf, db from odcs.server.models import Compose -from odcs.common.types import COMPOSE_STATES, COMPOSE_RESULTS +from odcs.common.types import COMPOSE_STATES, COMPOSE_RESULTS, COMPOSE_FLAGS from odcs.server.utils import makedirs from .utils import ConfigPatcher, AnyStringWith, ModelsBaseTest @@ -156,6 +156,26 @@ class TestPungiConfig(unittest.TestCase): cfg = self._load_pungi_cfg(template) self.assertTrue(cfg["pkgset_koji_inherit"]) + def test_get_pungi_conf_check_deps(self): + _, mock_path = tempfile.mkstemp() + template_path = os.path.abspath(os.path.join(test_dir, + "../conf/pungi.conf")) + shutil.copy2(template_path, mock_path) + + with patch("odcs.server.pungi.conf.pungi_conf_path", mock_path): + pungi_cfg = PungiConfig("MBS-512", "1", PungiSourceType.KOJI_TAG, + "f26") + + template = pungi_cfg.get_pungi_config() + cfg = self._load_pungi_cfg(template) + self.assertFalse(cfg["check_deps"]) + + pungi_cfg = PungiConfig("MBS-512", "1", PungiSourceType.KOJI_TAG, + "f26", flags=COMPOSE_FLAGS["check_deps"]) + template = pungi_cfg.get_pungi_config() + cfg = self._load_pungi_cfg(template) + self.assertTrue(cfg["check_deps"]) + def test_get_pungi_conf_multilib(self): _, mock_path = tempfile.mkstemp() template_path = os.path.abspath(os.path.join(test_dir,