FedoraおよびRHEL系ディストリビューションにおけるRPMインストーラ/アップデータとしてデファクトスタンダードといえるYumについて、基本的な使い方をまとめておこうと思う。対象バージョンはCentOS4以降のyum。
1. システムにインストールされているRPMをアップデートする:
yum update [RPM名]
途中で本当にダウンロードしてインストールするかどうか確認してくる(対話的動作をする)が、yum update -y のように「-y」オプションをつけることで完全に自動化できる。
CentOSやRHELでは自動的なアップデートを行ってもまず問題がでることはないので、cron等で-yをつけて実行してもよいかもしれない。Fedoraもまず問題がでることはないはずだが、そのディストリビューションとしての性格上問題が起こってもおかしくはない。実際Fedoraでは2010年1月に一度dnssec-confのアップデートによりbindが起動できなくなるトラブルがあった。
RPM名を指定した場合は、そのRPMおよび必要な依存関係についてアップデートが走る(細かい挙動は未確認)。
2. システムにインストールされていないRPMをインストールする:
yum install RPM名
指定したRPMをインストールする。「そんなこと言われてもパッケージの名前わからんし」という場合は次項目参照。
3. RPMを検索する:
yum search 検索文字列
検索文字列にマッチするRPMを検索する。検索対象はおそらくRPM名だけではなく、rpm -qi 等で表示される詳細情報も含んでいる。たとえばyum search nkfで検索すると、
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@ume# yum search nkf | |
Loaded plugins: refresh-packagekit | |
=================================== Matched: nkf =================================== | |
nkf.x86_64 : A Kanji code conversion filter | |
perl-NKF.x86_64 : Perl extension for Network Kanji Filter | |
perl-Pod-Coverage.noarch : Checks if the documentation of a module is comprehensive | |
skf-common.x86_64 : Common files for Simple Kanji Filter - i18n kanji converte |
のように、表示されるサマリにnkfという文字列さえ含まれていないRPMもマッチするからだ。結構便利。
「こんな短いサマリだけじゃ、どんなソフトかわからないよー」という人は次項目参照。
4. RPMの詳細情報を表示する
yum info RPM名
たとえば上のyum searchで現れたnkf.x86_64の場合
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@ume# yum info nkf.x86_64 | |
Loaded plugins: refresh-packagekit | |
Installed Packages | |
Name : nkf | |
Arch : x86_64 | |
Epoch : 1 | |
Version : 2.0.8b | |
Release : 7.fc13 | |
Size : 241 k | |
Repo : installed | |
From repo : fedora | |
Summary : A Kanji code conversion filter | |
URL : http://nkf.sourceforge.jp/ | |
License : BSD | |
Description : Nkf is a Kanji code converter for terminals, hosts, and networks. Nkf | |
: converts input Kanji code to 7-bit JIS, MS-kanji (shifted-JIS) or | |
: EUC. |
が表示される。
大体この4つ(update, install, search, info)のサブコマンドを覚えておけば事足りると思うが、以下は覚えておくとちょっと便利な応用編。
「あれあれ、あのコマンドが欲しいんだけど、yum searchで探しても出てこないんだよね。絶対あるはずなんだけど」という場合。そんなときは次の項目。
5. RPMに含まれる機能名/ファイル名からRPMを検索する:
yum whatprovides 機能名/ファイル名
たとえば顧客からの指示でデータを(今時)uuencodeして送るよう指示されたとする。
yum search uuencode としても出てくるのは以下のような結果だ(Fedora13の場合)。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@ume# yum search uuencode | |
Loaded plugins: refresh-packagekit | |
================================ Matched: uuencode ================================= | |
ghc-dataenc.x86_64 : Haskell encoding library | |
ghc-dataenc-devel.i686 : Haskell encoding library development files | |
ghc-dataenc-devel.x86_64 : Haskell encoding library development files | |
ghc-dataenc-doc.x86_64 : Documentation for Haskell encoding library | |
ghc-dataenc-prof.x86_64 : Profiling libraries for Haskell encoding library | |
uulib-devel.i686 : Binary news message decoding library | |
uulib-devel.x86_64 : Binary news message decoding library |
どれも違うっぽい。そんなときはwhatprovidesを使う。
まずはuuencodeだけで検索
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@ume# yum whatprovides 'uuencode' | |
Loaded plugins: refresh-packagekit | |
Warning: 3.0.x versions of yum would erroneously match against filenames. | |
You can use "*/uuencode" and/or "*bin/uuencode" to get that behaviour | |
No Matches found |
どうやら該当するRPMはないようだ。ただし、'*/uuencode'とか'*bin/uuencode'とかでも試せよと言っているのでそうすると、
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@ume# yum whatprovides '*bin/uuencode' | |
Loaded plugins: refresh-packagekit | |
sharutils-4.7-6.fc13.x86_64 : The GNU shar utilities for packaging and unpackaging | |
: shell archives | |
Repo : fedora | |
Matched from: | |
Filename : /usr/bin/uuencode | |
sharutils-4.9-1.fc13.x86_64 : The GNU shar utilities for packaging and unpackaging | |
: shell archives | |
Repo : updates | |
Matched from: | |
Filename : /usr/bin/uuencode |
上記ふたつはバージョンが違うだけなので、sharutilsという名前でyum infoを確認
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@ume# yum info sharutils | |
Loaded plugins: refresh-packagekit | |
Available Packages | |
Name : sharutils | |
Arch : x86_64 | |
Version : 4.9 | |
Release : 1.fc13 | |
Size : 183 k | |
Repo : updates | |
Summary : The GNU shar utilities for packaging and unpackaging shell archives | |
URL : http://www.gnu.org/software/sharutils/ | |
License : GPLv3+ and LGPLv2+ and Public Domain | |
Description : The sharutils package contains the GNU shar utilities, a set of tools | |
: for encoding and decoding packages of files (in binary or text format) | |
: in a special plain text format called shell archives (shar). This | |
: format can be sent through e-mail (which can be problematic for | |
: regular binary files). The shar utility supports a wide range of | |
: capabilities (compressing, uuencoding, splitting long files for | |
: multi-part mailings, providing check-sums), which make it very | |
: flexible at creating shar files. After the files have been sent, the | |
: unshar tool scans mail messages looking for shar files. Unshar | |
: automatically strips off mail headers and introductory text and then | |
: unpacks the shar files. |
Descriptionをみると、uuencoding とあるのでインストールするべきRPMはsharutilsで間違いなさそうだ。あとはyum install sharutilsすれば良いだけ。
6. ローカルに存在するRPMファイルをyumでインストールする
yum localinstall RPMファイル
「手元にrpmがあるんだけど、rpm -ivhでインストールしようとすると依存関係のエラーがでちゃった。依存関係にあるRPMはダウンロードしてほしいんだけど、手元のrpmはわざわざダウンロードせずにインストールできない?」という場合はlocalinstallが役に立つ。
ただし、手元のRPMがGPG署名されていないものの場合、--nogpgcheckオプションが必要になるかもしれない。これはRPMに付加されたGPG署名を検証しないオプションなので、利用するときは自分が何をしているか理解したうえで指定すること。localinstallで表示される依存RPMをyum installで先にインストールし、手元のRPMはrpm -ivhでインストールするという手順を踏んだ方が良いかもしれない。
7. 環境まわりのTIPS
proxy設定
/etc/yum.conf の[main]セクションに
proxy = http://proxy.example.com:3128/
のように記述すればよい。(/etc/yum.confがデフォルトのままなら、最後の行に追記すれば[main]セクションに書いたことになる)
なお、RHEL4/CentOS4のyum(rpmライブラリ?)にはバグがあり、Proxyの仕様によってはyum updateの途中でエラーになってしまうことがあるようだ。この場合はくりかえしyum updateを実行することでアップデートが進むので、あきらめずに実行してみてほしい(もしかしたらだれかがパッチを書いているかも)。
fastestmirrorプラグインの無効化
同じくProxy背後にいる場合、fastestmirrorを無効にしたほうがいいかも。
fastestmirrorプラグインは、RPMのダウンロード先としてもっとも早いミラーサーバを選択するためのプラグインだが、Proxy背後にいる場合は妙に遠い場所を選んでしまうことがあるようだ。このような場合はfastestmirrorをuninstallするか、
/etc/yum/pluginconf.d/fastestmirror.conf というファイルの
enabled=1という行を
enabled=0に書き換えると良い。
おわりに
以上、「これだけは押さえておきたいyumの使い方」というテーマで7つのポイントに絞って解説したが、この記事があなたの作業効率アップに貢献できたのなら幸いだ。
他にもRPMまわりの話とか、rpmfusion, EPELなんかの追加リポジトリの話、yumリポジトリをセットアップする側の話とかいろいろネタがあるので気が向いたらまた記事にしていきたい。
ご意見、ご感想、ツッコミ等はコメント欄へどうぞ。お待ちしております。
0 件のコメント:
コメントを投稿