From: "Brian C. Lane" bcl@redhat.com
kickstarts require an install option (cdrom, url, etc.) but previously there was a bug and you could leave these out and it would use whatever repos were configured. This behavior has been fixed, but that makes it difficult to share kickstarts across releases.
This patch adds $releasever and $basearch variable support (like in yum config files) to kickstart repos. Both baseurl and mirrorlist support these so that now the kickstart can have this and it will do the right thing:
url --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch... --- pyanaconda/packaging/yumpayload.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py index 6cd223d..5f1fcd3 100644 --- a/pyanaconda/packaging/yumpayload.py +++ b/pyanaconda/packaging/yumpayload.py @@ -875,6 +875,25 @@ reposdir=%s except RepoMDError: log.error("failed to get groups for repo %s" % yumrepo.id)
+ def _replaceVars(self, url): + """ Replace url variables with their values + + :param url: url string to do replacement on + :type url: string + :returns: string with variables substituted + :rtype: string or None + + Currently supports $releasever and $basearch + """ + if not url: + return url + + with _yum_lock: + url = url.replace("$releasever", self._yum.conf.yumvar['releasever']) + url = url.replace("$basearch", blivet.arch.getArch()) + + return url + def _addYumRepo(self, name, baseurl, mirrorlist=None, proxyurl=None, **kwargs): """ Add a yum repo to the YumBase instance. """ from yum.Errors import RepoError @@ -907,6 +926,10 @@ reposdir=%s log.error("Failed to parse proxy for _addYumRepo %s: %s" \ % (proxyurl, e))
+ if baseurl: + baseurl = self._replaceVars(baseurl) + if mirrorlist: + mirrorlist = self._replaceVars(mirrorlist) log.debug("adding yum repo %s with baseurl %s and mirrorlist %s" % (name, baseurl, mirrorlist)) with _yum_lock:
On Thu, 2013-05-30 at 16:38 -0700, Brian C. Lane wrote:
From: "Brian C. Lane" bcl@redhat.com
kickstarts require an install option (cdrom, url, etc.) but previously there was a bug and you could leave these out and it would use whatever repos were configured. This behavior has been fixed, but that makes it difficult to share kickstarts across releases.
This patch adds $releasever and $basearch variable support (like in yum config files) to kickstart repos. Both baseurl and mirrorlist support these so that now the kickstart can have this and it will do the right thing:
url --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch...
pyanaconda/packaging/yumpayload.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py index 6cd223d..5f1fcd3 100644 --- a/pyanaconda/packaging/yumpayload.py +++ b/pyanaconda/packaging/yumpayload.py @@ -875,6 +875,25 @@ reposdir=%s except RepoMDError: log.error("failed to get groups for repo %s" % yumrepo.id)
- def _replaceVars(self, url):
""" Replace url variables with their values:param url: url string to do replacement on:type url: string:returns: string with variables substituted:rtype: string or NoneCurrently supports $releasever and $basearch"""if not url:return urlwith _yum_lock:url = url.replace("$releasever", self._yum.conf.yumvar['releasever'])url = url.replace("$basearch", blivet.arch.getArch())return url- def _addYumRepo(self, name, baseurl, mirrorlist=None, proxyurl=None, **kwargs): """ Add a yum repo to the YumBase instance. """ from yum.Errors import RepoError
@@ -907,6 +926,10 @@ reposdir=%s log.error("Failed to parse proxy for _addYumRepo %s: %s" \ % (proxyurl, e))
if baseurl:baseurl = self._replaceVars(baseurl)if mirrorlist:mirrorlist = self._replaceVars(mirrorlist) log.debug("adding yum repo %s with baseurl %s and mirrorlist %s" % (name, baseurl, mirrorlist)) with _yum_lock:
Clever idea! ACK for both branches.
anaconda-patches@lists.fedorahosted.org