FreeBSDのports/packagesビルドシステムtinderboxを使う

FreeBSD 7.2-RELEASEがリリースされたので、手元の実験用FreeBSD Boxを新しくした。ついでにtinderboxも3.2を最初からセットアップした。
tinderboxは、FreeBSDports/packagesのビルドシステム。いろんなuserland、いろんなports treeを組み合わせてビルド環境を作り、packagesの作成ができる。使ってるのはchrootだからできないこともあるけど、制限を理解して使えばかなり便利。

tinderbox のインストール

tinderboxは、各種情報をRDBMSに記録する。RDBMSとしては、MySQLまたはPostgreSQLが使用できる。あらかじめどちらかに決めて、インストールしておくこと。
src/ports treeの取得にはcsup/cvsupを使用する。base systemに含まれてるcsupが準備なしで使えてお手軽でいい感じ。
あとは、いわゆるweb interfaceを使うなら、php4かphp5が必要。
全部まとめてportsが面倒を見てくれるから、今回はportsからインストールした。ports-mgmt/tinderbox。オプションはMYSQL, CSUP, WEBUI, APACHE, CHECK_FOR_ROOTで、デフォルトのまま。

インストール後の設定

portsからインストールすると、/usr/local/tinderbox配下にインストールされる。まずは初期設定。/usr/local/tinderbox/scripts/tcをSetupつきで実行する。
DB の種類を聞かれるので、mysqlを指定。

# /usr/local/tinderbox/scripts/tc Setup
Welcome to the Tinderbox Setup script.  This script will guide you through
some of the automated Tinderbox setup steps.  Once this script completes ,
you should review the documentation in /usr/local/tinderbox/scripts/README
or on the web at http://tinderbox.marcuscom.com/ to complete your setup.

Hit <ENTER> to get started:
INFO: Checking prerequisites ...
DONE.

INFO: Creating default configuration files ...
DONE.

INFO: Beginning database configuration.
Enter database driver (mysql pgsql):mysql

あとはDBのrootユーザ名やらパスワードやら、tinderboxで使用するDB名やらユーザ名やらパスワードを聞かれる。順番に答えていこう。

Does this host have access to connect to the Tinderbox database as a database administrator? (y/N)y
Enter database admin user [root]:
Enter database host [localhost]:
Enter database name [tinderbox]:
Are these settings corrrect:
    Database Administrative User : root
    Database Host                : localhost
    Database Name                : tinderbox
(y/N)y
Do you want to cache root's password, and pass it to subsequent database command calls (note: this presents a security risk) (y/N) ?
以下略

Setupが完了したら、/usr/local/tinderbox/scripts/tinderbox.phを自分の環境に合わせて編集する。

# Configurable options
$TINDERBOX_HOST  = 'http://tinderbox.example.com';
$TINDERBOX_URI   = '/tb';
$SUBJECT         = 'Example Tinderbox:';
$SENDER          = 'tinderbox@example.com';
$SMTP_HOST       = 'mail.example.com';

# These should probably be left alone
$LOGS_URI        = $TINDERBOX_URI . '/logs';
$SHOWBUILD_URI   = $TINDERBOX_URI . '/index.php?action=list_buildports&build=';
$SHOWPORT_URI    = $TINDERBOX_URI . '/index.php?action=describe_port&id=';

1;

build環境の構築

tinderbox.ph が準備できたら、build環境を初期構築する。まずは初期化。CVSUPのデフォルトサーバを聞かれるので、適切なサーバを選んで入力する。

# /usr/local/tinderbox/scripts/tc init
Enter a default cvsup host [cvsup12.FreeBSD.org]: cvsup2.jp.freebsd.org
Enter a default update type or command [CSUP]:
Default update host and type have been set.  These can be changed later by
modifying /usr/local/tinderbox/scripts/etc/env/GLOBAL.

次はjailを作る。このjailはFreeBSDのjailじゃなくて、ある特定のFreeBSD userlandのこと。今回は7.2-RELEASEを準備した。

# /usr/local/tinderbox/scripts/tc createJail -j 7.2 -d "FreeBSD 7.2-RELEASE" -t RELENG_7_2_0_RELEASE

これで、source treeをcsupで取り寄せてbuildwolrd, installworldしてjailを作ってくれる。
jail ができたら、次はports treeを準備する。今回はHEADを用意した。

# /usr/local/tinderbox/scripts/tc createPortsTree -p FreeBSD -d "FreeBSD ports tree" -w http://www.freebsd.org/cgi/cvsweb.cgi/ports/

最後に、jailとportstreeを組み合わせて、buildと呼ばれる環境を作成する。

# /usr/local/tinderbox/scripts/tc createBuild -b 7.2-FreeBSD -j 7.2 -p FreeBSD -d "7.2-RELEASE with FreeBSD ports tree"

buildをいくつか作っておいて、それぞれでportsの検証やらpackagesの作成ができるというわけ。

tinderboxを使ってみる

んじゃ、早速tinderboxを使ってみる。まずは、buildにportsを追加する。追加は必須じゃないけど、追加しておけばbuildにかかった時間とか結果が記録されるので、追加しておくのが吉。

# /usr/local/tinderbox/scripts/tc addPort -b 7.2-FreeBSD -d lang/perl5.8

次に、実際にportsを作ってみる。

# /usr/local/tinderbox/scripts/tc tinderbuild -nullfs -b 7.2-FreeBSD lang/perl5.8

しばらくするとpackagesが完成する。logsにはログが格納されてるはず。

tinderboxのweb interfaceを使ってみる

tinderboxにはweb interfaceがあって、buildの進捗状況を確認したり、buildするportsを指定したりできる。
/usr/local/tinderbox/scripts/webuiがweb interface。まずはinc_tinderbox.php.distを元にしてinc_tinderbox.phpを設定する。tinderbox_name, tinderbox_title, template_dirを好みで変更すれば、他はそのままでも問題なし。

# page title
$tinderbox_name  = 'markun Tinderbox';
# used in page header
$tinderbox_title = 'markun Tinderbox';
中略
# Comment out the next line, and uncomment the line after it to enable
# the paefchen frontend template.
#$template_dir   = 'default';
$template_dir   = 'paefchen';
以下略

次に、inc_ds.php.distを元に、inc_ds.phpを設定する。DBのホスト名とパスワードを設定することになるので、セットアップの際に入力したパスワードを思い出して設定すること。
あとは、これをhttpで見せてやる。ついでに/usr/local/tinderbox配下のlogsとerrorsとpackagesもhttpで見られるように設定する。Apacheならこんな感じ。

Alias /tb/packages /usr/local/tinderbox/packages
Alias /tb/logs /usr/local/tinderbox/logs
Alias /tb/errors /usr/local/tinderbox/errors
Alias /tb /usr/local/tinderbox/scripts/webui
<Directory /usr/local/tinderbox/scripts/webui>
    DirectoryIndex index.php
    Allow from all
</Directory>
<Directory ~ /usr/local/tinderbox/(packages|logs|errors)>
    Options Indexes
    Allow from all
</Directory>