CentOS

2006/7/24 04:49 PM 更新

Yumでパッケージ管理

※CentOS 3の情報はページが移動しました。 --> Yumでパッケージ管理(CentOS 3)

CentOSはRedHatLinux互換OSなのでRPMでパッケージ管理をしている。 アップデート方法はOS標準のup2dateコマンドを使う方法とYumというパッケージ管理ツー ルが提供されている。
ここでは、アップデート時などの依存関係の処理にすぐれているYumを使用する。

まずはYum用のGPG KeyをCentOSのサイトからインポートする。 これを行うことで、アップデート時にファイルの正当性を確認することが可能になる。 (正当性が確認できない場合にWARNINGが表示される。)
# rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-centos4

CentOS 4よりyumの設定方法が変更になった。
今までは/etc/yum.confで設定していたがこれに加え/etc/yum.repos.d/CentOS-Base.repoというファイルにてリポジトリの設定を行うようになった。

リポジトリはミラーサーバを使うように設定されているので特に変更する必要は無い。
  /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[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

#released updates
[update]
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

#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

#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

#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

#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
アップデート可能なパッケージ一覧を表示する。
# yum check-update
Setting up repositories
update                    100% |=========================|  951 B    00:00
base                      100% |=========================| 1.1 kB    00:00
addons                    100% |=========================|  951 B    00:00
extras                    100% |=========================| 1.1 kB    00:00
Reading repository metadata in from local files
primary.xml.gz            100% |=========================|  62 kB    00:15
update    : ################################################## 154/154
Added 16 new packages, deleted 0 old in 1.78 seconds

comps.i386                               2:4.3CENTOS-0.20060314 base
gtk2.i386                                2.4.13-18              base
kernel.i686                              2.6.9-34.0.2.EL        update
kernel-devel.i686                        2.6.9-34.0.2.EL        update
libtiff.i386                             3.6.1-10               update
newt.i386                                0.51.6-7.rhel4         base
rpmdb-CentOS.i386                        2:4.3-0.20060314       base
vixie-cron.i386                          4:4.1-44.EL4           update
xorg-x11-Mesa-libGL.i386                 6.8.2-1.EL.13.25.1     update
xorg-x11-libs.i386                       6.8.2-1.EL.13.25.1     update
アップデートする。 -yオプションを付けると自動的にインストールされるがお勧めしない。
# yum update comps
Setting up Update Process
Setting up repositories
Reading repository metadata in from local files
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for comps to pack into transaction set.
comps-4.3CENTOS-0.2006031 100% |=========================| 2.3 kB    00:00
---> Package comps.i386 2:4.3CENTOS-0.20060314 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Updating:
 comps                   i386       2:4.3CENTOS-0.20060314  base              8.8 M

Transaction Summary
=============================================================================
Install      0 Package(s)
Update       1 Package(s)
Remove       0 Package(s)
Total download size: 8.8 M
Is this ok [y/N]: y
Downloading Packages:
(1/1): comps-4.3CENTOS-0. 100% |=========================| 8.8 MB    01:12
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating  : comps                        ######################### [1/2]
  Cleanup   : comps                        ######################### [2/2]

Updated: comps.i386 2:4.3CENTOS-0.20060314
Complete!
yumでのインストール履歴を確認することが出来る。
  /var/log/yum.log
Jul 01 05:57:30 Erased: anacron
Jul 01 05:57:44 Erased: apmd
Jul 01 05:58:56 Erased: bluez-bluefw
Jul 01 06:00:09 Erased: bluez-hcidump
Jul 01 06:01:55 Erased: bluez-utils
Jul 01 06:01:55 Erased: bluez-libs
Jul 01 17:17:56 Installed: glibc-kernheaders.i386 2.4-9.1.98.EL
Jul 01 17:17:57 Installed: glibc-headers.i386 2.3.4-2.19
Jul 01 17:17:58 Installed: glibc-devel.i386 2.3.4-2.19
Jul 01 17:17:59 Installed: cpp.i386 3.4.5-2
Jul 01 17:18:02 Installed: gcc.i386 3.4.5-2
Jul 18 17:10:39 Updated: comps.i386 2:4.3CENTOS-0.20060314