2013-04-19 08:55:07 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2013-05-29 09:34:21 -07:00
|
|
|
set -e -u
|
2013-05-24 10:59:07 -04:00
|
|
|
|
2013-04-19 08:55:07 -04:00
|
|
|
function usage() {
|
2013-05-24 10:59:07 -04:00
|
|
|
echo "build a debug mysql in the current directory"
|
|
|
|
echo "with default parameters it builds a debug $mysql-$mysql_tree"
|
2013-04-19 11:20:31 -04:00
|
|
|
echo "--git_tag=$git_tag"
|
2013-05-24 10:59:07 -04:00
|
|
|
echo "--mysql=$mysql --mysql_tree=$mysql_tree"
|
2014-04-03 12:50:25 -04:00
|
|
|
echo "--tokudbengine=$tokudbengine --tokudbengine_tree=$tokudbengine_tree"
|
2013-05-24 10:59:07 -04:00
|
|
|
echo "--ftindex=$ftindex --ftindex_tree=$ftindex_tree"
|
|
|
|
echo "--jemalloc=$jemalloc --jemalloc_tree=$jemalloc_tree"
|
|
|
|
echo "--backup=$backup --backup_tree=$backup_tree"
|
|
|
|
echo "--cc=$cc --cxx=$cxx"
|
2013-05-29 09:34:21 -07:00
|
|
|
echo "--local_cache_dir=$local_cache_dir --local_cache_update=$local_cache_update"
|
2013-05-29 12:50:27 -07:00
|
|
|
echo "--cmake_valgrind=$cmake_valgrind --cmake_debug_paranoid=$cmake_debug_paranoid"
|
2013-04-19 11:20:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function github_clone() {
|
2013-12-11 14:42:57 -05:00
|
|
|
local repo=
|
|
|
|
if [ $# -gt 0 ] ; then repo=$1; shift; else test 0 = 1; return; fi
|
|
|
|
local tree=
|
|
|
|
if [ $# -gt 0 ] ; then tree=$1; shift; else test 0 = 1; return; fi
|
|
|
|
local destdir=
|
|
|
|
if [ $# -gt 0 ] ; then destdir=$1; shift; fi
|
2013-05-29 09:34:21 -07:00
|
|
|
if [[ -z "$local_cache_dir" ]] ; then
|
2013-12-11 14:42:57 -05:00
|
|
|
git clone git@github.com:Tokutek/$repo $destdir
|
|
|
|
if [ $? != 0 ] ; then test 0 = 1; return; fi
|
2013-05-29 09:34:21 -07:00
|
|
|
else
|
|
|
|
if (( "$local_cache_update" )) ; then
|
|
|
|
pushd $local_cache_dir/$repo.git
|
2013-07-18 14:18:17 -07:00
|
|
|
git fetch --all -f -p -v
|
|
|
|
git fetch --all -f -p -v -t
|
2013-05-29 09:34:21 -07:00
|
|
|
popd
|
|
|
|
fi
|
2013-12-11 14:42:57 -05:00
|
|
|
git clone --reference $local_cache_dir/$repo.git git@github.com:Tokutek/$repo $destdir
|
|
|
|
if [ $? != 0 ] ; then test 0 = 1; return; fi
|
2013-05-29 09:34:21 -07:00
|
|
|
fi
|
|
|
|
|
2013-12-11 14:42:57 -05:00
|
|
|
if [ -z "$destdir" ] ; then pushd $repo; else pushd $destdir; fi
|
|
|
|
if [ -z "$git_tag" ] ; then
|
2013-07-10 15:30:23 -07:00
|
|
|
if ! git branch | grep "\<$tree\>" > /dev/null && git branch -a | grep "remotes/origin/$tree\>" > /dev/null; then
|
|
|
|
git checkout --track origin/$tree
|
|
|
|
else
|
|
|
|
git checkout $tree
|
|
|
|
fi
|
2013-04-19 11:20:31 -04:00
|
|
|
else
|
2013-05-24 10:59:07 -04:00
|
|
|
git checkout $git_tag
|
2013-04-19 11:20:31 -04:00
|
|
|
fi
|
2013-12-11 14:42:57 -05:00
|
|
|
if [ $? != 0 ] ; then test 0 = 1; return; fi
|
2013-05-24 10:59:07 -04:00
|
|
|
popd
|
2013-04-19 08:55:07 -04:00
|
|
|
}
|
|
|
|
|
2013-06-05 14:22:45 -04:00
|
|
|
# shopt -s compat31 2>/dev/null
|
2013-04-19 08:55:07 -04:00
|
|
|
|
2013-04-19 11:20:31 -04:00
|
|
|
git_tag=
|
2014-04-03 12:50:25 -04:00
|
|
|
mysql=mysql-5.5
|
2014-01-23 12:59:54 -05:00
|
|
|
mysql_tree=mysql-5.5.35
|
2013-04-19 11:20:31 -04:00
|
|
|
jemalloc=jemalloc
|
2013-05-24 10:59:07 -04:00
|
|
|
jemalloc_tree=3.3.1
|
2014-04-03 12:50:25 -04:00
|
|
|
tokudbengine=tokudb-engine
|
|
|
|
tokudbengine_tree=master
|
2013-04-19 11:20:31 -04:00
|
|
|
ftindex=ft-index
|
2013-05-24 10:59:07 -04:00
|
|
|
ftindex_tree=master
|
2013-04-19 11:20:31 -04:00
|
|
|
backup=backup-community
|
2013-05-24 10:59:07 -04:00
|
|
|
backup_tree=master
|
2014-02-07 10:32:50 -05:00
|
|
|
cc=gcc
|
|
|
|
cxx=g++
|
2013-05-29 09:34:21 -07:00
|
|
|
local_cache_dir=
|
|
|
|
local_cache_update=1
|
2013-05-29 12:50:27 -07:00
|
|
|
cmake_valgrind=
|
|
|
|
cmake_debug_paranoid=
|
2013-04-19 11:20:31 -04:00
|
|
|
|
2013-04-19 08:55:07 -04:00
|
|
|
while [ $# -ne 0 ] ; do
|
|
|
|
arg=$1; shift
|
2014-04-03 12:50:25 -04:00
|
|
|
if [[ $arg =~ ^--(.*)=(.*) ]] ; then
|
2013-04-19 08:55:07 -04:00
|
|
|
eval ${BASH_REMATCH[1]}=${BASH_REMATCH[2]};
|
|
|
|
else
|
|
|
|
usage; exit 1;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2014-04-03 12:50:25 -04:00
|
|
|
if [[ $mysql =~ ^(.*)-(([0-9]+\.[0-9]+)\.[0-9]+.*)$ ]] ; then
|
|
|
|
mysql=${BASH_REMATCH[1]}-${BASH_REMATCH[3]}
|
|
|
|
mysql_tree=${BASH_REMATCH[1]}-${BASH_REMATCH[2]}
|
|
|
|
fi
|
|
|
|
|
2013-05-24 10:59:07 -04:00
|
|
|
# setup environment variables
|
2013-12-03 13:22:25 -05:00
|
|
|
build_dir=$PWD/build
|
|
|
|
mkdir $build_dir
|
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
install_dir=$PWD/install
|
2013-05-24 10:59:07 -04:00
|
|
|
mkdir $install_dir
|
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
2013-04-19 08:55:07 -04:00
|
|
|
|
2013-05-24 10:59:07 -04:00
|
|
|
# checkout the fractal tree
|
|
|
|
github_clone $ftindex $ftindex_tree
|
2013-12-03 13:22:25 -05:00
|
|
|
|
|
|
|
# checkout jemalloc
|
2013-05-24 10:59:07 -04:00
|
|
|
github_clone $jemalloc $jemalloc_tree
|
2013-04-19 08:55:07 -04:00
|
|
|
|
2013-12-03 13:22:25 -05:00
|
|
|
# checkout mysql
|
2013-12-11 14:42:57 -05:00
|
|
|
github_clone $mysql $mysql_tree $mysql_tree
|
2013-04-19 08:55:07 -04:00
|
|
|
|
2013-05-24 10:59:07 -04:00
|
|
|
# checkout the community backup
|
|
|
|
github_clone $backup $backup_tree
|
2013-04-19 08:55:07 -04:00
|
|
|
|
2013-05-24 10:59:07 -04:00
|
|
|
# checkout the tokudb handlerton
|
2014-04-03 12:50:25 -04:00
|
|
|
github_clone $tokudbengine $tokudbengine_tree
|
2013-04-19 08:55:07 -04:00
|
|
|
|
2013-05-24 10:59:07 -04:00
|
|
|
# setup links'
|
2014-04-03 12:50:25 -04:00
|
|
|
pushd $tokudbengine/storage/tokudb
|
2013-05-24 10:59:07 -04:00
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
ln -s ../../../$ftindex ft-index
|
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
popd
|
2013-12-11 14:42:57 -05:00
|
|
|
pushd $mysql_tree/storage
|
2013-05-24 10:59:07 -04:00
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
2014-04-03 12:50:25 -04:00
|
|
|
ln -s ../../$tokudbengine/storage/tokudb tokudb
|
2013-05-24 10:59:07 -04:00
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
popd
|
2013-12-11 14:42:57 -05:00
|
|
|
pushd $mysql_tree
|
2013-05-24 10:59:07 -04:00
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
ln -s ../$backup/backup toku_backup
|
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
popd
|
2013-12-11 14:42:57 -05:00
|
|
|
pushd $mysql_tree/scripts
|
2013-05-24 10:59:07 -04:00
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
2014-04-03 12:50:25 -04:00
|
|
|
ln ../../$tokudbengine/scripts/tokustat.py
|
2013-05-24 10:59:07 -04:00
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
2014-04-03 12:50:25 -04:00
|
|
|
ln ../../$tokudbengine/scripts/tokufilecheck.py
|
2013-05-24 10:59:07 -04:00
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
popd
|
2013-12-19 12:22:24 -05:00
|
|
|
if [[ $mysql =~ mariadb ]] || [[ $mysql_tree =~ mariadb ]] ; then
|
2013-12-11 14:42:57 -05:00
|
|
|
pushd $mysql_tree/extra
|
2013-12-03 13:22:25 -05:00
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
ln -s ../../$jemalloc $jemalloc
|
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
popd
|
|
|
|
else
|
|
|
|
pushd $ftindex/third_party
|
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
ln -s ../../$jemalloc $jemalloc
|
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
popd
|
|
|
|
fi
|
2013-04-19 08:55:07 -04:00
|
|
|
|
2013-12-03 13:22:25 -05:00
|
|
|
pushd $build_dir
|
2013-05-24 10:59:07 -04:00
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
2013-06-21 12:03:02 -07:00
|
|
|
extra_cmake_options="-DCMAKE_LINK_DEPENDS_NO_SHARED=ON"
|
2013-05-29 12:50:27 -07:00
|
|
|
if (( $cmake_valgrind )) ; then
|
|
|
|
extra_cmake_options+=" -DUSE_VALGRIND=ON"
|
|
|
|
fi
|
|
|
|
if (( $cmake_debug_paranoid )) ; then
|
|
|
|
extra_cmake_options+=" -DTOKU_DEBUG_PARANOID=ON"
|
|
|
|
fi
|
2013-12-11 14:42:57 -05:00
|
|
|
CC=$cc CXX=$cxx cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$install_dir -DBUILD_TESTING=OFF $extra_cmake_options ../$mysql_tree
|
2013-05-24 10:59:07 -04:00
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
make -j4 install
|
|
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
popd
|
2013-04-19 08:55:07 -04:00
|
|
|
|
2013-05-24 10:59:07 -04:00
|
|
|
pushd $install_dir
|
|
|
|
scripts/mysql_install_db --defaults-file=$HOME/$(whoami).cnf
|
|
|
|
popd
|