yum中$releasever、 $basearch等变量含义

以下摘自stackoverflow:

Most distro uses the distroverpkg version to get the releasever and basearch.

If you look at /etc/yum.conf, you will see that distrover is set to redhat-release (for RHEL), enterpriselinux-release (for OEL), and others.

To get the package name:

distro=$(sed -n 's/^distroverpkg=//p' /etc/yum.conf)

To get the releasever:

releasever=$(rpm -q --qf "%{version}" -f /etc/$distro)

To get the basearch:

basearch=$(rpm -q --qf "%{arch}" -f /etc/$distro)

The new code above will try to get the package associated with a file /etc/$distro. Some Linux adds /etc/redhat-release to their package release.

If you get file not owned by any package then use the /etc/*-release file that came with your distro. It is probably /etc/centos-release.

You can check the appropriate /etc/*-release appropriate for this code by checking which file is packaged with centos.

rpm -qf /etc/*-release

Then use this file instead of the first line above.

distro=/etc/centos-release

Here's an example from OEL where /etc/redhat-release is packaged as enterprise-release.

rpm -q --qf "%{name}" -f /etc/redhat-release

总结:

$releasever是取自distro的软件包比如,cent7.2是取centos-release-7-2.1511.el7.centos.2.10.x86_64的version字段;

$basearch是取centos-release-7-2.1511.el7.centos.2.10.x86_64的arch字段。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值