Debian パッケージ作りのメモ

自分で作ったプログラムをDebianパッケージにするメモです。
微妙に規則違反の可能性もありますが、、、

  • リポジトリからソースを取得して tar.gz で固める


    % mkdir myprogram-1.0.0
    % cd myprogram-1.0.0
    % svn co http://location/svn/myprogram/trunk myprogram
    % find . -name '.svn' -type d -exec rm -rf {} \;
    % cd ..
    % tar cfz myprogram_1.0.0.orig.tar.gz myprogram-1.0.0
  • dh_make でひな形を作る


    % cd -
    % dh_make


    Type of package: single binary, multiple binary, library, kernel module or cdbs?
    [s/m/l/k/b] s

    Maintainer name :
    Email-Address :
    Date : Sun, 12 Apr 2009 15:01:44 +0900
    Package Name : myprogram
    Version : 1.0.0
    License : blank
    Using dpatch : no
    Type of Package : Single
    Hit to confirm:
    Skipping creating ../myprogram_1.0.0.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 intraguardian Makefiles install into $DESTDIR and not in / .

  • Debian パッケージにするためのパッチを配置する


    % mkdir debian/patches
    上記ディレクトリに、01_nantara.dpatch, 02_kantara.dpatch という名前でパッチを配置する。

    パッチの先頭には、

    #! /bin/sh /usr/share/dpatch/dpatch-run

    を、書いておく。



    debian/patches/00list というファイルを作成して、一行ずつ配置したパッチの名前を書いておく。


    01_nantara.dpatch
    02_kantara.dpatch
  • ルールの変更

    debian/rules の最初の方に、dpatch を使うよーと記載しておく。

    #enable dpatch
    include /usr/share/dpatch/dpatch.make
    また、

    clean:
    という行を、

    clean: patch-stamp
    に、変更しておく。

    /etc/init.d/ 以下に起動スクリプトを配置したい場合は、dh_installinit のコメント `#' を外しておく。
  • 起動スクリプトの準備

    起動スクリプトが必要なプログラムなら、debian/init.d という名前で、起動スクリプトを用意しておく。
  • インストール後処理

    インストール後にパーミッションなどの変更が必要なプログラムなら、
    debian/postinst というファイルの中にいろいろと処理を仕込んでおく。
    init.d や postinst は debian/ 下の *.ex が参考になります。
  • パッケージの作成


    debuild

ざっと、以上のような手順でパッケージができます。
注意する点としては、dh_make で作った debian/rules は make install が下記の様になっています。


# Add here commands to install the package into debian/myprogram.
$(MAKE) DESTDIR=$(CURDIR)/debian/myprogram install
自作プログラムの Makefile で DESTDIR という変数によってインストール場所を変えられるようにしていないと、
make install 時にこけるので、なっていないなら Makefile をちょっといじっておくといいかもしれません。