CentOS:yum源中$releasever变量

来自WHY42

CentOS源中很多地方用版本号来关联镜像的更新路径。然而这个东西好像经常出错。例如163的repo:

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

今天更新时发现这个值竟然是6Server。奇怪的是这个变量并不在环境变量中。查找资料发现这个值$releasever变量是取redhat-release-server rpm包的属性值( %{version})。

rpm -q --qf %{version} redhat-release-server

如果要修改这个值,可以

echo "6">/etc/yum/vars/releasever