綾小路龍之介の素人思考

[debian] メタパッケージの作成

メタパッケージとはこれをインストールすることであるタスクに必要なパッケージをすべてインストールできるようなパッケージ (他パッケージへの依存関係のみを収録するパッケージ)。仮想パッケージやダミーパッケージや擬似パッケージとは異なる。インストールするだけで日本語環境がわりとすんなり入る language-support-ja パッケージやパッケージのビルドに必要なパッケージを一発でインストールできる build-essential パッケージ等が好例かもしれない。

equivs を使う方法

必要なパッケージをインストール

# aptitude install equivs

debhelper の参照する環境変数を設定。これらは control や changelog で利用される。debian のPackages.gz ファイルを見ると、多くの人はファーストネーム、ファミリーネームの順番。基本的には","を使っていない。

$ export DEBFULLNAME="Ryuunosuke AYANOKOUZI"
$ export DEBEMAIL="i38w7i3@yahoo.co.jp"

controlファイルを作成

$ equivs-control hoge-control
$ cat hoge-control
### Commented entries have reasonable defaults.
### Uncomment to edit them.
Section: misc
Priority: optional
# Homepage: <enter URL here; no default>
Standards-Version: 3.6.2

Package: <package name; defaults to equivs-dummy>
# Version: <enter version here; defaults to 1.0>
# Maintainer: Your Name <yourname@example.com>
# Pre-Depends: <comma-separated list of packages>
# Depends: <comma-separated list of packages>
# Recommends: <comma-separated list of packages>
# Suggests: <comma-separated list of packages>
# Provides: <comma-separated list of packages>
# Replaces: <comma-separated list of packages>
# Architecture: all
# Copyright: <copyright file; defaults to GPL2>
# Changelog: <changelog file; defaults to a generic changelog>
# Readme: <README.Debian file; defaults to a generic one>
# Extra-Files: <comma-separated list of additional files for the doc directory>
# Files: <pair of space-separated paths; First is file to include, second is destination>
#  <more pairs, if there's more than one file to include. Notice the starting space>
Description: <short description; defaults to some wise words>
 long description and info
 .
 second paragraph

最低 Package 部分を書き換える。

$ sed -i -e 's/Package:.*/Package: hoge/' hoge-control
$ cat ns-control
### Commented entries have reasonable defaults.
### Uncomment to edit them.
Section: misc
Priority: optional
# Homepage: <enter URL here; no default>
Standards-Version: 3.6.2

Package: hoge
# Version: <enter version here; defaults to 1.0>
# Maintainer: Your Name <yourname@example.com>
# Pre-Depends: <comma-separated list of packages>
# Depends: <comma-separated list of packages>
# Recommends: <comma-separated list of packages>
# Suggests: <comma-separated list of packages>
# Provides: <comma-separated list of packages>
# Replaces: <comma-separated list of packages>
# Architecture: all
# Copyright: <copyright file; defaults to GPL2>
# Changelog: <changelog file; defaults to a generic changelog>
# Readme: <README.Debian file; defaults to a generic one>
# Extra-Files: <comma-separated list of additional files for the doc directory>
# Files: <pair of space-separated paths; First is file to include, second is destination>
#  <more pairs, if there's more than one file to include. Notice the starting space>
Description: <short description; defaults to some wise words>
 long description and info
 .
 second paragraph
</pre>

<p>controlファイルを元にビルドする。適当なファイルが出来上がる。</p>
<pre>
$ equivs-build hoge-control
dh_testdir
dh_testroot
dh_clean -k
dh_clean: dh_clean -k is deprecated; use dh_prep instead
dh_clean: Compatibility levels before 5 are deprecated.
dh_testdir
dh_testroot
dh_install
dh_install: Compatibility levels before 5 are deprecated.
dh_installdocs
dh_installdocs: Compatibility levels before 5 are deprecated.
dh_installchangelogs
dh_installchangelogs: Compatibility levels before 5 are deprecated.
dh_compress
dh_compress: Compatibility levels before 5 are deprecated.
dh_fixperms
dh_fixperms: Compatibility levels before 5 are deprecated.
dh_installdeb
dh_installdeb: Compatibility levels before 5 are deprecated.
dh_gencontrol
dh_gencontrol: Compatibility levels before 5 are deprecated.
dh_md5sums
dh_md5sums: Compatibility levels before 5 are deprecated.
dh_builddeb
dh_builddeb: Compatibility levels before 5 are deprecated.
dpkg-deb: building package `hoge' in `../hoge_1.0_all.deb'.

The package has been created.
Attention, the package has been created in the current directory,
not in ".." as indicated by the message above!

パッケージの内容は以下のような感じ。

$ dpkg-deb -I hoge_1.0_all.deb
 new debian package, version 2.0.
 size 2062 bytes: control archive= 477 bytes.
     263 bytes,    11 lines      control
     196 bytes,     3 lines      md5sums
 Package: hoge
 Version: 1.0
 Architecture: all
 Maintainer: Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>
 Installed-Size: 36
 Section: misc
 Priority: optional
 Description: <short description; defaults to some wise words>
  long description and info
  .
  second paragraph
$ dpkg-deb -c hoge_1.0_all.deb
drwxr-xr-x root/root         0 2012-11-14 12:51 ./
drwxr-xr-x root/root         0 2012-11-14 12:51 ./usr/
drwxr-xr-x root/root         0 2012-11-14 12:51 ./usr/share/
drwxr-xr-x root/root         0 2012-11-14 12:51 ./usr/share/doc/
drwxr-xr-x root/root         0 2012-11-14 12:51 ./usr/share/doc/hoge/
-rw-r--r-- root/root       148 2012-11-14 12:51 ./usr/share/doc/hoge/changelog.gz
-rw-r--r-- root/root       742 2012-11-14 12:51 ./usr/share/doc/hoge/README.Debian
-rw-r--r-- root/root       936 2012-11-14 12:51 ./usr/share/doc/hoge/copyright

postinst 等のスクリプトをメタパッケージに含めたい場合がある。たとえば以下のようなファイルを含めたい場合、以下のようにする。

$ cat hoge-postinst
#!/bin/sh

exit 0
$ echo "File: postinst" >> hoge-control
$ sed -e 's/^$/./' -e 's/^/ /' hoge-postinst >> hoge-control

再度ビルド作業を行う。

$ equivs-build hoge-control
Use of uninitialized value $m in oct at /usr/bin/equivs-build line 72.
dh_testdir
dh_testroot
dh_clean -k
dh_clean: dh_clean -k is deprecated; use dh_prep instead
dh_clean: Compatibility levels before 5 are deprecated.
dh_testdir
dh_testroot
dh_install
dh_install: Compatibility levels before 5 are deprecated.
dh_installdocs
dh_installdocs: Compatibility levels before 5 are deprecated.
dh_installchangelogs
dh_installchangelogs: Compatibility levels before 5 are deprecated.
dh_compress
dh_compress: Compatibility levels before 5 are deprecated.
dh_fixperms
dh_fixperms: Compatibility levels before 5 are deprecated.
dh_installdeb
dh_installdeb: Compatibility levels before 5 are deprecated.
dh_gencontrol
dh_gencontrol: Compatibility levels before 5 are deprecated.
dh_md5sums
dh_md5sums: Compatibility levels before 5 are deprecated.
dh_builddeb
dh_builddeb: Compatibility levels before 5 are deprecated.
dpkg-deb: building package `hoge' in `../hoge_1.0_all.deb'.

The package has been created.
Attention, the package has been created in the current directory,
not in ".." as indicated by the message above!
$ dpkg-deb -I hoge_1.0_all.deb
 new debian package, version 2.0.
 size 2110 bytes: control archive= 515 bytes.
     263 bytes,    11 lines      control
     196 bytes,     3 lines      md5sums
      18 bytes,     3 lines   *  postinst             #!/bin/sh
 Package: hoge
 Version: 1.0
 Architecture: all
 Maintainer: Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>
 Installed-Size: 40
 Section: misc
 Priority: optional
 Description: <short description; defaults to some wise words>
  long description and info
  .
  second paragraph
$ dpkg-deb -c hoge_1.0_all.deb
drwxr-xr-x root/root         0 2012-11-14 13:12 ./
drwxr-xr-x root/root         0 2012-11-14 13:12 ./usr/
drwxr-xr-x root/root         0 2012-11-14 13:12 ./usr/share/
drwxr-xr-x root/root         0 2012-11-14 13:12 ./usr/share/doc/
drwxr-xr-x root/root         0 2012-11-14 13:12 ./usr/share/doc/hoge/
-rw-r--r-- root/root       148 2012-11-14 13:12 ./usr/share/doc/hoge/changelog.gz
-rw-r--r-- root/root       742 2012-11-14 13:12 ./usr/share/doc/hoge/README.Debian
-rw-r--r-- root/root       936 2012-11-14 13:12 ./usr/share/doc/hoge/copyright

また、適当なテキストファイルを含めることも可能。

$ cat hoge-control
### Commented entries have reasonable defaults.
### Uncomment to edit them.
Section: misc
Priority: optional
# Homepage: <enter URL here; no default>
Standards-Version: 3.6.2

Package: hoge
# Version: <enter version here; defaults to 1.0>
# Maintainer: Your Name <yourname@example.com>
# Pre-Depends: <comma-separated list of packages>
# Depends: <comma-separated list of packages>
# Recommends: <comma-separated list of packages>
# Suggests: <comma-separated list of packages>
# Provides: <comma-separated list of packages>
# Replaces: <comma-separated list of packages>
# Architecture: all
# Copyright: <copyright file; defaults to GPL2>
# Changelog: <changelog file; defaults to a generic changelog>
# Readme: <README.Debian file; defaults to a generic one>
# Extra-Files: <comma-separated list of additional files for the doc directory>
# Files: <pair of space-separated paths; First is file to include, second is destination>
#  <more pairs, if there's more than one file to include. Notice the starting space>
Description: <short description; defaults to some wise words>
 long description and info
 .
 second paragraph
File: postinst
 #!/bin/sh
 .
 exit 0
File: /etc/skel/.hogerc
 #!/bin/sh
 .
 exit 0
$ equivs-build hoge-control
Use of uninitialized value $m in oct at /usr/bin/equivs-build line 72.
Use of uninitialized value $m in oct at /usr/bin/equivs-build line 72.
dh_testdir
dh_testroot
dh_clean -k
dh_clean: dh_clean -k is deprecated; use dh_prep instead
dh_clean: Compatibility levels before 5 are deprecated.
dh_testdir
dh_testroot
dh_install
dh_install: Compatibility levels before 5 are deprecated.
dh_installdocs
dh_installdocs: Compatibility levels before 5 are deprecated.
dh_installchangelogs
dh_installchangelogs: Compatibility levels before 5 are deprecated.
dh_compress
dh_compress: Compatibility levels before 5 are deprecated.
dh_fixperms
dh_fixperms: Compatibility levels before 5 are deprecated.
dh_installdeb
dh_installdeb: Compatibility levels before 5 are deprecated.
dh_gencontrol
dh_gencontrol: Compatibility levels before 5 are deprecated.
dh_md5sums
dh_md5sums: Compatibility levels before 5 are deprecated.
dh_builddeb
dh_builddeb: Compatibility levels before 5 are deprecated.
dpkg-deb: building package `hoge' in `../hoge_1.0_all.deb'.

The package has been created.
Attention, the package has been created in the current directory,
not in ".." as indicated by the message above!
$ dpkg-deb -I hoge_1.0_all.deb
 new debian package, version 2.0.
 size 2204 bytes: control archive= 551 bytes.
      18 bytes,     1 lines      conffiles
     263 bytes,    11 lines      control
     196 bytes,     3 lines      md5sums
      18 bytes,     3 lines   *  postinst             #!/bin/sh
 Package: hoge
 Version: 1.0
 Architecture: all
 Maintainer: Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>
 Installed-Size: 56
 Section: misc
 Priority: optional
 Description: <short description; defaults to some wise words>
  long description and info
  .
  second paragraph
$ dpkg-deb -c hoge_1.0_all.deb
drwxr-xr-x root/root         0 2012-11-14 13:35 ./
drwxr-xr-x root/root         0 2012-11-14 13:35 ./usr/
drwxr-xr-x root/root         0 2012-11-14 13:35 ./usr/share/
drwxr-xr-x root/root         0 2012-11-14 13:35 ./usr/share/doc/
drwxr-xr-x root/root         0 2012-11-14 13:35 ./usr/share/doc/hoge/
-rw-r--r-- root/root       148 2012-11-14 13:35 ./usr/share/doc/hoge/changelog.gz
-rw-r--r-- root/root       742 2012-11-14 13:35 ./usr/share/doc/hoge/README.Debian
-rw-r--r-- root/root       936 2012-11-14 13:35 ./usr/share/doc/hoge/copyright
drwxr-xr-x root/root         0 2012-11-14 13:35 ./etc/
drwxr-xr-x root/root         0 2012-11-14 13:35 ./etc/skel/
-rw-r--r-- root/root        18 2012-11-14 13:35 ./etc/skel/.hogerc

equivs-build が "Use of uninitialized value $m in oct at /usr/bin/equivs-build line 72." と言っているのは、パーミッションの設定が書かれていないから。パーミッションの設定を control ファイルに書き込むことでこのエラーは消える。equivs-build が中間ファイルを作っている時点ではこのパーミッションが反映されるが、debhelper が適当なものに変えてしまうため、実際 deb パッケージに収められるパーミッションに反映されるとは限らない。たとえば以下の例では .hogerd と hoge.txt のパーミッションを666にしているが、実際の deb パッケージに収められるパーミッションは 644 に変わっている。

$ cat hoge-control
### Commented entries have reasonable defaults.
### Uncomment to edit them.
Section: misc
Priority: optional
# Homepage: <enter URL here; no default>
Standards-Version: 3.6.2

Package: hoge
# Version: <enter version here; defaults to 1.0>
# Maintainer: Your Name <yourname@example.com>
# Pre-Depends: <comma-separated list of packages>
# Depends: <comma-separated list of packages>
# Recommends: <comma-separated list of packages>
# Suggests: <comma-separated list of packages>
# Provides: <comma-separated list of packages>
# Replaces: <comma-separated list of packages>
# Architecture: all
# Copyright: <copyright file; defaults to GPL2>
# Changelog: <changelog file; defaults to a generic changelog>
# Readme: <README.Debian file; defaults to a generic one>
# Extra-Files: <comma-separated list of additional files for the doc directory>
# Files: <pair of space-separated paths; First is file to include, second is destination>
#  <more pairs, if there's more than one file to include. Notice the starting space>
Description: <short description; defaults to some wise words>
 long description and info
 .
 second paragraph
File: postinst 0777
 #!/bin/sh
 .
 exit 0
File: /etc/skel/.hogerc 0666
 #!/bin/sh
 .
 exit 0
File: /etc/skel/hoge.txt 0666
 #!/bin/sh
 .
 exit 0
$ equivs-build hoge-control
dh_testdir
dh_testroot
dh_clean -k
dh_clean: dh_clean -k is deprecated; use dh_prep instead
dh_clean: Compatibility levels before 5 are deprecated.
dh_testdir
dh_testroot
dh_install
dh_install: Compatibility levels before 5 are deprecated.
dh_installdocs
dh_installdocs: Compatibility levels before 5 are deprecated.
dh_installchangelogs
dh_installchangelogs: Compatibility levels before 5 are deprecated.
dh_compress
dh_compress: Compatibility levels before 5 are deprecated.
dh_fixperms
dh_fixperms: Compatibility levels before 5 are deprecated.
dh_installdeb
dh_installdeb: Compatibility levels before 5 are deprecated.
dh_gencontrol
dh_gencontrol: Compatibility levels before 5 are deprecated.
dh_md5sums
dh_md5sums: Compatibility levels before 5 are deprecated.
dh_builddeb
dh_builddeb: Compatibility levels before 5 are deprecated.
dpkg-deb: building package `hoge' in `../hoge_1.0_all.deb'.

The package has been created.
Attention, the package has been created in the current directory,
not in ".." as indicated by the message above!
$ dpkg-deb -I hoge_1.0_all.deb
 new debian package, version 2.0.
 size 2270 bytes: control archive= 555 bytes.
      37 bytes,     2 lines      conffiles
     263 bytes,    11 lines      control
     196 bytes,     3 lines      md5sums
      18 bytes,     3 lines   *  postinst             #!/bin/sh
 Package: hoge
 Version: 1.0
 Architecture: all
 Maintainer: Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>
 Installed-Size: 60
 Section: misc
 Priority: optional
 Description: <short description; defaults to some wise words>
  long description and info
  .
  second paragraph
$ dpkg-deb -c hoge_1.0_all.deb
drwxr-xr-x root/root         0 2012-11-14 14:47 ./
drwxr-xr-x root/root         0 2012-11-14 14:47 ./usr/
drwxr-xr-x root/root         0 2012-11-14 14:47 ./usr/share/
drwxr-xr-x root/root         0 2012-11-14 14:47 ./usr/share/doc/
drwxr-xr-x root/root         0 2012-11-14 14:47 ./usr/share/doc/hoge/
-rw-r--r-- root/root       148 2012-11-14 14:47 ./usr/share/doc/hoge/changelog.gz
-rw-r--r-- root/root       742 2012-11-14 14:47 ./usr/share/doc/hoge/README.Debian
-rw-r--r-- root/root       936 2012-11-14 14:47 ./usr/share/doc/hoge/copyright
drwxr-xr-x root/root         0 2012-11-14 14:47 ./etc/
drwxr-xr-x root/root         0 2012-11-14 14:47 ./etc/skel/
-rw-r--r-- root/root        18 2012-11-14 14:47 ./etc/skel/.hogerc
-rw-r--r-- root/root        18 2012-11-14 14:47 ./etc/skel/hoge.txt

Changelog、Readme、Copyright についてはファイルパスを指定して外部からファイルを提供できる。以下は changelog を指定した例。

$ cat changelog
hoge (1.1) unstable; urgency=low

  * 2nd version

 -- Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>  Wed, 14 Nov 2012 15:27:47 +0900

hoge (1.0) unstable; urgency=low

  * First version

 -- Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>  Wed, 14 Nov 2012 14:38:48 +0900
$ cat hoge-control
### Commented entries have reasonable defaults.
### Uncomment to edit them.
Section: misc
Priority: optional
# Homepage: <enter URL here; no default>
Standards-Version: 3.6.2

Package: hoge
# Version: <enter version here; defaults to 1.0>
# Maintainer: Your Name <yourname@example.com>
# Pre-Depends: <comma-separated list of packages>
# Depends: <comma-separated list of packages>
# Recommends: <comma-separated list of packages>
# Suggests: <comma-separated list of packages>
# Provides: <comma-separated list of packages>
# Replaces: <comma-separated list of packages>
# Architecture: all
# Copyright: <copyright file; defaults to GPL2>
# Changelog: <changelog file; defaults to a generic changelog>
# Readme: <README.Debian file; defaults to a generic one>
# Extra-Files: <comma-separated list of additional files for the doc directory>
# Files: <pair of space-separated paths; First is file to include, second is destination>
#  <more pairs, if there's more than one file to include. Notice the starting space>
Description: <short description; defaults to some wise words>
 long description and info
 .
 second paragraph
File: postinst 0777
 #!/bin/sh
 .
 exit 0
File: /etc/skel/.hogerc 0666
 #!/bin/sh
 .
 exit 0
File: /etc/skel/hoge.txt 0666
 #!/bin/sh
 .
 exit 0
$ equivs-build hoge-control
dh_testdir
dh_testroot
dh_clean -k
dh_clean: dh_clean -k is deprecated; use dh_prep instead
dh_clean: Compatibility levels before 5 are deprecated.
dh_testdir
dh_testroot
dh_install
dh_install: Compatibility levels before 5 are deprecated.
dh_installdocs
dh_installdocs: Compatibility levels before 5 are deprecated.
dh_installchangelogs
dh_installchangelogs: Compatibility levels before 5 are deprecated.
dh_compress
dh_compress: Compatibility levels before 5 are deprecated.
dh_fixperms
dh_fixperms: Compatibility levels before 5 are deprecated.
dh_installdeb
dh_installdeb: Compatibility levels before 5 are deprecated.
dh_gencontrol
dh_gencontrol: Compatibility levels before 5 are deprecated.
dh_md5sums
dh_md5sums: Compatibility levels before 5 are deprecated.
dh_builddeb
dh_builddeb: Compatibility levels before 5 are deprecated.
dpkg-deb: building package `hoge' in `../hoge_1.1_all.deb'.

The package has been created.
Attention, the package has been created in the current directory,
not in ".." as indicated by the message above!
$ dpkg-deb -x hoge_1.1_all.deb hoge_1.1_all
$ zcat hoge_1.1_all/usr/share/doc/hoge/changelog.gz
hoge (1.1) unstable; urgency=low

  * 2nd version

 -- Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>  Wed, 14 Nov 2012 15:27:47 +0900

hoge (1.0) unstable; urgency=low

  * First version

 -- Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>  Wed, 14 Nov 2012 14:38:48 +0900

debhelper を使う方法

今回はアーキテクチャに依存しないメタパッケージを作る。まずはパッケージ名とバージョンを含めたディレクトリを作り、そのディレクトリに移動して、パッケージの雛形を作成する。

$ mkdir hoge-dh-1.0
$ cd hoge-dh-1.0/
$ dh_make --single --native --createorig --packagename hoge-dh
Maintainer name : Ryuunosuke AYANOKOUZI
Email-Address   : i38w7i3@yahoo.co.jp
Date                            : Thu, 15 Nov 2012 05:26:06 +0900
Package Name     : hoge-dh
Version                 : 1.0
License                 : gpl3
Using dpatch     : no
Type of Package : Single
Hit <enter> to confirm:
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 hoge-dh Makefiles install into $DESTDIR and not in / .

debian ディレクトリにあるexやEXで終わるファイルは例。後々メンテナンススクリプト等の雛形に使える。存在してもビルド中に使われることはない。必要なファイル以外を削除して、controlファイルとcopyrightファイルを編集。

$ rm debian/*.ex debian/*.EX debian/README.Debian debian/README.source debian/README debian/docs
$ sed -i -e 's#^Section: .*#Section: localization#' \
        -e 's#^Architecture: .*#Architecture: all#' \
        -e 's#^Depends: .*#Depends: ${misc:Depends}#' \
        -e 's#^Standards-Version: .*#Standards-Version: 3.9.1#' \
        -e 's#^Homepage: .*#Homepage: http://example.com/hoge#' \
        -e 's#^Description: .*#Description: test metapackage#' \
        -e 's#^ <insert .*# long discription for test metapackage#' \
        debian/control
$ sed -i -e 's#<url://example.com>#http://example.com/hoge#' \
        -e '/<likewise for another author>/d' \
        -e "s#<put author's name and email here>#Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>#" \
        -e 's#<Copyright (C) YYYY Firstname Lastname>#Copyright (C) 2012 Ryuunosuke AYANOKOUZI#' \
        -e '/# Please also look if there are files or directories which have a/d' \
        -e '/# different copyright\/license attached and list them here\./d' \
        debian/copyright

ビルド。

$ debuild -us -uc
 dpkg-buildpackage -rfakeroot -D -us -uc
dpkg-buildpackage: export CFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export CPPFLAGS from dpkg-buildflags (origin: vendor):
dpkg-buildpackage: export CXXFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export FFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export LDFLAGS from dpkg-buildflags (origin: vendor):
dpkg-buildpackage: source package hoge-dh
dpkg-buildpackage: source version 1.0
dpkg-buildpackage: source changed by Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>
 dpkg-source --before-build hoge-dh-1.0
dpkg-buildpackage: host architecture amd64
 fakeroot debian/rules clean
dh clean
   dh_testdir
   dh_auto_clean
   dh_clean
 dpkg-source -b hoge-dh-1.0
dpkg-source: info: using source format `3.0 (native)'
dpkg-source: info: building hoge-dh in hoge-dh_1.0.tar.gz
dpkg-source: info: building hoge-dh in hoge-dh_1.0.dsc
 debian/rules build
dh build
   dh_testdir
   dh_auto_configure
   dh_auto_build
   dh_auto_test
 fakeroot debian/rules binary
dh binary
   dh_testroot
   dh_prep
   dh_installdirs
   dh_auto_install
   dh_install
   dh_installdocs
   dh_installchangelogs
   dh_installexamples
   dh_installman
   dh_installcatalogs
   dh_installcron
   dh_installdebconf
   dh_installemacsen
   dh_installifupdown
   dh_installinfo
   dh_pysupport
   dh_installinit
   dh_installmenu
   dh_installmime
   dh_installmodules
   dh_installlogcheck
   dh_installlogrotate
   dh_installpam
   dh_installppp
   dh_installudev
   dh_installwm
   dh_installxfonts
   dh_bugfiles
   dh_lintian
   dh_gconf
   dh_icons
   dh_perl
   dh_usrlocal
   dh_link
   dh_compress
   dh_fixperms
   dh_strip
   dh_makeshlibs
   dh_shlibdeps
   dh_installdeb
   dh_gencontrol
   dh_md5sums
   dh_builddeb
dpkg-deb: building package `hoge-dh' in `../hoge-dh_1.0_all.deb'.
 dpkg-genchanges  >../hoge-dh_1.0_amd64.changes
dpkg-genchanges: including full source code in upload
 dpkg-source --after-build hoge-dh-1.0
dpkg-buildpackage: full upload; Debian-native package (full source is included)
Now running lintian...
Finished running lintian.

作成されたパッケージは親ディレクトリにある。

$ ls -la ../
total 32
drwxr-xr-x  3 **** **** 4096 2012-11-15 05:26 .
drwxr-xr-x 10 **** **** 4096 2012-11-15 03:01 ..
drwxr-xr-x  3 **** **** 4096 2012-11-15 05:26 hoge-dh-1.0
-rw-r--r--  1 **** **** 1898 2012-11-15 05:26 hoge-dh_1.0_all.deb
-rw-r--r--  1 **** **** 2157 2012-11-15 05:27 hoge-dh_1.0_amd64.build
-rw-r--r--  1 **** **** 1119 2012-11-15 05:26 hoge-dh_1.0_amd64.changes
-rw-r--r--  1 **** ****  495 2012-11-15 05:26 hoge-dh_1.0.dsc
-rw-r--r--  1 **** **** 1618 2012-11-15 05:26 hoge-dh_1.0.tar.gz
$ dpkg-deb -I ../hoge-dh_1.0_all.deb
 new debian package, version 2.0.
 size 1898 bytes: control archive= 436 bytes.
     264 bytes,    10 lines      control
     135 bytes,     2 lines      md5sums
 Package: hoge-dh
 Version: 1.0
 Architecture: all
 Maintainer: Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>
 Installed-Size: 32
 Section: localization
 Priority: extra
 Homepage: http://example.com/hoge
 Description: test metapackage
  long discription for test metapackage
$ dpkg-deb -c ../hoge-dh_1.0_all.deb
drwxr-xr-x root/root         0 2012-11-15 05:26 ./
drwxr-xr-x root/root         0 2012-11-15 05:26 ./usr/
drwxr-xr-x root/root         0 2012-11-15 05:26 ./usr/share/
drwxr-xr-x root/root         0 2012-11-15 05:26 ./usr/share/doc/
drwxr-xr-x root/root         0 2012-11-15 05:26 ./usr/share/doc/hoge-dh/
-rw-r--r-- root/root       152 2012-11-15 05:26 ./usr/share/doc/hoge-dh/changelog.gz
-rw-r--r-- root/root      1622 2012-11-15 05:26 ./usr/share/doc/hoge-dh/copyright

changelogの編集は dch 経由で行う。バージョンを上げるには -i オプション (バージョンの増加は適切に(一つ前のバージョンに Debian リビジョンがあれば、それを、なければアップストリームバージョンを)行われる。)。明示する場合は -v オプション。最後の引数でコメントを書ける。これがない場合はエディタ起動。

$ cat debian/changelog
hoge-dh (1.0) unstable; urgency=low

  * Initial Release.

 -- Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>  Thu, 15 Nov 2012 05:26:06 +0900
$ dch -i 'some comments for v1.1 here'
dch warning: your current directory has been renamed to:
../hoge-dh-1.1
dch warning: no orig tarball found for the new version.
$ cat debian/changelog
hoge-dh (1.1) unstable; urgency=low

  * some comments for v1.1 here

 -- Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>  Fri, 16 Nov 2012 08:14:35 +0900

hoge-dh (1.0) unstable; urgency=low

  * Initial Release.

 -- Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>  Thu, 15 Nov 2012 05:26:06 +0900
$ dch 'another comments for v1.1  here'
$ cat debian/changelog
hoge-dh (1.1) unstable; urgency=low

  * some comments for v1.1 here
  * another comments for v1.1  here

 -- Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>  Fri, 16 Nov 2012 08:14:49 +0900

hoge-dh (1.0) unstable; urgency=low

  * Initial Release.

 -- Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>  Thu, 15 Nov 2012 05:26:06 +0900
$ dch -v 2.0 'some comments for v2.0 here'
dch warning: your current directory has been renamed to:
../hoge-dh-2.0
dch warning: no orig tarball found for the new version.
$ cat debian/changelog
hoge-dh (2.0) unstable; urgency=low

  * some comments for v2.0 here

 -- Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>  Fri, 16 Nov 2012 08:14:59 +0900

hoge-dh (1.1) unstable; urgency=low

  * some comments for v1.1 here
  * another comments for v1.1  here

 -- Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>  Fri, 16 Nov 2012 08:14:49 +0900

hoge-dh (1.0) unstable; urgency=low

  * Initial Release.

 -- Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>  Thu, 15 Nov 2012 05:26:06 +0900
$ cd ../hoge-dh-2.0/
$ debuild -us -uc
 dpkg-buildpackage -rfakeroot -D -us -uc
dpkg-buildpackage: export CFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export CPPFLAGS from dpkg-buildflags (origin: vendor):
dpkg-buildpackage: export CXXFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export FFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export LDFLAGS from dpkg-buildflags (origin: vendor):
dpkg-buildpackage: source package hoge-dh
dpkg-buildpackage: source version 2.0
dpkg-buildpackage: source changed by Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>
 dpkg-source --before-build hoge-dh-2.0
dpkg-buildpackage: host architecture amd64
 fakeroot debian/rules clean
dh clean
   dh_testdir
   dh_auto_clean
   dh_clean
 dpkg-source -b hoge-dh-2.0
dpkg-source: info: using source format `3.0 (native)'
dpkg-source: info: building hoge-dh in hoge-dh_2.0.tar.gz
dpkg-source: info: building hoge-dh in hoge-dh_2.0.dsc
 debian/rules build
dh build
   dh_testdir
   dh_auto_configure
   dh_auto_build
   dh_auto_test
 fakeroot debian/rules binary
dh binary
   dh_testroot
   dh_prep
   dh_installdirs
   dh_auto_install
   dh_install
   dh_installdocs
   dh_installchangelogs
   dh_installexamples
   dh_installman
   dh_installcatalogs
   dh_installcron
   dh_installdebconf
   dh_installemacsen
   dh_installifupdown
   dh_installinfo
   dh_pysupport
   dh_installinit
   dh_installmenu
   dh_installmime
   dh_installmodules
   dh_installlogcheck
   dh_installlogrotate
   dh_installpam
   dh_installppp
   dh_installudev
   dh_installwm
   dh_installxfonts
   dh_bugfiles
   dh_lintian
   dh_gconf
   dh_icons
   dh_perl
   dh_usrlocal
   dh_link
   dh_compress
   dh_fixperms
   dh_strip
   dh_makeshlibs
   dh_shlibdeps
   dh_installdeb
   dh_gencontrol
   dh_md5sums
   dh_builddeb
dpkg-deb: building package `hoge-dh' in `../hoge-dh_2.0_all.deb'.
 dpkg-genchanges  >../hoge-dh_2.0_amd64.changes
dpkg-genchanges: including full source code in upload
 dpkg-source --after-build hoge-dh-2.0
dpkg-buildpackage: full upload; Debian-native package (full source is included)
Now running lintian...
Finished running lintian.

debian ディレクトリの中にメンテナンススクリプトを配置すれば、ビルド後に適切なスクリプトが含まれるようになる。またdh_installdeb(1) によればメンテナスクリプトを追加するには debian ディレクトリの中に PACKAGE.postinst 等のファイルを作成する。PACKAGE はパッケージの名前に置き換える。ここでは hoge-dh。

$ mv debian/postinst{.ex,}
$ debuild -us -uc
 dpkg-buildpackage -rfakeroot -D -us -uc
dpkg-buildpackage: export CFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export CPPFLAGS from dpkg-buildflags (origin: vendor):
dpkg-buildpackage: export CXXFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export FFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export LDFLAGS from dpkg-buildflags (origin: vendor):
dpkg-buildpackage: source package hoge-dh
dpkg-buildpackage: source version 1.0
dpkg-buildpackage: source changed by Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>
 dpkg-source --before-build hoge-dh-1.0
dpkg-buildpackage: host architecture amd64
 fakeroot debian/rules clean
dh clean
   dh_testdir
   dh_auto_clean
   dh_clean
 dpkg-source -b hoge-dh-1.0
dpkg-source: info: using source format `3.0 (native)'
dpkg-source: info: building hoge-dh in hoge-dh_1.0.tar.gz
dpkg-source: info: building hoge-dh in hoge-dh_1.0.dsc
 debian/rules build
dh build
   dh_testdir
   dh_auto_configure
   dh_auto_build
   dh_auto_test
 fakeroot debian/rules binary
dh binary
   dh_testroot
   dh_prep
   dh_installdirs
   dh_auto_install
   dh_install
   dh_installdocs
   dh_installchangelogs
   dh_installexamples
   dh_installman
   dh_installcatalogs
   dh_installcron
   dh_installdebconf
   dh_installemacsen
   dh_installifupdown
   dh_installinfo
   dh_pysupport
   dh_installinit
   dh_installmenu
   dh_installmime
   dh_installmodules
   dh_installlogcheck
   dh_installlogrotate
   dh_installpam
   dh_installppp
   dh_installudev
   dh_installwm
   dh_installxfonts
   dh_bugfiles
   dh_lintian
   dh_gconf
   dh_icons
   dh_perl
   dh_usrlocal
   dh_link
   dh_compress
   dh_fixperms
   dh_strip
   dh_makeshlibs
   dh_shlibdeps
   dh_installdeb
   dh_gencontrol
   dh_md5sums
   dh_builddeb
dpkg-deb: building package `hoge-dh' in `../hoge-dh_1.0_all.deb'.
 dpkg-genchanges  >../hoge-dh_1.0_amd64.changes
dpkg-genchanges: including full source code in upload
 dpkg-source --after-build hoge-dh-1.0
dpkg-buildpackage: full upload; Debian-native package (full source is included)
Now running lintian...
W: hoge-dh source: dh-make-template-in-source debian/hoge-dh.default.ex
W: hoge-dh source: dh-make-template-in-source debian/postrm.ex
W: hoge-dh source: dh-make-template-in-source debian/hoge-dh.doc-base.EX
W: hoge-dh source: dh-make-template-in-source debian/manpage.xml.ex
W: hoge-dh source: dh-make-template-in-source debian/manpage.sgml.ex
W: hoge-dh source: dh-make-template-in-source debian/menu.ex
W: hoge-dh source: dh-make-template-in-source debian/prerm.ex
W: hoge-dh source: dh-make-template-in-source debian/emacsen-remove.ex
W: hoge-dh source: dh-make-template-in-source debian/hoge-dh.cron.d.ex
W: hoge-dh source: dh-make-template-in-source debian/preinst.ex
W: hoge-dh source: dh-make-template-in-source debian/manpage.1.ex
W: hoge-dh source: dh-make-template-in-source debian/emacsen-startup.ex
W: hoge-dh source: dh-make-template-in-source debian/watch.ex
W: hoge-dh source: dh-make-template-in-source debian/init.d.ex
W: hoge-dh source: dh-make-template-in-source debian/emacsen-install.ex
W: hoge-dh: readme-debian-contains-debmake-template
W: hoge-dh: maintainer-script-empty postinst
Finished running lintian.
$ dpkg-deb -I ../hoge-dh_1.0_all.deb
 new debian package, version 2.0.
 size 2478 bytes: control archive= 915 bytes.
     264 bytes,    10 lines      control
     205 bytes,     3 lines      md5sums
     946 bytes,    39 lines   *  postinst             #!/bin/sh
 Package: hoge-dh
 Version: 1.0
 Architecture: all
 Maintainer: Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>
 Installed-Size: 40
 Section: localization
 Priority: extra
 Homepage: http://example.com/hoge
 Description: test metapackage
  long discription for test metapackage
</pre>

<pre>
$ mkdir hoge-dh-1.0.0
$ tar oczf hoge-dh-1.0.0.tar.gz hoge-dh-1.0.0
$ tar -cvz --owner=root --group=root -f hoge-dh-1.0.0.tar.gz hoge-dh-1.0.0
$ tar tvzf hoge-dh-1.0.0.tar.gz
$ cd hoge-dh-1.0.0/
$ dh_make --single --createorig -c gpl --packagename hoge-dh -f ../hoge-dh-1.0.0.tar.gz
$ mv debian/postinst{.ex,}
$ sed -i -e 's#^Section: .*#Section: localization#' \
        -e 's#^Architecture: .*#Architecture: all#' \
        -e 's#^Depends: .*#Depends: ${misc:Depends}#' \
        -e 's#^Standards-Version: .*#Standards-Version: 3.9.1#' \
        -e 's#^Homepage: .*#Homepage: http://example.com/hoge#' \
        -e 's#^Description: .*#Description: test metapackage#' \
        -e 's#^ <insert .*# long discription for test metapackage#' \
        debian/control
$ sed -i -e 's#<url://example.com>#http://example.com/hoge#' \
        -e '/<likewise for another author>/d' \
        -e "s#<put author's name and email here>#Ryuunosuke AYANOKOUZI <i38w7i3@yahoo.co.jp>#" \
        -e 's#<Copyright (C) YYYY Firstname Lastname>#Copyright (C) 2012 Ryuunosuke AYANOKOUZI#' \
        -e '/# Please also look if there are files or directories which have a/d' \
        -e '/# different copyright\/license attached and list them here\./d' \
        debian/copyright
$ debuild -us -uc
$ dpkg-deb -c ../hoge-dh_1.0.0-1_all.deb
$ dpkg-deb -I ../hoge-dh_1.0.0-1_all.deb

パッケージを公開する場合は署名が必要。基本的には上に書いた DEBFULLNAME や DEBEMAIL 環境変数から鍵が選ばれるが、DEBSIGN_KEYID を設定することで利用する鍵を指定することもできる。これは設定を /etc/devscripts.conf や ~/.devscripts に書き込むことで行う。コマンドラインで直接指定するには debuild -k を使う。dsc と changes ファイルに対してインライン署名が行われる。書名の確認は gpg --verify を使って行う。

$ export DEBFULLNAME="Ryuunosuke AYANOKOUZI"
$ export DEBEMAIL="i38w7i3@yahoo.co.jp"
$ cat <<EOF >> ~/.devscripts
DEBSIGN_KEYID="XXXXXXXX"
DEBUILD_LINTIAN_OPTS="-i -I --show-overrides"
EOF
$ debuild
(snip)
Now signing changes and any dsc files...
 signfile hoge-dh_1.0.0-4~rc4.dsc XXXXXXXX

You need a passphrase to unlock the secret key for
user: "AYANOKOUZI, Ryuunosuke"
4096-bit RSA key, ID XXXXXXXX, created YYYY-MM-DD


 signfile hoge-dh_1.0.0-4~rc4_amd64.changes XXXXXXXX

You need a passphrase to unlock the secret key for
user: "AYANOKOUZI, Ryuunosuke"
4096-bit RSA key, ID XXXXXXXX, created YYYY-MM-DD


Successfully signed dsc and changes files
$ gpg --verify ../hoge-dh_1.0.0-4~rc4.dsc
gpg: Signature made WWW DD MMM YYYY 02:07:03 PM JST using RSA key ID XXXXXXXX
gpg: Good signature from "AYANOKOUZI, Ryuunosuke"
$ gpg --verify ../hoge-dh_1.0.0-4~rc4_amd64.changes
gpg: Signature made WWW DD MMM YYYY 02:07:20 PM JST using RSA key ID XXXXXXXX
gpg: Good signature from "AYANOKOUZI, Ryuunosuke"

パッケージの署名とaptサーバのdists/hoge/Releaseファイルの署名は別物。

新しいソースを使う場合にはdch でアップストリームバージョンをあげる。カレントディレクトリの名前が変更されて、親ディレクトリにorigが無いと言われる。ディレクトリを移動して、親ディレクトリに3.0.0用のorigファイルを作成する。

$ dch -v 3.0.0-1~rc1 'new source'
dch warning: your current directory has been renamed to:
../hoge-dh-3.0.0
dch warning: no orig tarball found for the new version.
$ cd ../hoge-dh-3.0.0/
$ mv ../hoge-dh_2.0.0.orig.tar.gz ../hoge-dh_3.0.0.orig.tar.gz

リファレンス

  1. debian "仮想パッケージ"|"ダミーパッケージ"|"メタパッケージ" - Google 検索
  2. MetaPackages - Ubuntu Japanese Wiki
  3. Debian GNU/Linux 2.2 (`potato') PowerPC リリースノート - Debian GNU/Linux 2.2 は何が新しいのか
  4. 毎日が反省会 --nigauri.org--(2011-12-24)
  5. Debianベースのシステムでパッケージを自作する - SourceForge.JP Magazine : オープンソースの話題満載
  6. Ubuntu -- hardy の language-support-ja パッケージに関する詳細
  7. Index of /ubuntu/pool/main/l/language-support-ja
  8. Ubuntu -- raring の language-pack-ja-base パッケージに関する詳細
  9. Index of /ubuntu/pool/main/l/language-pack-ja-base
  10. Debian -- squeeze の build-essential パッケージに関する詳細
  11. Index of /debian/pool/main/b/build-essential
  12. GNU/Linux Debian user questions for Debian JP Project
  13. "メタパッケージ" 作成 debian - Google 検索
  14. Debian 新メンテナーガイド
  15. Debian -- squeeze の dh-make パッケージに関する詳細
  16. How to extract RPM or DEB packages
  17. めも - debパッケージを展開する
  18. 「第0回Debianパッケージング道場」に行ってきました - log++
  19. パッケージングについて
  20. 第6章 パッケージ化のベストプラクティス
  21. PackagingGuide/Recipes/PackageUpdate - Ubuntu Wiki
  22. PackagingGuide/Recipes - Ubuntu Wiki
  23. Index of /debian/pool/main/d/dh-make
  24. APT HOWTO (Obsolete Documentation) - ソースパッケージでの作業
  25. metapackage postinst|preinst|postrm|prerm equivs - Google 検索
  26. dpkg - How to create a meta-package that automatically installs other packages? - Ask Ubuntu
  27. Debian User Forums • View topic - HOWTO: Create a Debian metapackage
  28. Howto: create "configuration packages" with equivs - Ubuntu Forums
  29. inamerrata » Blog Archive » Managing Debian Installs
  30. 依存関係のみを列挙したdebを作る - I sort my thought...
  31. Debian デベロッパーズリファレンス - Debian 開発者用ツールの概観
  32. Lintian Tag: helper-templates-in-copyright
  33. Debian policy
  34. Debian JP Project - Debian ポリシーマニュアル - コントロールファイル (Control) とそのフィールド
  35. Develop/Packaging/Versioning - Ubuntu Japanese Wiki
  36. 第6章 パッケージのビルド
  37. dh_installdeb(1)
  38. 第5章 debianディレクトリーにあるその他のファイル

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2010-07-02T07:04:52+09:00
  2. Modified: 2010-07-02T07:04:52+09:00
  3. Generated: 2017-04-29T23:09:20+09:00