さくらのVPSにMercurialをインストールしようとしたらエラーが出る場合の3つの解決方法

さくらのVPSいいですね。反応速度、転送量どれをとっても、かなりおすすめです。


Rackspaceで動かしているWebサービスの一部を、さくらのVPSに持ってこようと考えています。


ソースコピーで環境を同じにすればいいのですが、Mercurialソースコードを持ってくることを試してみようと考えています。



そこで、デフォルトの状態で、さくらのVPS(OSはCentOS5.4)にMercurialをインストールしようとしたらエラーが出ます。


解決方法としては他のRPMパッケージを探しに行くか、依存関係を修復してインストールするか、ソースコードからインストールする方法があります。



それぞれ考察してみます。




1.他のRPMパッケージを探しに行く

他のリポジトリのRPMForgeには、mercurial の新しいバージョンがあります。

これをインストールするためにリポジトリを参照しにいくと、既存の依存パッケージもどんどんRMPForgeのものが入ってしまいます。

これを行うと、パッケージの本流から外れてしまいますので、今回はパスします。

新しいパッケージ類を試したい場合は、レポジトリを追加することも一考の余地ありです。


RPMforgeリポジトリ導入(RPMforge)



2.ソースコードからインストールする。

ソースコードからインストールもできます。
mercurialの本サイトからソースコードをダウンロードしてコンパイルします。

ソースからインストールする場合、PYTHONPATHの設定等が、自前でカスタマイズする必要があり、今回はパスします。

ソースからインストールしたい場合、詳細な方法は以下にあります。

CentOSでのMercurial その2




3.依存関係を修復してeasy_installでインストールする。

今回は依存関係を修復して、easy_installを使う方法をとります。

メインのRPMレポジトリを変更しないで、作業環境にもあまり依存させずに、
yumとeasy_installで構築できるためおすすめです。


(1)エラー確認

まず、エラーを確認します。


yum install mercurial
# yum install mercurial

Loaded plugins: downloadonly, fastestmirror
Loading mirror speeds from cached hostfile
 * addons: ftp.nara.wide.ad.jp
 * base: ftp.nara.wide.ad.jp
 * extras: ftp.nara.wide.ad.jp
 * updates: ftp.nara.wide.ad.jp
addons                                                   |  951 B     00:00
base                                                     | 2.1 kB     00:00
extras                                                   | 2.1 kB     00:00
updates                                                  | 1.9 kB     00:00
Setting up Install Process
No package mercurial available.
Nothing to do

デフォルトのRPMパッケージにないですよ、エラーが出ます。
「なんもできまへんがな」と言っています。


easy_install mercurial

では次にeasy_installでも試してみましょうか。

# easy_install mercurial

easy_install mercurial
Searching for mercurial
Reading http://pypi.python.org/simple/mercurial/
Reading http://www.selenic.com/mercurial
Best match: mercurial 1.7.2
Downloading http://mercurial.selenic.com/release/mercurial-1.7.2.tar.gz
Processing mercurial-1.7.2.tar.gz
Running mercurial-1.7.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-dtVMJZ/mercurial-1.7.2/egg-dist-tmp-1De2z4
error: Setup script exited with Couldn't import standard bz2 (incomplete Python install).


bz2がインポートできないとあります。Pythonインストールが不完全です、と。


(2)インストール(本番)

依存関係がおかしいということなので、まずbzip2をインストールします。

# yum install bzip2-devel


を行います。


再度Pythonを上書きインストールしてください。
(好みですが、自分はPython2.7をソースで再インストールしました。)


その後、Mercurialをeasy_installインストールします。

# easy_install mercurial

Searching for mercurial
Reading http://pypi.python.org/simple/mercurial/
Reading http://www.selenic.com/mercurial
Best match: mercurial 1.7.2
Downloading http://mercurial.selenic.com/release/mercurial-1.7.2.tar.gz
Processing mercurial-1.7.2.tar.gz
Running mercurial-1.7.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-EEA316/mercurial-1.7.2/egg-dist-tmp-RDjD8p
zip_safe flag not set; analyzing archive contents...
mercurial.help: module references __file__
mercurial.lsprof: module references __file__
mercurial.extensions: module references __file__
mercurial.commands: module references __file__
mercurial.templater: module references __file__
mercurial.i18n: module references __file__
hgext.mq: module references __file__
Adding mercurial 1.7.2 to easy-install.pth file
Installing hg script to /usr/local/bin

Installed /usr/local/lib/python2.7/site-packages/mercurial-1.7.2-py2.7-linux-x86_64.egg
Processing dependencies for mercurial
Finished processing dependencies for mercurial

となります。成功です。