rubygemsをDebian testingからaptitudeで取ってくる

参考:
Gfdnavi を Debian GNU/Linux 4.0(etch) で動かす.

ほとんど写しました。ありがとうございます。

前準備

testing のパッケージを導入するので apt-line に testing のリポジトリを追加します.

ということで/etc/apt/sources.listに以下を追加。

deb http://cdn.debian.or.jp/debian/ testing main contrib non-free
deb http://security.debian.org/ testing/updates main contrib non-free

次に, 「apt の pin 止め(apt-pinning)」と呼ばれる作業をしておきましょう. 既存の安定版環境が開発版(testing)環境へと勝手に upgrade しないようにしておきます.

/etc/apt/preferencesが無かったのでtouchして、その中に以下を記載。

Package: *
Pin: release a=testing
Pin-Priority: 90

なお、ピン留めのPin-Priorityの値は
http://debian.fam.cx/index.php?AptGet#content_1_27
を参照。小さいとインストールされず、高いと強行にインストールされる。

前準備その2

degas@debian:~$ sudo aptitude update
取得:1 http://cdn.debian.or.jp etch Release.gpg [386B]        
取得:2 http://cdn.debian.or.jp testing Release.gpg [189B]      
取得:3 http://security.debian.org etch/updates Release.gpg [189B]
取得:4 http://security.debian.org testing/updates Release.gpg [189B]
取得:5 http://security.debian.org etch/updates Release [37.6kB]
発見 http://cdn.debian.or.jp etch Release                    
取得:6 http://cdn.debian.or.jp testing Release [74.5kB]                         
取得:7 http://security.debian.org testing/updates Release [40.7kB]
無視 http://security.debian.org etch/updates/main Packages/DiffIndex            
無視 http://security.debian.org etch/updates/contrib Packages/DiffIndex
無視 http://security.debian.org etch/updates/main Sources/DiffIndex
無視 http://security.debian.org etch/updates/contrib Sources/DiffIndex
取得:8 http://security.debian.org testing/updates/main Packages [8112B]
取得:9 http://security.debian.org testing/updates/contrib Packages [20B]
取得:10 http://security.debian.org testing/updates/non-free Packages [20B]
取得:11 http://security.debian.org etch/updates/main Packages [374kB]
無視 http://cdn.debian.or.jp etch/main Packages/DiffIndex                       
無視 http://cdn.debian.or.jp etch/main Sources/DiffIndex      
取得:12 http://cdn.debian.or.jp testing/main Packages [6975kB]
発見 http://security.debian.org etch/updates/contrib Packages 
取得:13 http://security.debian.org etch/updates/main Sources [56.5kB]
発見 http://security.debian.org etch/updates/contrib Sources                    
取得:14 http://cdn.debian.or.jp testing/contrib Packages [97.1kB]               
取得:15 http://cdn.debian.or.jp testing/non-free Packages [122kB]               
発見 http://cdn.debian.or.jp etch/main Packages                                 
発見 http://cdn.debian.or.jp etch/main Sources                                  
7787kB を 30s 秒でダウンロードしました (254kB/s)                                
パッケージリストを読み込んでいます... エラー!
E: Dynamic MMap ran out of room
E: torcs を処理中にエラーが発生しました (NewVersion1)
E: Problem with MergeList /var/lib/apt/lists/cdn.debian.or.jp_debian_dists_testing_main_binary-i386_Packages
E: パッケージリストまたはステータスファイルを解釈またはオープンすることができません。
E: パッケージキャッシュを再構築できませんでした

場所がない(out of room)のだそうな。

キャッシュ容量の設定なども行っておきましょう。
/etc/apt/apt.conf

   1  APT::Cache-Limit "100000000";
   2  APT::Default-Release "stable";

上記の設定ファイルファイルが無い場合は、新しく作成します。
debianで補助的にunstableパッケージを使えるようにする設定 - Hello, world! - s21g

aptitude update したら "E: Dynamic MMap ran out of room" とエラーが出た

sources.list にたくさん書きすぎです。apt-line を減らすか、/etc/apt/apt.conf に

APT::Cache-Limit "100000000";

などと書いておくといいです。
詳しくは man apt.conf 参照。
http://debian.fam.cx/index.php?AptGet#content_1_47

ということで、/etc/apt/apt.confをtouchして、次に以下を記載。

APT::Cache-Limit "100000000";
APT::Default-Release "stable";

ということで再度aptitude update。

degas@debian:/etc/apt$ sudo aptitude update
取得:1 http://cdn.debian.or.jp etch Release.gpg [386B]        
取得:2 http://cdn.debian.or.jp testing Release.gpg [189B]     
取得:3 http://security.debian.org etch/updates Release.gpg [189B]
取得:4 http://security.debian.org testing/updates Release.gpg [189B]
発見 http://security.debian.org etch/updates Release
発見 http://cdn.debian.or.jp etch Release                                       
発見 http://security.debian.org testing/updates Release                         
発見 http://cdn.debian.or.jp testing Release                                    
無視 http://security.debian.org etch/updates/main Packages/DiffIndex            
無視 http://security.debian.org etch/updates/contrib Packages/DiffIndex
無視 http://security.debian.org etch/updates/main Sources/DiffIndex
無視 http://cdn.debian.or.jp etch/main Packages/DiffIndex      
無視 http://cdn.debian.or.jp etch/main Sources/DiffIndex       
無視 http://security.debian.org etch/updates/contrib Sources/DiffIndex
無視 http://security.debian.org testing/updates/main Packages/DiffIndex
無視 http://security.debian.org testing/updates/contrib Packages/DiffIndex
無視 http://security.debian.org testing/updates/non-free Packages/DiffIndex
発見 http://security.debian.org etch/updates/main Packages     
発見 http://security.debian.org etch/updates/contrib Packages  
発見 http://security.debian.org etch/updates/main Sources      
取得:5 http://cdn.debian.or.jp testing/main Packages/DiffIndex [2038B]
取得:6 http://cdn.debian.or.jp testing/contrib Packages/DiffIndex [2023B]
取得:7 http://cdn.debian.or.jp testing/non-free Packages/DiffIndex [2023B]
発見 http://cdn.debian.or.jp etch/main Packages                
発見 http://security.debian.org etch/updates/contrib Sources   
発見 http://security.debian.org testing/updates/main Packages  
発見 http://security.debian.org testing/updates/contrib Packages
発見 http://security.debian.org testing/updates/non-free Packages
発見 http://cdn.debian.or.jp etch/main Sources                 
6088B を 4s 秒でダウンロードしました (1405B/s)
パッケージリストを読み込んでいます... 完了

念のためaptitude upgradeで、何もupgradeされないことを確認。

degas@debian:/etc/apt$ sudo aptitude -s upgrade
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了        
拡張状態情報を読み込んでいます          
パッケージの状態を初期化しています... 完了
タグのデータベースを構築しています... 完了  
インストール・削除・更新されるパッケージがありません。
更新: 0 個、新規インストール: 0 個、削除: 0 個、保留: 0 個。
0B のアーカイブを取得する必要があります。展開後に 0B のディスク領域が新たに消費されます。
パッケージのダウンロード・インストール・削除をおこないます。

よし。

testingのrubygemsをインストール

degas@debian:/etc/apt$ sudo aptitude install rubygems -t testing
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了        
拡張状態情報を読み込んでいます          
パッケージの状態を初期化しています... 完了
拡張状態情報を書き込んでいます... 完了        
タグのデータベースを構築しています... 完了
以下の新規パッケージが自動的にインストールされます:
  rubygems1.8 
以下のパッケージが自動的に削除されます:
  libgems-ruby1.8 
以下のパッケージが一時固定されています:
 :(略)
以下の新規パッケージがインストールされます:
  rubygems1.8 
以下のパッケージが削除されます:
  libgems-ruby1.8 
以下のパッケージが更新されます:
  rubygems 
更新: 1 個、新規インストール: 1 個、削除: 1 個、保留: 331 個。
220kB のアーカイブを取得する必要があります。展開後に 59.4kB のディスク領域が新たに消費されます。
続けますか? [Y/n/?] y
拡張状態情報を書き込んでいます... 完了
取得:1 http://cdn.debian.or.jp testing/main rubygems 1.2.0-3 [56.6kB]
取得:2 http://cdn.debian.or.jp testing/main rubygems1.8 1.2.0-3 [164kB]
220kB を 2s 秒でダウンロードしました (91.6kB/s)
(データベースを読み込んでいます ... 現在 51861 個のファイルとディレクトリがインストールされています。)
rubygems 0.9.0-5 を (.../rubygems_1.2.0-3_all.deb で) 置換するための準備をしています ...
rubygems を展開し、置換しています...
(データベースを読み込んでいます ... 現在 51846 個のファイルとディレクトリがインストールされています。)
libgems-ruby1.8 を削除しています ...
未選択パッケージ rubygems1.8 を選択しています。
(データベースを読み込んでいます ... 現在 51699 個のファイルとディレクトリがインストールされています。)
(.../rubygems1.8_1.2.0-3_all.deb から) rubygems1.8 を展開しています...
rubygems1.8 (1.2.0-3) を設定しています ...

rubygems (1.2.0-3) を設定しています ...
degas@debian:/etc/apt$ gem -v
1.2.0

ちゃんとrubygemsの1.2.0が入った。