tinderbox 4.0.0を使ってみる

FreeBSDportsをbuildするためのシステムであるtinderboxの最新版4.0.0がリリースされていたので、FreeBSD 9.1-RELEASEにインストールして使ってみた。

4.0.0になっていろいろと新機能が使えるようになっている。

  • SQLiteサポート
  • tinderbuildがjail(8)を使うようになった
  • WebuiがPDOを使うようになった
  • md(4)を使った多様なファイルシステムを使えるようになった
  • tinderbox 3.3からのアップグレードに対応した
  • ドキュメントが一新された

これ以外にも、細かいところでlftpを使ったjail構築でtxz方式の新しいリリースパッケージに対応してたり、src/portsの更新にsubversionが使えるようになっていたりと、最近のFreeBSDを使うなら絶対に更新すべき。
インストールはports-mgmt/tinderboxから、設定は以下の通り。せっかくなのでSQLiteを使うことにして、lsofはkernel sourceをインストールしていないのでoffにした。

  ┌────────────────────────── tinderbox-4.0.0 ─────────────────────────────┐
  │ ┌────────────────────────────────────────────────────────────────────┐ │
  │ │ [x] CHECK_ROOT    Check if ./tc is run by uid 0                    │ │
  │ │ [x] EMAILS        Support for build failure/completion emails      │ │
  │ │ [x] LOG_COMPRESS  Support bzip'ing the logs                        │ │
  │ │ [ ] LSOF          For killMountProcesses() when using nullfs       │ │
  │ │───────────────────────────────── DB ───────────────────────────────│ │
  │ │ [ ] PGSQL         PostgreSQL database support                      │ │
  │ │ [ ] MYSQL         MySQL database support                           │ │
  │ │ [x] SQLITE        SQLite database support                          │ │
  │ │──────────────────────────────── WEB ───────────────────────────────│ │
  │ │ (*) APACHE        Apache server support                            │ │
  │ │ ( ) HIAWATHA      Hiawatha server                                  │ │
  │ │ ( ) LIGHTTPD      Lighttpd server support                          │ │
  │ │ ( ) NGINX         Nginx server                                     │ │
  │ └────────────────────────────────────────────────────────────────────┘ │
  ├────────────────────────────────────────────────────────────────────────┤
  │                     <  OK  >           <Cancel>                        │
  └────────────────────────────────────────────────────────────────────────┘

インストールが終わったら、setupスクリプトを実行する。

# cd /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:

ここでEnterキーを押して

INFO: Checking prerequisites ...
DONE.

INFO: Creating default configuration files ...
DONE.

INFO: Beginning database configuration.
Enter database driver (mysql pgsql sqlite): sqlite
Enter database name (full or relative paths allowed) [tinderbox]:
Is this setting correct:
    Database name : tinderbox
(y/N)y

sqliteを選択してDB名を入力、yを入力したらあとは自動的にセットアップされる。

INFO: Checking for prerequisites for sqlite database driver ...
DONE.

INFO: Loading Tinderbox schema into /usr/local/tinderbox/scripts/tinderbox
...
DONE.

INFO: Database configuration complete.

Congratulations!  The scripted portion of Tinderbox has completed successfully.
You should now verify the settings in /usr/local/tinderbox/scripts/tinderbox.ph
are correct for your environment, then run "/usr/local/tinderbox/scripts/tc
init" to complete the setup.  Be sure to checkout
http://tinderbox.marcuscom.com/ for further instructions.

セットアップが終わったら、設定ファイルを編集する。tinderbox.phは$TINDERBOX_HOST, $TINDERBOX_URI, $SUBJECTあたりをお好みで変更する。

# 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;

webui/inc_ds.php.distを元にしてinc_ds.phpを作成する。SQLiteを使うので、DB_DRIVERとDB_PATHを設定すればOK。

<?php

$DB_DRIVER = 'sqlite';
$DB_PATH = '../tinderbox'; # sqlite only

?>

webui/inc_tinderbox.php.distを元にしてinc_tinderbox.phpを作成する。tinderbox_nameとtemplate_dirを好みで設定すれば、ほかはそのままで問題なし。template_dirはdefaultよりpaefchenが個人的な好み。
Apacheでwebuiにアクセスできるよう、Aliasを設定する。こんなファイルを/usr/local/etc/apache22/Includes/tinderbox.confとして作成する。

Alias /tb/logs/ "/usr/local/tinderbox/logs/"
Alias /tb/packages/ "/usr/local/tinderbox/packages/"
Alias /tb/errors/ "/usr/local/tinderbox/errors/"
Alias /tb/wrkdirs/ "/usr/local/tinderbox/wrkdirs/"
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|wrkdirs)>
    Options Indexes
    Allow from all
</Directory>

jailを作成する。ftpサーバはほかに近いミラーサーバがあれば、そっちを指定するとネットワークに優しい。

# ./tc createJail -j 9.1 -d "FreeBSD 9.1-RELEASE" -t 9.1-RELEASE -u LFTP -H ftp.jp.freebsd.org

portsを作成する。

# ./tc createPortsTree -p FreeBSD -d "FreeBSD ports tree" -u SVN -P http -H svn.freebsd.org -D ports/head -w http://svnweb.freebsd.org/ports/

buildを作成する。

# ./tc createBuild -b 9.1-FreeBSD -j 9.1 -p FreeBSD -d "9.1-RELEASE with FreeBSD ports tree"

バックグラウンドでbuildするために、/etc/rc.confでtinderdを使う設定をする。

tinderd_enable="YES"
tinderd_directory="/usr/local/tinderbox/scripts"
tinderd_flags="-nullfs"

あとはばりばりと使うだけ。

# ./tc addPort -b 9.1-FreeBSD -d lang/perl5.14
# ./tc addBuildPortsQueueEntry -b 9.1-FreeBSD -d lang/perl5.14