If the repository 'foo-source' is enabled but there's no 'foo' repo, don't disable 'foo-source'. --- yumdownloader.py | 52 ++++++++++++++++++---------------------------------- 1 files changed, 18 insertions(+), 34 deletions(-)
diff --git a/yumdownloader.py b/yumdownloader.py index 03ad62c..158c21d 100755 --- a/yumdownloader.py +++ b/yumdownloader.py @@ -99,45 +99,29 @@ class YumDownloader(YumUtilBase): def setupSourceRepos(self): # enable the -source repos for enabled primary repos - archlist = rpmUtils.arch.getArchList() + ['src'] # Ok, we have src and bin repos. What we want to do here is: # # 1. _enable_ source repos for which the bin repos are enabled. - # 2. _disable_ the _other_ src repos. - # - # ...also we don't want to disable the src repos. for #1 and then - # re-enable them as then we get annoying messages and call .close() on - # them losing the primarydb data etc. + # 2. _disable_ source repos for which the bin repos are disabled. - # Get all src repos. - src_repos = {} - repos_source = self.repos.findRepos('*-source') - if rhn_source_repos: # RHN - repos_source += self.repos.findRepos('*-source-rpms') - for repo in repos_source: - src_repos[repo.id] = False + enabled = {} + for repo in self.repos.findRepos('*'): + enabled[repo.id] = repo.isEnabled() - # Find the enabled bin repos, and mark their respective *-source repo. - # as good. - for repo in self.repos.listEnabled(): - if repo.id not in src_repos: - srcrepo = '%s-source' % repo.id - if srcrepo in src_repos: - src_repos[srcrepo] = True - if not rhn_source_repos: - continue - if not repo.id.endswith("-rpms"): - continue - srcrepo = repo.id[:-len('-rpms')] + '-source-rpms' - if srcrepo in src_repos: - src_repos[srcrepo] = True + for repo in self.repos.findRepos('*'): + if repo.id.endswith('-source'): + bin_id = repo.id[:-7] + elif rhn_source_repos and repo.id.endswith('-source-rpms'): + bin_id = repo.id[:-12] + '-rpms' + else: + continue - # Toggle src repos that are set the wrong way - for repo in repos_source: - if repo.isEnabled() and not src_repos[repo.id]: + # Toggle src repos that are set the wrong way + # (no toggling when the bin repo does not exist) + if repo.isEnabled() and not enabled.get(bin_id, True): repo.close() self.repos.disableRepo(repo.id) - if not repo.isEnabled() and src_repos[repo.id]: + if not repo.isEnabled() and enabled.get(bin_id, False): self.logger.info('Enabling %s repository' % repo.id) repo.enable() -- 1.7.4.4 _______________________________________________ Yum-devel mailing list Yum-devel@lists.baseurl.org http://lists.baseurl.org/mailman/listinfo/yum-devel