しゃある通信

#30-03 [Ubuntu,perl,hack]CPANモジュールをdebパッケージにするcpan2deb(車輪の再発明)

自分の気にいるものがなかったので自作。

使い方


cpan2deb モジュール名
または
cpan2deb tarball URI

ex)

$ cpan2deb JSON::XS
CPAN モジュールを取得して Ubuntu 用にパッケージングする準備をします。
実行例はこんな感じ。
$ cpan2deb JSON::XS
CPAN: Storable loaded ok
Going to read /home/sharl/.cpan/Metadata
  Database was generated on Tue, 30 Nov 2010 01:53:34 GMT
Running get for module JSON::XS
CPAN: Digest::MD5 loaded ok
Checksum for /home/sharl/.cpan/sources/authors/id/M/ML/MLEHMANN/JSON-XS-2.3.tar.gz ok
(snip)
Maintainer name : Sharl Morlaroll
Email-Address   : sharl@hauN.org
Date            : Tue, 30 Nov 2010 17:30:00 +0900
Package Name    : libjson-xs-perl
Version         : 2.3
License         : artistic
Type of Package : Single
Hit <enter> to confirm: Skipping creating ../libjson-xs-perl_2.3.orig.tar.gz because it already exists
Currently there is no top level Makefile. This may require additional tuning.
Done. Please edit the files in the debian/ subdirectory now. You should also
check that the libjson-xs-perl Makefiles install into $DESTDIR and not in / .
Build-Depends: libextutils-makemaker-perl
Depends: libcommon-sense-perl
$ ls
libjson-xs-perl-2.3/  libjson-xs-perl_2.3.orig.tar.gz
$ cd libjson-xs-perl-2.3/
$ debuild -uc -us
(snip)
dpkg-deb: building package `libjson-xs-perl' in `../libjson-xs-perl_2.3-1_i386.deb'.
 dpkg-genchanges
dpkg-genchanges: including full source code in upload
dpkg-buildpackage (debuild emulation): full upload (original source is included)
$ tree debian/libjson-xs-perl
debian/libjson-xs-perl
|-- DEBIAN
|   |-- control
|   `-- md5sums
`-- usr
    |-- bin
    |   `-- json_xs
    |-- lib
    |   `-- perl5
    |       |-- JSON
    |       |   |-- XS
    |       |   |   `-- Boolean.pm
    |       |   `-- XS.pm
    |       `-- auto
    |           `-- JSON
    |               `-- XS
    |                   |-- XS.bs
    |                   `-- XS.so
    `-- share
        |-- doc
        |   `-- libjson-xs-perl
        |       |-- changelog.Debian.gz
        |       `-- copyright
        `-- man
            |-- man1
            |   `-- json_xs.1p.gz
            `-- man3
                |-- JSON::XS.3pm.gz
                `-- JSON::XS::Boolean.3pm.gz

16 directories, 12 files
$ cd ..
$ ls
libjson-xs-perl-2.3/           libjson-xs-perl_2.3-1_i386.build    libjson-xs-perl_2.3.orig.tar.gz
libjson-xs-perl_2.3-1.diff.gz  libjson-xs-perl_2.3-1_i386.changes
libjson-xs-perl_2.3-1.dsc      libjson-xs-perl_2.3-1_i386.deb
この辺までは自動でできるようになったので、ひとまず満足。

恥ずかしいけど置いておきます。

修正点:
2010/12/01 Build-Depends も反映するようにした。
2010/12/16 新しい CPAN.pm でも動くように修正。
2011/03/22 パッケージから余計なファイル・ディレクトリを削除するよう rules を修正。
2011/03/29 Module::Build に対応。
2011/05/09 Module::Install, Recommends に対応。
2011/05/24 モジュールの tarball URI を指定できるようにした。

追記:
GitHubにも登録してみた。cpan2deb



マクロミルへ登録

© 2010 Kazuya 'Sharl' Masuda
(C)Willoo Entertainment Inc. (C)Konami Digital Entertainment 株式会社ウィローエンターテイメント及び株式会社コナミデジタルエンタテインメントの著作権を侵害する行為は禁止されています。 0.003617 cached