CentOS 4のRubyをアップグレード

CentOSエンタープライズ系のディストリビューションのため、パッケージが概して古い。安定性を重視したものなので、それは仕方がない。ただ、時々困ることがある。

[masagon@main ~]$ ruby --version
ruby 1.8.1 (2003-12-25) [x86_64-linux-gnu]

おっと、これはいけねぇ。Railsが乗らんじゃないか!

まぁ、それもあるんですが、今回困ったのは日本語のコード変換。
KconvNKF モジュールでUnicodeが扱えないんです。
(参考サイト:http://jp.rubyist.net/magazine/?0009-BundledLibraries

Iconv は使えて、国際的にはこっちが本筋かもしれないんですが、いかんせん半角カナや機種依存文字の扱いが弱い。

幸いこのサーバーでは、Rubyはこの案件しか使っていないので、アップグレードすることにした。

ただ、安易にソースのコンパイルなどはしない主義。ディストリビューションの設計には、それなりの思想がある。設計者の思想を極力リスペクトしたい。rpmファイルやtarballは最後の手段だ。

こういう要求は当然のことなのだろう。CentOSの本家には、CentOS-Testingというレポジトリがしっかりと用意されている。今回はこれを使うことにする。

[root@main ~]# cd /etc/yum.repos.d
[root@main yum.repos.d]# wget http://dev.centos.org/centos/4/CentOS-Testing.repo
[root@main yum.repos.d]# cat CentOS-Testing.repo
[c4-testing]
name=CentOS-4 Testing 
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing

# CentOS-Testing:
# !!!! CAUTION !!!!
# This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras.
# They may or may not replace core CentOS packages, and are not guaranteed to function properly.
# These packages build and install, but are waiting for feedback from testers as to 
# functionality and stability. Packages in this repository will come and go during the 
# development period, so it should not be left enabled or used on production systems without due
# consideration. 

初期状態では無効(enabled=0)となっているようだ。なにやら、おどろおどろしい警告が含まれている。当然全てのパッケージに適用するつもりはない。

Rubyの関連モジュールだけに適用させるため、includepkgsを指定する。

[root@main yum.repos.d]# vi CentOS-Testing.repo
[c4-testing]
name=CentOS-4 Testing 
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=1      <-- 有効にして
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
includepkgs=ruby*      <-- パッケージを限定(*はワイルドカード)
[root@main yum.repos.d]# yum update ruby
...
Complete!
[root@main yum.repos.d]# ruby --version
ruby 1.8.5 (2006-08-25) [x86_64-linux]

ぬぉ!誕生日!
ってことで、無事1.8.5にアップグレードされましたとさ。(おしまいおしまい)