Centos yum中的$releasever和$basearch变量
来自三线的随记
在Centos中
yum.repos.d下的repo文件,经常能看到$releasever 和 $basearch变量
[base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
releaserver 变量
yum config-manager --dump-variables
rpm -q --provides $(rpm -q --whatprovides "system-release(releasever)") | grep "system-release(releasever)" | cut -d ' ' -f 3
releaserver 这个变量值同样可以通过文件来覆写,例如针对centos8的vault仓库
- 注意epel等repo也会读取releasever和contentdir 变量值,如果是用了epel / remi等软件源,不要直接改releasever和contentdir 的全局值
echo "8.4.2105" > /etc/yum/vars/releasever echo "centos-vault" > /etc/yum/vars/contentdir
效果:
[root@centos8-template vars]# yum config-manager --dump-variables arch = x86_64 basearch = x86_64 infra = stock contentdir = centos-vault releasever = 8.4.2105
旧版centos取值判断
其中
$releasever 即release version
取值
rpm -qi centos-release
结果中的version字段
[root@router yum.repos.d]# cat /etc/redhat-release CentOS Linux release 7.8.2003 (Core) [root@router yum.repos.d]# rpm -qi centos-release Name : centos-release Version : 7 Release : 8.2003.0.el7.centos Architecture: x86_64 Install Date: Sat 13 Jun 2020 07:01:32 PM HKT Group : System Environment/Base Size : 43849 License : GPLv2 Signature : RSA/SHA256, Tue 14 Apr 2020 11:54:48 PM HKT, Key ID 24c6a8a7f4a80eb5 Source RPM : centos-release-7-8.2003.0.el7.centos.src.rpm Build Date : Wed 08 Apr 2020 06:01:12 AM HKT Build Host : x86-01.bsys.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS Summary : CentOS Linux release file Description : CentOS Linux release files [root@router yum.repos.d]#
此处为version为7
而basearch自然就是架构了
[root@router yum.repos.d]# uname -ip x86_64 x86_64 [root@router yum.repos.d]# arch x86_64
$infra 位于 /etc/yum/vars/infra
[root@node-docker yum.repos.d]# cat /etc/yum/vars/infra stock
Related: Yum简要配置example随记