diff options
Diffstat (limited to 'src/lib/Bcfg2')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Apt.py | 4 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Collection.py | 4 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Pac.py | 4 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Source.py | 24 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Yum.py | 105 |
5 files changed, 64 insertions, 77 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py b/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py index 685cd5c1d..06730562a 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py @@ -19,10 +19,6 @@ class AptSource(Source): Source.__init__(self, basepath, xsource, config) self.pkgnames = set() - self.url_map = [{'rawurl': self.rawurl, 'url': self.url, - 'version': self.version, - 'components': self.components, 'arches': self.arches}] - def save_state(self): cache = open(self.cachefile, 'wb') cPickle.dump((self.pkgnames, self.deps, self.provides, diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py b/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py index b05a69d4a..dc6768232 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py @@ -64,10 +64,8 @@ class Collection(Bcfg2.Server.Plugin.Debuggable): def sourcelist(self): srcs = [] for source in self.sources: - # get_urls() loads url_map as a side-effect - source.get_urls() for url_map in source.url_map: - if url_map['arch'] not in metadata.groups: + if url_map['arch'] not in self.metadata.groups: continue reponame = source.get_repo_name(url_map) srcs.append("Name: %s" % reponame) diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Pac.py b/src/lib/Bcfg2/Server/Plugins/Packages/Pac.py index 34c7b42c1..046fee68f 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Pac.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Pac.py @@ -18,10 +18,6 @@ class PacSource(Source): Source.__init__(self, basepath, xsource, config) self.pkgnames = set() - self.url_map = [{'rawurl': self.rawurl, 'url': self.url, - 'version': self.version, - 'components': self.components, 'arches': self.arches}] - def save_state(self): cache = open(self.cachefile, 'wb') cPickle.dump((self.pkgnames, self.deps, self.provides), diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py index df3706fb1..918c36afe 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py @@ -45,7 +45,7 @@ class Source(Bcfg2.Server.Plugin.Debuggable): try: self.version = xsource.find('Version').text except AttributeError: - pass + self.version = None for key, tag in [('components', 'Component'), ('arches', 'Arch'), ('blacklist', 'Blacklist'), @@ -102,7 +102,27 @@ class Source(Bcfg2.Server.Plugin.Debuggable): self.cachefile = os.path.join(self.basepath, "cache-%s" % self.cachekey) + if not self.rawurl: + self.baseurl = self.url + "%(version)s/%(component)s/%(arch)s/" + else: + self.baseurl = self.rawurl self.url_map = [] + for arch in self.arches: + if self.url: + usettings = [dict(version=self.version, component=comp, + arch=arch) + for comp in self.components] + else: # rawurl given + usettings = [dict(version=self.version, component=None, + arch=arch)] + + for setting in usettings: + if not self.rawurl: + setting['baseurl'] = self.url + else: + setting['baseurl'] = self.rawurl + setting['url'] = self.baseurl % setting + self.url_map.extend(usettings) @property def cachekey(self): @@ -147,7 +167,7 @@ class Source(Bcfg2.Server.Plugin.Debuggable): def get_repo_name(self, url_map): # try to find a sensible name for a repo - if 'component' in url_map and url_map['component']: + if url_map['component']: rname = url_map['component'] else: name = None diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py index cba3373c1..858916abf 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py @@ -166,49 +166,48 @@ class YumCollection(Collection): def get_config(self, raw=False): config = ConfigParser.SafeConfigParser() for source in self.sources: - # get_urls() loads url_map as a side-effect - source.get_urls() for url_map in source.url_map: - if url_map['arch'] in self.metadata.groups: - basereponame = source.get_repo_name(url_map) - reponame = basereponame - - added = False - while not added: - try: - config.add_section(reponame) - added = True - except ConfigParser.DuplicateSectionError: - match = re.search("-(\d+)", reponame) - if match: - rid = int(match.group(1)) + 1 - else: - rid = 1 - reponame = "%s-%d" % (basereponame, rid) - - config.set(reponame, "name", reponame) - config.set(reponame, "baseurl", url_map['url']) - config.set(reponame, "enabled", "1") - if len(source.gpgkeys): - config.set(reponame, "gpgcheck", "1") - config.set(reponame, "gpgkey", - " ".join(source.gpgkeys)) - else: - config.set(reponame, "gpgcheck", "0") + if url_map['arch'] not in self.metadata.groups: + continue + basereponame = source.get_repo_name(url_map) + reponame = basereponame - if len(source.blacklist): - config.set(reponame, "exclude", - " ".join(source.blacklist)) - if len(source.whitelist): - config.set(reponame, "includepkgs", - " ".join(source.whitelist)) + added = False + while not added: + try: + config.add_section(reponame) + added = True + except ConfigParser.DuplicateSectionError: + match = re.search("-(\d+)", reponame) + if match: + rid = int(match.group(1)) + 1 + else: + rid = 1 + reponame = "%s-%d" % (basereponame, rid) + + config.set(reponame, "name", reponame) + config.set(reponame, "baseurl", url_map['url']) + config.set(reponame, "enabled", "1") + if len(source.gpgkeys): + config.set(reponame, "gpgcheck", "1") + config.set(reponame, "gpgkey", + " ".join(source.gpgkeys)) + else: + config.set(reponame, "gpgcheck", "0") - if raw: - opts = source.server_options - else: - opts = source.client_options - for opt, val in opts.items(): - config.set(reponame, opt, val) + if len(source.blacklist): + config.set(reponame, "exclude", + " ".join(source.blacklist)) + if len(source.whitelist): + config.set(reponame, "includepkgs", + " ".join(source.whitelist)) + + if raw: + opts = source.server_options + else: + opts = source.client_options + for opt, val in opts.items(): + config.set(reponame, opt, val) if raw: return config @@ -593,10 +592,6 @@ class YumSource(Source): self.repo['relative_path']) self.arches = [self.repo['arch']] - if not self.rawurl: - self.baseurl = self.url + "%(version)s/%(component)s/%(arch)s/" - else: - self.baseurl = self.rawurl self.packages = dict() self.deps = dict([('global', dict())]) self.provides = dict([('global', dict())]) @@ -625,26 +620,8 @@ class YumSource(Source): self.filemap, self.url_map) = cPickle.load(data) def get_urls(self): - surls = list() - self.url_map = [] - for arch in self.arches: - if self.url: - usettings = [{'version':self.version, 'component':comp, - 'arch':arch} - for comp in self.components] - else: # rawurl given - usettings = [{'version':self.version, 'component':None, - 'arch':arch}] - - for setting in usettings: - setting['url'] = self.baseurl % setting - self.url_map.append(copy.deepcopy(setting)) - surls.append((arch, [setting['url'] for setting in usettings])) - urls = [] - for (sarch, surl_list) in surls: - for surl in surl_list: - urls.extend(self._get_urls_from_repodata(surl, sarch)) - return urls + return [self._get_urls_from_repodata(m['url'], m['arch']) + for m in self.url_map] urls = property(get_urls) def _get_urls_from_repodata(self, url, arch): |