読者です 読者をやめる 読者になる 読者になる

Tinderbox環境構築

FreeBSD

Tinderbox User Guide を参考に作業を実施する。

Tinderbox用のjail作成

ezjail-adminを使用して作った。

$ sudo ezjail-admin create -f basic tinderbox.dip.jp 192.168.11.5

以下の作業は、このjail内で行った。

Perl5.8のインストール

jail$ cd /usr/ports/lang/perl5.8
jail$ sudo make install clean

MySQL5.5のインストール

jail$ cd /usr/ports/databases/mysql55-server
jail$ sudo make install clean

MySQL設定ファイルの配置と起動

jail$ sudo cp /usr/local/share/mysql/my-medium.cnf /usr/local/etc/my.cnf
jail$ sudo /usr/local/etc/rc.d/mysql-server forcestart

DBD::mysqlのインストール

jail$ cd /usr/ports/databases/p5-DBD-mysql55
jail$ sudo make install clean

まだ途中。webインタフェース入れないつもりなので、PHP関連のインストールは飛ばす。
404 Not Foundから再開する予定。

2011/03/03 再開。

Tinderboxyを展開

ダウンロードしたtinderboxを展開する。

jail$ sudo mkdir -p /tinderbox/scripts
jail$ sudo tar zxf ~/tinderbox-3.3.tar.gz -C /tinderbox/scripts/
jail$ sudo mv tinderbox-3.3/.* .
jail$ sudo mv tinderbox-3.3/* .
jail$ sudo rmdir tinderbox-3.3

tcコマンドを実行

jail$ cd /tinderbox/scripts/

以下のtcスクリプトを実行すると、何やら対話型のインストールが始まった
jail$ sudo ./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 /tinderbox/scripts/README or on the
web at http://tinderbox.marcuscom.com/ to complete your setup.

Hit <ENTER> to get started:
INFO: Checking prerequisites ...
WARN: The following option dependencies are missing.  These are required to
use the Tinderbox web front-ends.
WARN:   lang/php[45] databases/pear-MDB2 www/php[45]-session
DONE.

INFO: Creating default configuration files ...
DONE.

INFO: Beginning database configuration.
Enter database driver (mysql pgsql): mysql
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)
Do you want to cache root's password, and pass it to subsequent database command calls (note: this presents a security risk) (y/N) ?y
Enter root's password : 
Confirm password for root : 
INFO: Checking for prerequisites for mysql database driver ...
ERROR: The following mandatory dependencies are missing.  These must be
installed prior to creating the Tinderbox database.
ERROR:      databases/p5-DBD-mysql[456][01] databases/mysql[456][01]-client
ERROR: Error creating the new database!  Consult the output above for more
information.

MySQLドライバとクライアントの依存チェックで失敗した。。。
databases/p5-DBD-mysql55 databases/mysql55-clientをインストールしたが、databases/p5-DBD-mysql[456][01] databases/mysql[456][01]-clientでなければならない模様…。

間違ってインストールしてしまったportsをアンインストール

p5-DBD-mysql55のアンインストール
jail$ cd /usr/ports/databases/p5-DBD-mysql55/
jail$ sudo make deinstall
===>  Deinstalling for databases/p5-DBD-mysql55
===>   Deinstalling p5-DBD-mysql55-4.017

MySQL5.5のアンインストール
jail$ cd /usr/ports/databases/mysql55-server
jail$ sudo make deinstall
===>  Deinstalling for databases/mysql55-server
===>   Deinstalling mysql-server-5.5.8

mysql55-clientのアンインストール
jail$ cd /usr/ports/databases/mysql55-client
jail$ sudo make deinstall
===>  Deinstalling for databases/mysql55-client
===>   Deinstalling mysql-client-5.5.8

databases/mysql50-serverのインストール

jail$ cd /basejail/usr/ports/databases/mysql50-server
jail$ sudo make install clean

疲れた。風呂入る。。
続きはDBD::mysqlMySQLクライアントのインストールから。

databases/p5-DBD-mysql50のインストール

jail$ cd /usr/ports/databases/p5-DBD-mysql50
jail$ sudo make install clean

databases/mysql50-clientのインストール

databases/mysql50-serverのインストール時に一緒に入るぽい。

tcコマンドを実行 (2回目)

jail$ cd /tinderbox/scripts/

jail$ sudo ./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 /tinderbox/scripts/README or on the
web at http://tinderbox.marcuscom.com/ to complete your setup.
Hit <ENTER> to get started:
INFO: Checking prerequisites ...
WARN: The following option dependencies are missing.  These are required to
use the Tinderbox web front-ends.
WARN:   lang/php[45] databases/pear-MDB2 www/php[45]-session
DONE.

INFO: Creating default configuration files ...
DONE.

INFO: Beginning database configuration.
Enter database driver (mysql pgsql): mysql
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) ?y
Enter root's password :
Confirm password for root :
INFO: Checking for prerequisites for mysql database driver ...
WARN: The following option dependencies are missing.  These are required to
use the Tinderbox web front-end.
WARN:      databases/php5-mysql
DONE.

Enter the desired username for the Tinderbox database : tinderboxuser
Enter the desired password for tinderboxuser :
Confirm password for tinderboxuser :
Are these the settings you want:
    Database username      : tinderboxuser
    Database user password : ****
(y/N) y
INFO: Checking to see if database tinderbox already exists on localhost ...
INFO: Database tinderbox does not exist.  Creating tinderbox on localhost ...
INFO: Creating user tinderboxuser on host localhost (if required) ...
DONE.

INFO: Loading Tinderbox schema into tinderbox ...
INFO: Adding permissions to tinderbox for tinderboxuser ...
DONE.

INFO: Database configuration complete.

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

今度は無事にインストールされた模様。
まだ途中。つづきはまたこんどやる。

tinderbox.ph の編集

適当。

jail$ cd /tinderbox/scripts
jail$ sudo vi tinderbox.ph
#$TINDERBOX_HOST         = 'http://tinderbox.example.com';
$TINDERBOX_HOST  = 'http://tinderbox.dip.jp';

tc init の実行

jail$ cd /tinderbox/scripts
jail$ sudo ./tc init
Enter a default cvsup host [cvsup18.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 /tinderbox/scripts/etc/env/GLOBAL.

ftp/lftp のインストール

jail$ cd /usr/ports/ftp/lftp
jail$ sudo make install clean

jailの作成

Tinderboxにおけるjailは特定バージョンのFreeBSDに過ぎない。
ここでは jail として 7.3-RELEASE を指定した。

jail$ cd /tinderbox/scripts
jail$ sudo ./tc createJail -j 7.3 -d "FreeBSD 7.3-RELEASE" -t 7.3-RELEASE -u LFTP -H ftp.freebsd.org
7.3: initializing tree
7.3: creating top-level directory
7.3: adding to datastore... done.
7.3: initializing new jail...
7.3: updating jail with LFTP
7.3: cleaning out /tinderbox/jails/7.3/obj
7.3: cleaning out /tinderbox/jails/7.3/tmp
7.3: creating tarball
7.3: cleaning out /tinderbox/jails/7.3/tmp
7.3: cleaning out /tinderbox/jails/7.3/obj
Cleaning up after Jail creation.  Please be patient.

結構時間が掛かるので、気長に待つ。

PortsTree の作成

jail$ cd /tinderbox/scripts
jail$ sudo ./tc createPortsTree -p FreeBSD -d "FreeBSD ports tree" -w http://www.freebsd.org/cgi/cvsweb.cgi/ports/
FreeBSD: initializing tree
FreeBSD: creating top-level directory
FreeBSD: adding to datastore... done.
FreeBSD: updating portstree with CSUP

Buildの作成

Buildはjailとportのマッピングのこと。

jail$ cd /tinderbox/scripts
jail$ sudo ./tc createBuild -b 7.3-FreeBSD -j 7.3 -p FreeBSD -d "7.3-RELEASE with FreeBSD ports tree"
Password:
7.3-FreeBSD: cleaning out /tinderbox/7.3-FreeBSD
7.3-FreeBSD: cleaning out /tinderbox/builds/7.3-FreeBSD
7.3-FreeBSD: adding Build to datastore... done.

ログの設定

jail$ cd /tinderbox/scripts
jail$ sudo ./tc configLog -d /tinderbox/logs

DBにportを登録

jail$ cd /tinderbox/scripts
jail$ sudo ./tc addPort -b 7.3-FreeBSD -d shells/bash

試しに shells/bash のパッケージを作成してみる

jail$ cd /tinderbox/scripts
jail$ sudo ./tc tinderbuild -nullfs -b 7.3-FreeBSD shells/bash
Password:
tinderbuild: creating makefile...
tinderbuild: Creating build directory for 7.3-FreeBSD
7.3-FreeBSD: cleaning out /tinderbox/7.3-FreeBSD
makeBuild: extracting jail tarball
tinderbuild: Finalizing chroot environment
mount_nullfs: Operation not permitted
tinderbuild: cannot mount ports source
tinderbuild: Cleaning up after tinderbuild.  Please be patient.

失敗した。。「mount_nullfs: Operation not permitted」とか言われてる。
「/tinderbox/scripts/lib/tinderlib.sh」で「mount -t nullfs -o ro /tinderbox/portstrees/FreeBSD/ports /tinderbox/7.3-FreeBSD/a/ports」というコマンドが失敗している模様。


調べてみたら、そもそもjail内でマウント/アンマントはできないらしい。。。
15.5. Fine Tuning and Administration
"The root user is not allowed to mount or unmount file systems from within a jail(8)."と書いてある…。

より詳しい情報は「man 8 jail」を見ると分かる。

2011/05/04 追記

jail内でのmount - 英語とプログラミング気まぐれ日記の内容を実施して、カーネルの再構築 - 英語とプログラミング気まぐれ日記したらjail内でもmount_nullfsできるようになったので続きを書く。

$ cd /tinderbox/scripts/

$ sudo ./tc tinderbuild -nullfs -b 7.3-FreeBSD shells/bash
tinderbuild: creating makefile...
tinderbuild: Creating build directory for 7.3-FreeBSD
7.3-FreeBSD: cleaning out /tinderbox/7.3-FreeBSD
makeBuild: extracting jail tarball
tinderbuild: Finalizing chroot environment
mount -t nullfs -o ro /tinderbox/portstrees/FreeBSD/ports /tinderbox/7.3-FreeBSD/a/ports
mount -t nullfs -o ro /tinderbox/jails/7.3/src /tinderbox/7.3-FreeBSD/usr/src
================================================
building packages (phase 0)
================================================
started at Wed May  4 00:59:10 JST 2011
ended at Wed May  4 01:02:20 JST 2011
phase 0 took 00:03:10
0 packages built
4.0K  of packages
================================================
building packages (phase 1)
================================================
started at Wed May  4 01:02:20 JST 2011
ended at Wed May  4 01:05:12 JST 2011
phase 1 took 00:02:52
0 packages built
4.0K  of packages
tinderbuild: Cleaning up after tinderbuild.  Please be patient.
fstat: /dev/mem: No such file or directory
fstat: /dev/mem: No such file or directory

成功したのか??
ん、マニュアルを見直したら、jailを使った場合の注意点が書いてあったORZ
404 Not Found
jail内ではmount_nullfsができないので、jail内でtinderboxを構築したい場合はchrootしろと書いてある。。。
そもそもが間違えていたぽい。。。mount_nullfsとか無理矢理許可しなくてよかった…。
もう一度この手順に従ってリベンジしてみる。
今日は疲れたから寝る。
なんかできた…。正直なんでできたのか理解してない。。

$ sudo ./tc tinderbuild -nullfs -b 7.3-FreeBSD shells/bash
tinderbuild: creating makefile...
tinderbuild: Creating build directory for 7.3-FreeBSD
7.3-FreeBSD: cleaning out /tinderbox/7.3-FreeBSD
makeBuild: extracting jail tarball
tinderbuild: Finalizing chroot environment
mount -t nullfs -o ro /tinderbox/portstrees/FreeBSD/ports /tinderbox/7.3-FreeBSD/a/ports
mount -t nullfs -o ro /tinderbox/jails/7.3/src /tinderbox/7.3-FreeBSD/usr/src
================================================
building packages (phase 0)
================================================
started at Wed May  4 02:42:37 JST 2011
ended at Wed May  4 02:45:33 JST 2011
phase 0 took 00:02:56
6 packages built
9.2M  of packages
================================================
building packages (phase 1)
================================================
started at Wed May  4 02:45:33 JST 2011
ended at Wed May  4 02:45:33 JST 2011
phase 1 took 00:00:00
6 packages built
9.2M  of packages
tinderbuild: Cleaning up after tinderbuild.  Please be patient.
fstat: /dev/mem: No such file or directory
fstat: /dev/mem: No such file or directory


$ ls ../packages/7.3-FreeBSD/shells/bash-4.1.9.tbz 
../packages/7.3-FreeBSD/shells/bash-4.1.9.tbz

こんどこそ寝るzzZ