yum配置文件变量详解

本文探讨了yum源配置文件的路径和内容,重点解析了其中的变量如$basearch, $arch等。通过查阅man yum.conf手册,了解到$releasever的值来源于distroverpkg,并解释了$arch对应系统的架构,而$basearch表示系统的基础架构。同时提到了$YUM0到$YUM9这些用户自定义变量的替换规则。文章还建议通过执行Python命令来实际查看这些变量的值。" 125873534,8287093,C#窗体间数据传递技巧详解,"['C#', '窗体设计', '数据传递']
部署运行你感兴趣的模型镜像

yun源配置路径:/etc/yum.repos.d/xxx.repo

先看下yun配置文件的内容

[root@py git]# cat /etc/yum.repos.d/epel.repo 
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

可以看到 里面有几个变量 $basearch $arch等

其实最好的资料就是man手册 这些变量内容 我们可以在man手册里面找到 

>> man yum.conf

VARIABLES
       There  are  a  number  of variables you can use to ease maintenance of yum’s configuration files.
       They are available in the values of several options including name, baseurl and commands.

              $releasever This will be replaced with the value of the version of the package  listed  in
              distroverpkg. This defaults to the version of ‘redhat-release’ package.

              $arch This will be replaced with the architecture or your system as detected by yum.

              $basearch  This  will be replaced with your base architecture in yum. For example, if your
              $arch is i686 your $basearch will be i386.

              $uuid This will be replaced with a unique but persistent uuid for this machine.  The value
              that  is first generated will be stored in /var/lib/yum/uuid and reused until this file is
              deleted.

              $YUM0-$YUM9 These will be replaced with the value of the shell environment variable of the
              same  name.  If  the shell environment variable does not exist then the configuration file
              variable will not be replaced.

这里可以看到 $releasever的值来自distroverpkg 那么distroverpkg是什么呢? 我们继续在man yum.conf里面查找可以看到

distroverpkg The package used by yum to determine the "version" of the distribution.  This
              can  be any installed package. Default is ‘redhat-release’. You can see what provides this
              manually by using: "yum whatprovides redhat-release".

$arch 是系统架构 执行执行arch命令查看

[root@py git]# arch 
x86_64

$basearch 这将被你yum所在系统的基础架构所取代 

例如 如果您的$ arch是i686 你的$ basearch将是i386

$YUM0 - $YUM9 用户自定义变量

这些将被替换为相同名称的shell环境变量的值 如果shell环境变量不存在 那么配置文件变量将不会被替换


这里有个简单的Python命令可以查看这些值

[root@py git]# /usr/bin/python -c 'import yum, pprint; yb = yum.YumBase(); pprint.pprint(yb.conf.yumvar, width=1)'
Loaded plugins: fastestmirror
{'arch': 'ia32e',
 'basearch': 'x86_64',
 'infra': 'stock',
 'releasever': '6',
 'uuid': 'e51c4e78-7b06-473c-8605-1c998de5a792'}


您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值