2013-04-30 14:43:39 -04:00
#!/bin/bash
2013-04-16 23:57:16 -04:00
2013-04-30 14:43:39 -04:00
set -e
set -u
2013-04-16 23:57:16 -04:00
function usage( ) {
2013-04-30 14:43:39 -04:00
echo "make mysql with the tokudb storage engine from github repo's"
2013-04-24 10:55:16 -04:00
echo " --git_tag= $git_tag "
2013-04-20 09:16:16 -04:00
echo " --mysqlbuild= $mysqlbuild "
2013-04-30 14:43:39 -04:00
echo " --mysql= $mysql "
2013-04-24 10:55:16 -04:00
echo " --tokudb_version= $tokudb_version "
2013-05-06 17:27:13 -04:00
echo " --mysql_tree= $mysql_tree --ftengine_tree= $ftengine_tree --ftindex_tree= $ftindex_tree --jemalloc_tree= $jemalloc_tree --backup_tree= $backup_tree "
2013-04-24 21:38:59 -04:00
echo
echo "community release builds using the tokudb-7.0.1 git tag"
2013-04-24 10:55:16 -04:00
echo " make.mysql.bash --mysqlbuild=mysql-5.5.30-tokudb-7.0.1-linux-x86_64"
echo " make.mysql.bash --mysqlbuild=mariadb-5.5.30-tokudb-7.0.1-linux-x86_64"
echo " make.mysql.bash --git_tag=tokudb-7.0.1 --mysql=mysql-5.5.30"
2013-04-24 21:38:59 -04:00
echo
echo "community debug builds using the tokudb-7.0.1 git tag"
echo " make.mysql.bash --mysqlbuild=mysql-5.5.30-tokudb-7.0.1-debug-linux-x86_64"
echo
echo "enterprise release builds at the HEAD of the repos"
echo " make.mysql.bash --mysqlbuild=mysql-5.5.30-tokudb-test-e-linux-x86_64"
echo
echo "community release builds of a branch"
echo " make.mysql.bash --mysql=mysql-5.5.30 --mysql_tree=<your mysql tree name> --ftengine_tree=<your ft-engine tree name> --tokudb_version=<your test string>>"
2013-04-16 23:57:16 -04:00
return 1
}
2013-04-30 14:43:39 -04:00
pushd $( dirname $0 )
source ./common.sh
popd
2013-04-26 13:58:28 -04:00
2013-04-16 23:57:16 -04:00
PATH = $HOME /bin:$PATH
2013-04-20 09:16:16 -04:00
system = $( uname -s | tr '[:upper:]' '[:lower:]' )
arch = $( uname -m | tr '[:upper:]' '[:lower:]' )
makejobs = $( get_ncpus)
2013-04-19 14:47:02 -04:00
git_tag = HEAD
2013-04-20 09:16:16 -04:00
mysqlbuild =
2013-04-30 14:43:39 -04:00
mysql =
2013-04-16 23:57:16 -04:00
cc = gcc47
cxx = g++47
2013-04-17 11:44:54 -04:00
build_debug = 0
build_type = community
build_tgz = 1
build_rpm = 0
2013-04-24 10:55:16 -04:00
tokudb_version =
2013-04-20 09:16:16 -04:00
tokudb_patches = 1
cmake_build_type = RelWithDebInfo
2013-04-24 10:55:16 -04:00
mysql_tree =
ftengine_tree =
ftindex_tree =
2013-04-24 21:38:59 -04:00
jemalloc_version = 3.3.0
2013-04-24 10:55:16 -04:00
jemalloc_tree =
backup_tree =
2013-04-16 23:57:16 -04:00
2013-04-30 14:43:39 -04:00
# parse arguments
2013-04-16 23:57:16 -04:00
while [ $# -gt 0 ] ; do
arg = $1 ; shift
2013-04-24 21:38:59 -04:00
if [ [ $arg = ~ --( .*) = ( .*) ] ] ; then
k = ${ BASH_REMATCH [1] } ; v = ${ BASH_REMATCH [2] }
eval $k = $v
2013-04-26 13:58:28 -04:00
if [ $k = mysqlbuild ] ; then
2013-04-24 21:38:59 -04:00
parse_mysqlbuild $mysqlbuild
if [ $? != 0 ] ; then exit 1; fi
2013-04-26 13:58:28 -04:00
elif [ $k = mysql ] ; then
2013-04-24 21:38:59 -04:00
parse_mysql $mysql
if [ $? != 0 ] ; then exit 1; fi
2013-04-26 13:58:28 -04:00
fi
2013-04-16 23:57:16 -04:00
else
usage; exit 1;
fi
done
2013-04-30 14:43:39 -04:00
# compute more version names etc.
2013-04-24 21:38:59 -04:00
if [ -z $mysqlbuild ] ; then
if [ -z $tokudb_version ] ; then
if [ $git_tag = HEAD ] ; then
tokudb_version = $( date +%s)
elif [ [ $git_tag = ~ tokudb-( .*) ] ] ; then
tokudb_version = ${ BASH_REMATCH [1] }
else
tokudb_version = $git_tag
git_tag = HEAD
fi
fi
if [ $build_debug != 0 ] ; then
if [ $cmake_build_type = RelWithDebInfo ] ; then cmake_build_type = Debug; fi
tokudb_version = $tokudb_version -debug
fi
if [ $build_type = enterprise ] ; then
tokudb_version = $tokudb_version -e
2013-04-20 09:16:16 -04:00
fi
2013-04-16 23:57:16 -04:00
fi
2013-04-30 14:43:39 -04:00
# download all the mysql source
if [ ! -d $mysql_distro ] ; then
github_download Tokutek/$mysql_distro $( git_tree $git_tag $mysql_tree ) $mysql_distro
fi
2013-04-16 23:57:16 -04:00
2013-04-30 14:43:39 -04:00
cd $mysql_distro
2013-04-16 23:57:16 -04:00
2013-04-30 14:43:39 -04:00
# install the backup source
if [ ! -d toku_backup ] ; then
github_download Tokutek/backup-$build_type $( git_tree $git_tag $backup_tree ) backup-$build_type
cp -r backup-$build_type /backup toku_backup
fi
2013-04-16 23:57:16 -04:00
2013-04-30 14:43:39 -04:00
if [ ! -d ft-engine ] ; then
github_download Tokutek/ft-engine $( git_tree $git_tag $ftengine_tree ) ft-engine
2013-04-16 23:57:16 -04:00
2013-04-30 14:43:39 -04:00
# install the tokudb storage engine source
cp -r ft-engine/storage/tokudb storage/
2013-04-16 23:57:16 -04:00
2013-04-30 14:43:39 -04:00
# merge the mysql tests
mv mysql-test mysql-test-save
cp -r ft-engine/mysql-test .
cp -r mysql-test-save/* mysql-test
rm -rf mysql-test-save
# install the tokudb scripts
cp -r ft-engine/scripts/* scripts/
2013-04-16 23:57:16 -04:00
fi
2013-04-30 14:43:39 -04:00
if [ ! -d storage/tokudb/ft-index ] ; then
github_download Tokutek/ft-index $( git_tree $git_tag $ftindex_tree ) storage/tokudb/ft-index
fi
if [ ! -d storage/tokudb/ft-index/third_party/jemalloc ] ; then
github_download Tokutek/jemalloc $( git_tree $git_tag $jemalloc_tree ) storage/tokudb/ft-index/third_party/jemalloc
fi
# append tokudb-specific version
if [ $( fgrep tokudb VERSION | wc -l) = 0 ] ; then
# append the tokudb version to the MYSQL_VERSION_EXTRA variable in the VERSION file
sed --in-place= "" -e " s/^MYSQL_VERSION_EXTRA=.*/&-tokudb- ${ tokudb_version } / " VERSION
fi
# prints a cmake command to eval
function generate_cmake_cmd ( ) {
2013-05-22 15:17:34 -04:00
local ls_remote # dont combine this with the following line
ls_remote = $( git ls-remote https://github.com/Tokutek/ft-index.git $git_tag )
if [ $? != 0 ] ; then
echo 1>& 2 " git ls-remote https://github.com/Tokutek/ft-index.git $git_tag failed $? "
test 0 = 1; return
fi
local ft_revision = 0x$( echo $ls_remote | cut -c-7)
2013-04-30 14:43:39 -04:00
echo -n CC = $cc CXX = $cxx cmake \
-D BUILD_CONFIG = mysql_release \
-D CMAKE_BUILD_TYPE = $cmake_build_type \
-D CMAKE_TOKUDB_REVISION = $ft_revision \
-D BUILD_TESTING = OFF \
-D USE_GTAGS = OFF \
-D USE_CTAGS = OFF \
-D USE_ETAGS = OFF \
-D USE_CSCOPE = OFF
if [ $build_debug = 1 ] ; then
echo -n " " \
-D USE_VALGRIND = ON \
-D TOKU_DEBUG_PARANOID = ON
else
echo -n " " \
-D USE_VALGRIND = OFF \
-D TOKU_DEBUG_PARANOID = OFF
fi
if [ [ $mysql_distro = ~ ^Percona ] ] ; then
echo -n " " \
-D WITH_EMBEDDED_SERVER = OFF
fi
2013-04-16 23:57:16 -04:00
2013-04-30 14:43:39 -04:00
if [ $system = darwin ] ; then
echo -n " " \
-D WITH_SAFEMALLOC = OFF \
-D WITH_SSL = system
fi
if [ $build_type = enterprise ] ; then
echo -n " " \
-D COMPILATION_COMMENT = \" TokuDB Enterprise Server \( GPL\) \"
fi
2013-05-01 14:47:53 -04:00
}
2013-04-30 14:43:39 -04:00
2013-05-01 14:47:53 -04:00
function generate_cmake_cmd_rpm( ) {
if [ $system = linux -a $mysql_distro = mariadb ] ; then
2013-04-30 14:43:39 -04:00
linux_distro = linux
if [ -f /etc/issue ] ; then
if [ [ " $( head -1 /etc/issue) " = ~ "Red Hat Enterprise Linux Server release ([56])" ] ] ; then
linux_distro = rhel${ BASH_REMATCH [1] }
fi
if [ [ " $( head -1 /etc/issue) " = ~ "CentOS release ([56])" ] ] ; then
linux_distro = centos${ BASH_REMATCH [1] }
fi
fi
echo -n " " -D RPM = $linux_distro
2013-05-01 14:47:53 -04:00
elif [ $system = linux -a $mysql_distro != mariadb ] ; then
echo 1>& 2 "I don't know how to build rpms for mysql yet."
2013-05-22 15:17:34 -04:00
test 0 = 1; return
2013-04-30 14:43:39 -04:00
fi
}
2013-05-02 09:30:24 -04:00
package_source_done = 0
2013-05-01 14:47:53 -04:00
if [ $build_tgz != 0 ] ; then
mkdir -p build.$cmake_build_type
pushd build.$cmake_build_type
# actually build
2013-05-22 15:17:34 -04:00
cmd = $( generate_cmake_cmd)
if [ $? != 0 ] ; then exit 1; fi
eval $cmd ..
2013-05-02 09:30:24 -04:00
if [ $package_source_done = 0 ] ; then
make package_source
package_source_done = 1
fi
2013-05-01 14:47:53 -04:00
make package -j$makejobs
popd
fi
2013-05-01 16:55:01 -04:00
if [ $build_rpm != 0 ] ; then
2013-04-30 14:43:39 -04:00
2013-05-01 14:47:53 -04:00
mkdir -p build.rpm.$cmake_build_type
pushd build.rpm.$cmake_build_type
2013-04-30 14:43:39 -04:00
2013-05-01 14:47:53 -04:00
# actually build
2013-05-22 15:17:34 -04:00
cmd = $( generate_cmake_cmd; generate_cmake_cmd_rpm)
if [ $? != 0 ] ; then exit 1; fi
eval $cmd ..
2013-05-02 09:30:24 -04:00
if [ $package_source_done = 0 ] ; then
make package_source
package_source_done = 1
fi
2013-05-01 14:47:53 -04:00
make package -j$makejobs
popd
2013-04-30 14:43:39 -04:00
fi