diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-03-15 10:46:53 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-03-15 10:46:53 -0400 |
commit | 0c290ce54d1be854ebc60eedfff89ef16d998727 (patch) | |
tree | 98cf75c1b94a8a593ce6c63e54a5afa48bc9918e /src/lib/Server | |
parent | 5a633d1a62b50cc41bbef38f2bfabc09ae7a43e0 (diff) | |
download | bcfg2-0c290ce54d1be854ebc60eedfff89ef16d998727.tar.gz bcfg2-0c290ce54d1be854ebc60eedfff89ef16d998727.tar.bz2 bcfg2-0c290ce54d1be854ebc60eedfff89ef16d998727.zip |
filter out characters yum dislikes in repo names
Diffstat (limited to 'src/lib/Server')
-rw-r--r-- | src/lib/Server/Plugins/Packages/Source.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/Server/Plugins/Packages/Source.py b/src/lib/Server/Plugins/Packages/Source.py index 910a90cac..1dfeecc40 100644 --- a/src/lib/Server/Plugins/Packages/Source.py +++ b/src/lib/Server/Plugins/Packages/Source.py @@ -136,7 +136,7 @@ class Source(Bcfg2.Server.Plugin.Debuggable): def get_repo_name(self, url_map): # try to find a sensible name for a repo if url_map['component']: - return url_map['component'] + rname = url_map['component'] else: name = None for repo_re in (self.mrepo_re, @@ -144,14 +144,18 @@ class Source(Bcfg2.Server.Plugin.Debuggable): self.genericrepo_re): match = repo_re.search(url_map['url']) if match: - name = match.group(1).replace('/', '-') break if name is None: # couldn't figure out the name from the URL or URL map # (which probably means its a screwy URL), so we just # generate a random one name = base64.b64encode(os.urandom(16))[:-2] - return "%s-%s" % (self.groups[0], name) + rname = "%s-%s" % (self.groups[0], name) + # see yum/__init__.py in the yum source, lines 441-449, for + # the source of this regex. yum doesn't like anything but + # string.ascii_letters, string.digits, and [-_.:]. There + # doesn't seem to be a reason for this, because yum. + return re.sub(r'[^A-Za-z0-9-_.:]', '-', rname) def __str__(self): if self.rawurl: |