From b59bdcea9228c93cb1f701fe7c050742df82e2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Fri, 5 Jun 2020 11:07:02 +0200 Subject: [PATCH] createrepo: Allow making productid glob stricter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch updates the documentation to match the actual behavior, and adds a configuration option to remove the leading prefix. The extra wildcard is causing problems when there are two variants in the compose and one UID is a suffix of the other (e.g. DevTools and Tools), since multiple files will match the shorter name and an error will be reported. JIRA: RHELCMP-1086 Signed-off-by: Lubomír Sedlář --- doc/configuration.rst | 8 +++++++- pungi/checks.py | 1 + pungi/phases/createrepo.py | 9 ++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/configuration.rst b/doc/configuration.rst index 801d4ac0..24956db0 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -448,7 +448,7 @@ Options **product_id** = None (:ref:`scm_dict `) -- If specified, it should point to a - directory with certificates ``--*.pem``. Pungi will + directory with certificates ``*--*.pem``. Pungi will copy each certificate file into the relevant Yum repositories as a ``productid`` file in the ``repodata`` directories. The purpose of these ``productid`` files is to expose the product data to `subscription-manager @@ -462,6 +462,12 @@ Options When you set this option to ``True``, Pungi will ignore the missing certificate and simply log a warning message. +**product_id_allow_name_prefix** = True + (*bool*) -- Allow arbitrary prefix for the certificate file name (see + leading ``*`` in the pattern above). Setting this option to ``False`` will + make the pattern more strict by requiring the file name to start directly + with variant name. + Example ------- diff --git a/pungi/checks.py b/pungi/checks.py index 09799ed9..3d187abe 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -859,6 +859,7 @@ def make_schema(): }, "product_id": {"$ref": "#/definitions/str_or_scm_dict"}, "product_id_allow_missing": {"type": "boolean", "default": False}, + "product_id_allow_name_prefix": {"type": "boolean", "default": True}, # Deprecated in favour of regular local/phase/global setting. "live_target": {"type": "string"}, "tree_arches": {"$ref": "#/definitions/list_of_strings", "default": []}, diff --git a/pungi/phases/createrepo.py b/pungi/phases/createrepo.py index 5780068a..3e5c7b57 100644 --- a/pungi/phases/createrepo.py +++ b/pungi/phases/createrepo.py @@ -350,12 +350,15 @@ def get_productids_from_scm(compose): return raise + if compose.conf["product_id_allow_name_prefix"]: + pattern = "%s/*%s-%s-*.pem" + else: + pattern = "%s/%s-%s-*.pem" + for arch in compose.get_arches(): for variant in compose.get_variants(arch=arch): # some layered products may use base product name before variant - pem_files = glob.glob("%s/*%s-%s-*.pem" % (tmp_dir, variant.uid, arch)) - # use for development: - # pem_files = glob.glob("%s/*.pem" % tmp_dir)[-1:] + pem_files = glob.glob(pattern % (tmp_dir, variant.uid, arch)) if not pem_files: warning = "No product certificate found (arch: %s, variant: %s)" % ( arch,