From c6a86c444a711076ad343cacd4e0d346951629a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 28 Mar 2019 12:36:06 +0100 Subject: [PATCH] gather: Apply repo path substitutions for DNF backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use a method to add repos that will apply $arch and $basearch substitution automatically. Yum backend only applies $basearch, so if compatibility is needed, that one should be used. Drop code for handling mirrorlist, since Pungi does not ever use it, and being used externally is not really supported. Signed-off-by: Lubomír Sedlář --- bin/pungi-gather | 4 ++-- pungi/dnf_wrapper.py | 23 ++++++++--------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/bin/pungi-gather b/bin/pungi-gather index 392f1389..2e5c114f 100755 --- a/bin/pungi-gather +++ b/bin/pungi-gather @@ -112,13 +112,13 @@ def main(persistdir, cachedir): if ks_repo.name not in gather_opts.lookaside_repos: continue dnf_obj.add_repo( - ks_repo.name, ks_repo.baseurl, ks_repo.mirrorlist, enablegroups=False + ks_repo.name, ks_repo.baseurl, enablegroups=False ) for ks_repo in ksparser.handler.repo.repoList: if ks_repo.name in gather_opts.lookaside_repos: continue - dnf_obj.add_repo(ks_repo.name, ks_repo.baseurl, ks_repo.mirrorlist) + dnf_obj.add_repo(ks_repo.name, ks_repo.baseurl) with Profiler("DnfWrapper.fill_sack()"): dnf_obj.fill_sack(load_system_repo=False, load_available_repos=True) diff --git a/pungi/dnf_wrapper.py b/pungi/dnf_wrapper.py index 48843535..af1d0cb1 100644 --- a/pungi/dnf_wrapper.py +++ b/pungi/dnf_wrapper.py @@ -55,21 +55,14 @@ class DnfWrapper(dnf.Base): self.arch_wrapper = ArchWrapper(self.conf.substitutions["arch"]) self.comps_wrapper = CompsWrapper(self) - def add_repo( - self, repoid, baseurl=None, mirrorlist=None, enablegroups=True, lookaside=False - ): - if "://" not in baseurl: - baseurl = "file://%s" % os.path.abspath(baseurl) - if LooseVersion(dnf.__version__) < LooseVersion("2.0.0"): - repo = dnf.repo.Repo(repoid, self.conf.cachedir) - else: - repo = dnf.repo.Repo(repoid, self.conf) - repo.baseurl = baseurl - repo.mirrorlist = mirrorlist - repo.enablegroups = enablegroups - repo.enable() - self.repos.add(repo) - repo.priority = 10 if lookaside else 20 + def add_repo(self, repoid, baseurl=None, enablegroups=True, lookaside=False): + self.repos.add_new_repo( + repoid, + self.conf, + baseurl=[baseurl], + enabledgroups=enablegroups, + priority=10 if lookaside else 20, + ) class CompsWrapper(object):