[Kimchi-devel] [PATCH] Fix issue #617: Base URL may be an empty string when updating YUM repo
Aline Manera
alinefm at linux.vnet.ibm.com
Thu Mar 19 22:00:17 UTC 2015
Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
src/kimchi/i18n.py | 2 +-
src/kimchi/repositories.py | 16 +++++++++++-----
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index df5422f..e4e1a89 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -298,7 +298,7 @@ messages = {
"KCHREPOS0010E": _("GPG key must be a URL pointing to the ASCII-armored file."),
"KCHREPOS0011E": _("Could not update repository %(repo_id)s."),
"KCHREPOS0012E": _("Repository %(repo_id)s does not exist."),
- "KCHREPOS0013E": _("Specify repository base URL or mirror list in order to create a YUM repository."),
+ "KCHREPOS0013E": _("Specify repository base URL or mirror list in order to create or update a YUM repository."),
"KCHREPOS0014E": _("Repository management tool was not recognized for your system."),
"KCHREPOS0015E": _("Repository %(repo_id)s is already enabled."),
"KCHREPOS0016E": _("Repository %(repo_id)s is already disabled."),
diff --git a/src/kimchi/repositories.py b/src/kimchi/repositories.py
index f826ac9..f1e1eb3 100644
--- a/src/kimchi/repositories.py
+++ b/src/kimchi/repositories.py
@@ -1,7 +1,7 @@
#
# Project Kimchi
#
-# Copyright IBM, Corp. 2014
+# Copyright IBM, Corp. 2014-2015
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -269,19 +269,25 @@ class YumRepo(object):
if repo_id not in repos.repos.keys():
raise NotFoundError("KCHREPOS0012E", {'repo_id': repo_id})
- config = params.get('config', {})
entry = repos.getRepo(repo_id)
baseurl = params.get('baseurl', None)
+ config = params.get('config', {})
mirrorlist = config.get('mirrorlist', None)
+ if len(baseurl.strip()) == 0:
+ baseurl = None
+
+ if len(mirrorlist.strip()) == 0:
+ mirrorlist = None
+
+ if baseurl is None and mirrorlist is None:
+ raise MissingParameter("KCHREPOS0013E")
+
if baseurl is not None:
validate_repo_url(baseurl)
entry.baseurl = baseurl
- if mirrorlist == '':
- mirrorlist = None
-
if mirrorlist is not None:
validate_repo_url(mirrorlist)
entry.mirrorlist = mirrorlist
--
2.1.0
More information about the Kimchi-devel
mailing list