From e1b857617cf043ea638a6d57c60a1f5fd577d5ae Mon Sep 17 00:00:00 2001 From: Packit Date: Aug 19 2020 14:20:09 +0000 Subject: Apply patch 0001-Do-a-substitution-of-variables-in-repo_id-RhBug1748841.patch patch_name: 0001-Do-a-substitution-of-variables-in-repo_id-RhBug1748841.patch location_in_specfile: 1 present_in_specfile: true --- diff --git a/dnf/conf/read.py b/dnf/conf/read.py index a526a71..1efac22 100644 --- a/dnf/conf/read.py +++ b/dnf/conf/read.py @@ -43,7 +43,7 @@ class RepoReader(object): # read .repo files from directories specified by conf.reposdir for repofn in (repofn for reposdir in self.conf.reposdir - for repofn in sorted(glob.glob('%s/*.repo' % reposdir))): + for repofn in sorted(glob.glob('{}/*.repo'.format(reposdir)))): try: for r in self._get_repos(repofn): yield r @@ -54,17 +54,38 @@ class RepoReader(object): def _build_repo(self, parser, id_, repofn): """Build a repository using the parsed data.""" - repo = dnf.repo.Repo(id_, self.conf) + substituted_id = libdnf.conf.ConfigParser.substitute(id_, self.conf.substitutions) + + # Check the repo.id against the valid chars + invalid = dnf.repo.repo_id_invalid(substituted_id) + if invalid is not None: + if substituted_id != id_: + msg = _("Bad id for repo: {} ({}), byte = {} {}").format(substituted_id, id_, + substituted_id[invalid], + invalid) + else: + msg = _("Bad id for repo: {}, byte = {} {}").format(id_, id_[invalid], invalid) + raise dnf.exceptions.ConfigError(msg) + + repo = dnf.repo.Repo(substituted_id, self.conf) try: repo._populate(parser, id_, repofn, dnf.conf.PRIO_REPOCONFIG) except ValueError as e: - msg = _("Repository '%s': Error parsing config: %s") % (id_, e) + if substituted_id != id_: + msg = _("Repository '{}' ({}): Error parsing config: {}").format(substituted_id, + id_, e) + else: + msg = _("Repository '{}': Error parsing config: {}").format(id_, e) raise dnf.exceptions.ConfigError(msg) # Ensure that the repo name is set if repo._get_priority('name') == dnf.conf.PRIO_DEFAULT: - msg = _("Repository '%s' is missing name in configuration, using id.") - logger.warning(msg, id_) + if substituted_id != id_: + msg = _("Repository '{}' ({}) is missing name in configuration, using id.").format( + substituted_id, id_) + else: + msg = _("Repository '{}' is missing name in configuration, using id.").format(id_) + logger.warning(msg) repo.name = ucd(repo.name) repo._substitutions.update(self.conf.substitutions) repo.cfg = parser @@ -80,7 +101,7 @@ class RepoReader(object): try: parser.read(repofn) except RuntimeError as e: - raise dnf.exceptions.ConfigError(_('Parsing file "%s" failed: %s') % (repofn, e)) + raise dnf.exceptions.ConfigError(_('Parsing file "{}" failed: {}').format(repofn, e)) except IOError as e: logger.warning(e) @@ -90,13 +111,6 @@ class RepoReader(object): if section == 'main': continue - # Check the repo.id against the valid chars - invalid = dnf.repo.repo_id_invalid(section) - if invalid is not None: - logger.warning(_("Bad id for repo: %s, byte = %s %d"), section, - section[invalid], invalid) - continue - try: thisrepo = self._build_repo(parser, ucd(section), repofn) except (dnf.exceptions.RepoError, dnf.exceptions.ConfigError) as e: