いきなりDebianでCPANモジュールをパッケージ化

さっそくですが個人メモとしてCPANモジュールをDebianパッケージにする方法を書いてみる。

Debian には dh-make-perl というCPANモジュールをdeb化するために便利なツールがある。

$ dh-make-perl --cpan AnyEvent
(省略)
I would like to connect to one of the following sites to get 'authors/id/M/ML/MLEHMANN/AnyEvent-5.271.tar.gz':

http://www.perl.org/CPAN/
ftp://ftp.perl.org/pub/CPAN/

Is it OK to try to connect to the Internet? [yes]
(省略)
$ ls
AnyEvent-5.271 libanyevent-perl_5.271.orig.tar.gz

これを実行するとDebianパッケージ化に必要な debian/rules, debian/control などを自動で作ってくれる。

その後、下記を実行すると debファイルが作成される。

$ cd AnyEvent-5.271/
$ debuild -rfakeroot -uc -us
$ cd ../
$ ls | grep anyevent
libanyevent-perl_5.271-1.diff.gz
libanyevent-perl_5.271-1.dsc
libanyevent-perl_5.271-1_all.deb
libanyevent-perl_5.271-1_i386.build
libanyevent-perl_5.271-1_i386.changes
libanyevent-perl_5.271.orig.tar.gz

あとはこれをインストールすればOK

$ sudo dpkg -i libanyevent-perl_5.271-1_all.deb

念のため確認。

$ dpkg -l libanyevent-perl
ii libanyevent-per 5.271-1 simpler/faster/newer/cooler AnyEvent API

自作パッケージかどうかも確認。

$ apt-cache show libanyevent-perl
Package: libanyevent-perl
Status: install ok installed
Priority: optional
Section: perl
Installed-Size: 852
Maintainer: hayashi
Architecture: all
Version: 5.271-1
Depends: perl (>= 5.6.0-16)
Description: simpler/faster/newer/cooler AnyEvent API
This module documents the new simpler AnyEvent API.
.
The rationale for the new API is that experience with EV shows that
this API actually "works", despite it's lack of extensibility, leading to
a shorter, easier and faster API.
.
The main difference to AnyEvent is that instead of method calls, function
calls are used, and that no named arguments are used.
.
This makes calls to watcher creation functions really short, which can
make a program more readable, despite the lack of named parameters.
Function calls also allow more static type checking than method calls, so
many mistakes are caught at compiletime with this API.
.
This description was automagically extracted from the module by dh-make-perl.
Homepage: http://search.cpan.org/dist/AnyEvent/

問題なくインストールできた。

もちろんperldocも。

$ perldoc AnyEvent

実はPlackやCoroをパッケージ化しようとしたのだがlenny提供のパッケージバージョンが古かったりテストでこけたりとうまくいかなかった。
またdpkgでインストールしているので依存関係のあるパッケージを自動でインストールしてくれない。
そこで次回はPlackdeb化を通してlennyで提供していないバージョンのモジュールをソースから入れる方法とdpkgではなく自動で依存関係のあるパッケージを入れてくれるツールを紹介しようと思う。