オレオレ Debian アーカイブの作成 (mini-dinstall 編)

最終ゴール

オレオレ apt リポジトリにオレオレ deb パッケージを置いて,特定少人数に対して配布する.

今回のお題

mini-dinstall コマンドと,dupload パッケージを用いてオレオレ apt アーカイブを作成する方法を紹介する.

準備

howto: uploading to people.d.o using dput を参考に作成する.以下を仮定する.

mini-dinstall をインストールする.

$ sudo aptitude install mini-dinstall

アーカイブ用の公開鍵暗号鍵の生成

$ ssh foo@www.example.com
$ gpg --gen-key
Please select what kind of key you want: DSA and Elgamal
What keysize do you want? (2048) 
Key is valid for? (0)
Real name: foo
Email address:
Comment: Debian Archive Key

パスフレーズは空にしておく.空にしていないと後で dupload でアップロードしたときにパスフレーズをリモートからでは入力できなくて失敗する.

この鍵の ID を取得しておく.

$ gpg -k
pub   1024D/6789ABCD 2010-04-07
uid                  foo (Debian Archive Key)

ここでは 6789ABCD が ID である.

アーカイブツリーの作成

Origin (アーカイブの作成者/管理者) が foo で Label (アーカイブの名称) が foo のアーカイブツリーを作成する.Origin, Label については http://www.isotton.com/software/debian/docs/repository-howto/repository-howto.html#release を参照.

$ cd /srv/www/example/debian
$ mkdir -p mini-dinstall/incoming
$ vi sign_release.sh
#!/bin/sh
rm -f Release.gpg
gpg -u 6789ABCD -bao Release.gpg "$1"
$ chmod 750 sign_release.sh

mini-dinstall の設定ファイルを作成する.

$ vi ~/.mini-dinstall.conf
[DEFAULT]
mail_to = foo
architectures = all, i386
archive_style = flat
archivedir = /srv/www/example/debian
generate_release = 1
release_origin = foo
release_label = foo
release_description = foo
release_signscript = /srv/www/example/debian/sign_release.sh

[unstable]
release_suite = unstable

アップロードの設定

手元のマシンでアップロードの設定を行う.

$ sudo aptitude install dupload
$ vi ~/.dupload.conf
package config;

$cfg{'foo'} = {
  fqdn => "www.example.com",
  method => "scpb",
  incoming => "/srv/www/example/debian/pool/main",
  # The dinstall on ftp-master sends emails itself
  dinstall_runs => 1,
};

$cfg{'foo'}{postupload}{'changes'} = "ssh foo@www.example.com mini-dinstall -b";

アップロード

*.changes ファイルがあるディレクトリで下のようにする.

$ dupload --to foo .

apt

インストールするマシンの apt を設定する.

$ sudo vi /etc/apt/sources.list
deb http://www.example.com/debian/ unstable/
deb-src http://www.example.com/debian/ unstable/

リポジトリの公開鍵をインストールするマシンの鍵束に加える.

$ ssh foo@www.example.com gpg --export -a 6789ABCD | sudo apt-key add -

これで通常の操作をすればよい.

$ sudo aptitude update

まとめ

見てきたように apt-ftparchive を使うより著しく簡単である.また,バージョンアップしたパッケージのアップロード時の問題も解決された.

ただ,apt-ftparchive を使う方法で可能だった component の利用ができないのが少し残念(sources.list の記述を deb http://www.example.com/debian/ unstable main のようにできないということ).

あと,debian ディレクトリの .htaccess を適切に設定してやる必要があるかも.