【Linux】 yumのexclude設定の挙動に振り回された話
前置き
Linuxの構築時、/etc/yum.conf
によく書く設定の一つにexclude
があります。
kernelやMWなど自動アップデートして欲しくないものを除外するわけですね。
今回、RHEL6からphp-mbstringがoptionalチャネル管理になったのでチャネルの設定をしていましたのですが、
チャネルの設定が完了したのにyum search
してもリポジトリ上にphp-mbstringが見当たらない。
原因としては/etc/yum.conf
にexclude=php*
の設定がありました。勝手にアップデートの対象から外すだけだと思っていましたがどうもyumで扱う対象そのものから外れてしまうみたいです。
ということでちょっと検証してみました。
検証
環境
- OS:CentOS6.6
- 対象パッケージ:yum-cron
最初に、exclude設定を追加してみます。
[root@conoha ~]# diff /etc/yum.conf.orig /etc/yum.conf 28a29 > exclude=yum-cron
yum list
した結果
[root@conoha ~]# yum list yum-cron Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile epel/metalink | 5.7 kB 00:00 * base: ftp.tsukuba.wide.ad.jp * epel: ftp.tsukuba.wide.ad.jp * extras: ftp.tsukuba.wide.ad.jp * updates: ftp.tsukuba.wide.ad.jp base | 3.7 kB 00:00 cr | 3.3 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 Error: No matching Packages to list
yum search
した結果
[root@conoha ~]# yum search yum-cron Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile * base: ftp.tsukuba.wide.ad.jp * epel: ftp.tsukuba.wide.ad.jp * extras: ftp.tsukuba.wide.ad.jp * updates: ftp.tsukuba.wide.ad.jp Warning: No matches found for: yum-cron No Matches found
yumdownloader
した結果
[root@conoha ~]# yumdownloader yum-cron Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.tsukuba.wide.ad.jp * epel: ftp.tsukuba.wide.ad.jp * extras: ftp.tsukuba.wide.ad.jp * updates: ftp.tsukuba.wide.ad.jp No Match for argument yum-cron Nothing to download
いずれも失敗します。 さらには自前でrpmを用意してinstallしようとしてもスルーされてしまいます。
[root@conoha ~]# yum localinstall ./yum-cron-3.2.29-60.el6.centos.noarch.rpm Loaded plugins: fastestmirror, security Setting up Local Package Process Examining ./yum-cron-3.2.29-60.el6.centos.noarch.rpm: yum-cron-3.2.29-60.el6.centos.noarch Nothing to do
原因は最初にも書きましたが/etc/yum.conf
にexclude=php*
の設定がしてあるためです。
この作業をするためだけに設定ファイルを変更するのも嫌なので、何かオプションがあるんじゃないかな?と思って確認したところmanpageに記載がありました。
--disableexcludes=[all|main|repoid] Disable the excludes defined in your config files. Takes one of three options: all == disable all excludes main == disable excludes defined in [main] in yum.conf repoid == disable excludes defined for that repo
オプションを設定してコマンドを投入してみます。
[root@conoha ~]# yum search yum-cron --disableexcludes=all Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile * base: ftp.tsukuba.wide.ad.jp * epel: ftp.tsukuba.wide.ad.jp * extras: ftp.tsukuba.wide.ad.jp * updates: ftp.tsukuba.wide.ad.jp ============================================================================= N/S Matched: yum-cron ============================================================================= yum-cron.noarch : Files needed to run yum updates as a cron job Name and summary matches only, use "search all" for everything. [root@conoha ~]# yum localinstall ./yum-cron-3.2.29-60.el6.centos.noarch.rpm --disableexcludes=all Loaded plugins: fastestmirror, security Setting up Local Package Process Examining ./yum-cron-3.2.29-60.el6.centos.noarch.rpm: yum-cron-3.2.29-60.el6.centos.noarch Marking ./yum-cron-3.2.29-60.el6.centos.noarch.rpm to be installed Loading mirror speeds from cached hostfile * base: ftp.tsukuba.wide.ad.jp * epel: ftp.tsukuba.wide.ad.jp * extras: ftp.tsukuba.wide.ad.jp * updates: ftp.tsukuba.wide.ad.jp Resolving Dependencies --> Running transaction check ---> Package yum-cron.noarch 0:3.2.29-60.el6.centos will be installed --> Processing Dependency: yum-plugin-downloadonly for package: yum-cron-3.2.29-60.el6.centos.noarch --> Running transaction check ---> Package yum-plugin-downloadonly.noarch 0:1.1.30-30.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================= Package Arch Version Repository Size ================================================================================================================================================================================= Installing: yum-cron noarch 3.2.29-60.el6.centos /yum-cron-3.2.29-60.el6.centos.noarch 28 k Installing for dependencies: yum-plugin-downloadonly noarch 1.1.30-30.el6 base 23 k Transaction Summary ================================================================================================================================================================================= Install 2 Package(s) Total size: 51 k Total download size: 23 k Installed size: 48 k Is this ok [y/N]: N Exiting on user Command
うまくいきました。
結論
- exclude設定があるとupdate以外にもlist, search, installなども失敗する
- exclude設定を無視する時はdisableexcludes設定を使う