MySQL Tritonn パッチの作成方法 ( 暫定版 )

MySQL Tritonn パッチの作成が成功したのでメモしておきます。
この記事を書くにあたって、下記のサイト様を参考にさせて戴きました。
http://qwik.jp/tritonn/make_oldstyle_patch.html

追記
記事内容を編集していたらリンクがおかしくなってしまったので、この日のログを一旦削除しました。
スパムみたいなことして申し訳ないです。


まずは make するのに gmake と automake がいるのでインストール。

cd /usr/ports
make search name="gmake"
Port:   gmake-3.81_2
Path:   /usr/ports/devel/gmake
Info:   GNU version of 'make' utility
Maint:  ade@FreeBSD.org
B-deps: gettext-0.16.1_3 libiconv-1.11_1
R-deps: gettext-0.16.1_3 libiconv-1.11_1
WWW:    http://www.gnu.org/software/make/make.html
cd /usr/ports/devel/gmake
make install clean
rehash
cd /usr/ports
make search name="automake-1.9"
Port:   automake-1.9.6_2
Path:   /usr/ports/devel/automake19
Info:   GNU Standards-compliant Makefile generator (1.9)
Maint:  ade@FreeBSD.org
B-deps: autoconf-2.61_2 autoconf-wrapper-20071025 m4-1.4.9,1 perl-5.8.8_1
R-deps: autoconf-2.61_2 autoconf-wrapper-20071025 automake-wrapper-20071025 m4-1.4.9,1 perl-5.8.8_1
WWW:    http://www.gnu.org/software/automake/
cd /usr/ports/devel/automake19
make install clean
rehash

CC と CXX を gcc にする。

vi ~/.cshrc
setenv	CC	gcc
setenv	CXX	gcc

何はともあれ senna のインストール。

mkdir senna
cd senna
fetch http://jaist.dl.sourceforge.jp/senna/27317/senna-1.0.9.tar.gz
tar xvzf senna-1.0.9.tar.gz
cd senna-1.0.9
./configure --prefix=/usr --without-mecab
gmake && sudo gmake install
cd ../../

とりあえずパッチ作成に当たって、現在の Ports Collection の MySQL 最新 Ver. を調べなくちゃいけないんでサクッと grep

grep PORTVERSION /usr/ports/databases/mysql50-server/Makefile
PORTVERSION=	5.0.45

次に MySQL Tritonn 最新 Ver. を調べる。

Tritonn プロジェクト日本語トップページ - OSDN

一致していることを確認したら下記を見てパッチを作る。

http://qwik.jp/tritonn/make_oldstyle_patch.html

作業ディレクトリ作成

mkdir ~/tritonn
cd ~/tritonn

とりあえず fetch 。

fetch http://ftp.iij.ad.jp/pub/db/mysql/Downloads/MySQL-5.0/mysql-5.0.45.tar.gz
fetch http://jaist.dl.sourceforge.jp/tritonn/27837/mysql-5.0.45-tritonn-1.0.7.tar.gz

とりあえず tar 。

tar xvzf mysql-5.0.45.tar.gz
tar xvzf mysql-5.0.45-tritonn-1.0.7.tar.gz

とりあえず diff 。

diff -Nurdp mysql-5.0.45 mysql-5.0.45-tritonn-1.0.7 > mysql-5.0.45-tritonn-1.0.7-all.diff

とりあえず diffstat 。の前に portinstall 。

cd /usr/ports
make search name="diffstat"
Port:   diffstat-1.45
Path:   /usr/ports/textproc/diffstat
Info:   Makes a histogram summarizing "diff" output
Maint:  clsung@FreeBSD.org
B-deps:
R-deps:
WWW:    http://dickey.his.com/diffstat/diffstat.html
cd /usr/ports/textproc/diffstat
make install clean
rehash

やっとこ diffstat 。

cd ~/tritonn
cat mysql-5.0.45-tritonn-1.0.7-all.diff | diffstat -l > mysql-5.0.45-tritonn-1.0.7-filelist.txt

diff を取るファイルの絞込み

cat mysql-5.0.45-tritonn-1.0.7-filelist.txt | wc -l
     266
grep -v "Makefile.in" mysql-5.0.45-tritonn-1.0.7-filelist.txt > mysql-5.0.45-tritonn-1.0.7-filelist2.txt
cat mysql-5.0.45-tritonn-1.0.7-filelist2.txt | wc -l
     138
cp mysql-5.0.45-tritonn-1.0.7-filelist2.txt mysql-5.0.45-tritonn-1.0.7-filelist3.txt
vi mysql-5.0.45-tritonn-1.0.7-filelist3.txt

http://qwik.jp/tritonn/mysql_porting.html を参考にして filelist3.txt から以下のファイルを削除しました。
このリストは将来的に変わる可能性があります。

aclocal.m4
bdb*
config.guess
config.h.in
config.sub
configure
depcomp
install-sh
innobase/aclocal.m4
innobase/configure
libmysqld/sql_yacc.cc
ltmain.sh
missing
scripts/mysqlbug
sql/lex_hash.h
cat mysql-5.0.45-tritonn-1.0.7-filelist3.txt | wc -l
     113

最後にもう一回 diff を取る

vi xdiff
#!/bin/sh

while [ $# -gt 0 ]
do
	FILE=$1
	shift
	diff -Nudp mysql-5.0.45/$FILE mysql-5.0.45-tritonn-1.0.7/$FILE
done
chmod 711 xdiff
cat mysql-5.0.45-tritonn-1.0.7-filelist3.txt | xargs ./xdiff > mysql-5.0.45-tritonn-1.0.7-old-style.diff

パッチを当ててみる

cd mysql-5.0.45
patch -p1 < ../mysql-5.0.45-tritonn-1.0.7-old-style.diff |& tee ../patch.log

make してみる。

gmake clean
gmake: *** No rule to make target `clean'.  Stop.
libtoolize -c -f
Using `AC_PROG_RANLIB' is rendered obsolete by `AC_PROG_LIBTOOL'
You should update your `aclocal.m4' by running aclocal.
aclocal-1.9 && autoheader && automake-1.9 -c -a -i && autoconf

configure/make してみる。

./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --libexecdir=/usr/local/mysql/bin \
--enable-thread-safe-client --enable-local-infile --enable-assembler --with-pic --with-fast-mutexes \
--with-client-ldflags=-static --with-mysqld-ldflags=-static --with-zlib-dir=bundled --with-big-tables \
--with-yassl --with-readline --with-archive-storage-engine --with-blackhole-storage-engine --with-csv-storage-engine \
--with-example-storage-engine --with-federated-storage-engine --with-innodb --with-extra-charsets=complex \
--with-charsets=utf8 --with-mit-threads=no --with-named-thread-libs=-lthr --with-senna;
gmake
sudo scripts/make_binary_distribution --no-strip

回帰機能テストの実行。

tar xvzf mysql-5.0.45.tar.gz
cd mysql-5.0.45/mysql-test
./mysql-test-run.pl --force --udiff |& tee ../../test.log
grep " fail " ../../test.log
blackhole                      [ fail ]
ctype_latin1_de                [ fail ]
fulltext                       [ fail ]
fulltext2                      [ fail ]
fulltext_cache                 [ fail ]
fulltext_left_join             [ fail ]
fulltext_multi                 [ fail ]
fulltext_order_by              [ fail ]
im_daemon_life_cycle           [ disabled ]  Bug#20294: Instance manager tests fail randomly
im_options_set                 [ disabled ]  Bug#20294: Instance manager tests fail randomly
im_options_unset               [ disabled ]  Bug#20294: Instance manager tests fail randomly
im_utils                       [ disabled ]  Bug#20294: Instance manager tests fail randomly
query_cache                    [ fail ]
sp                             [ fail ]
grep "Lost connection" ../../test.log