yum package库优先级设定(repo)

Life is short , play more!
本文来自lihao's Blog,转载请注明。

CentOS-4 或 CentOS-6:

yum install yum-plugin-priorities

CentOS-5:

yum install yum-priorities
  • 通过 CentOS Extras 软件库。由于 CentOS Extras 软件库被缺省为启用的,因此在 CentOS 上你可以借着安装 yum-plugin-priorities 来设置这个插件。在 CentOS 5 Extras 软件库中,这个组件名叫 yum-priorities。更多有关 CentOS Extras 软件库的数据可以在「软件库」页内找到。
  • 自 yum-utils 1.0.1 起,priorities 插件已经被加入上游的 yum-utils 源代码内。yum-utils 内的版本同时支持 yum 2.4.x 及 3.0.x。设置指引已收录在压缩档内位于plugins/priorities 目录的 README 文件里。

完成插件的安装后,请确定它在你决定使用的软件库内已被启用。要达至这个目的,请编辑 /etc/yum/pluginconf.d/priorities.conf,并确保它拥有下列内容:

[main]
enabled=1

当这个插件被启用后,你可以加入下面一行为软件库增设优先次序:

priority=N

N 是一个 1 至 99 的整数。每个软件库的缺省优先次序是 99。拥有最细数值的软件库会获得最优先待遇。一般来说,最理想的做法是至少将极高等级赋予 CentOS 的 baseupdate 软件库。在下列的 /etc/yum.repos.d/CentOS-Base.repo 样例档中,CentOS 的 base 及 update 软件库被赋予最高的等级(1):

 

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=1

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=1

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=1

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=1

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=1

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=2

注:上述例子针对 CentOS-4。在 CentOS-5 请将 RPM-GPG-KEY-centos4 文件名称(位于 gpgkey 行内)以 RPM-GPG-KEY-CentOS-5 取代。

在 /etc/yum.repos.d/CentOS-Base.repo 文件内作出这些改动后,yum 便永远不会用其它较低级别的软件库内的组件取替 base 及 update 软件库内的组件。这样做可能会导致安全性更新及「定点发行」内的更新被无声无息地压抑掉,暴露你的系统给潜在的损害。请参阅文章起首的忠告。

 


发表评论

电子邮件地址不会被公开。 必填项已用*标注