You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

244 lines
7.2 KiB

13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
  1. #!/bin/bash
  2. set -e
  3. set -u
  4. function usage() {
  5. echo "make mysql with the tokudb storage engine from github repo's"
  6. echo "--git_tag=$git_tag"
  7. echo "--mysqlbuild=$mysqlbuild"
  8. echo "--mysql=$mysql"
  9. echo "--tokudb_version=$tokudb_version"
  10. echo "--mysql_tree=$mysql_tree --tokudbengine_tree=$tokudbengine_tree --ftindex_tree=$ftindex_tree --jemalloc_tree=$jemalloc_tree --backup_tree=$backup_tree"
  11. echo
  12. echo "community release builds using the tokudb-7.0.1 git tag"
  13. echo " make.mysql.bash --mysqlbuild=mysql-5.5.30-tokudb-7.0.1-linux-x86_64"
  14. echo " make.mysql.bash --mysqlbuild=mariadb-5.5.30-tokudb-7.0.1-linux-x86_64"
  15. echo " make.mysql.bash --git_tag=tokudb-7.0.1 --mysql=mysql-5.5.30"
  16. echo
  17. echo "community debug builds using the tokudb-7.0.1 git tag"
  18. echo " make.mysql.bash --mysqlbuild=mysql-5.5.30-tokudb-7.0.1-debug-linux-x86_64"
  19. echo
  20. echo "enterprise release builds at the HEAD of the repos"
  21. echo " make.mysql.bash --mysqlbuild=mysql-5.5.30-tokudb-test-e-linux-x86_64"
  22. echo
  23. echo "community release builds of a branch"
  24. echo " make.mysql.bash --mysql=mysql-5.5.30 --mysql_tree=<your mysql tree name> --tokudbengine_tree=<your tokudb-engine tree name> --tokudb_version=<your test string>>"
  25. return 1
  26. }
  27. pushd $(dirname $0)
  28. source ./common.sh
  29. popd
  30. PATH=$HOME/bin:$PATH
  31. system=$(uname -s | tr '[:upper:]' '[:lower:]')
  32. arch=$(uname -m | tr '[:upper:]' '[:lower:]')
  33. makejobs=$(get_ncpus)
  34. git_tag=HEAD
  35. mysqlbuild=
  36. mysql=
  37. cc=gcc
  38. cxx=g++
  39. build_debug=0
  40. build_type=community
  41. build_tgz=1
  42. build_rpm=0
  43. tokudb_version=
  44. tokudb_patches=1
  45. cmake_build_type=RelWithDebInfo
  46. mysql_tree=
  47. tokudbengine_tree=
  48. ftindex_tree=
  49. jemalloc_version=3.3.0
  50. jemalloc_tree=
  51. backup_tree=
  52. # parse arguments
  53. while [ $# -gt 0 ] ; do
  54. arg=$1; shift
  55. if [[ $arg =~ --(.*)=(.*) ]] ; then
  56. k=${BASH_REMATCH[1]}; v=${BASH_REMATCH[2]}
  57. eval $k=$v
  58. if [ $k = mysqlbuild ] ; then
  59. parse_mysqlbuild $mysqlbuild
  60. if [ $? != 0 ] ; then exit 1; fi
  61. elif [ $k = mysql ] ; then
  62. parse_mysql $mysql
  63. if [ $? != 0 ] ; then exit 1; fi
  64. fi
  65. else
  66. usage; exit 1;
  67. fi
  68. done
  69. # compute more version names etc.
  70. if [ -z $mysqlbuild ] ; then
  71. if [ -z $tokudb_version ] ; then
  72. if [ $git_tag = HEAD ] ; then
  73. tokudb_version=$(date +%s)
  74. elif [[ $git_tag =~ tokudb-(.*) ]] ; then
  75. tokudb_version=${BASH_REMATCH[1]}
  76. else
  77. tokudb_version=$git_tag
  78. git_tag=HEAD
  79. fi
  80. fi
  81. if [ $build_debug != 0 ] ; then
  82. if [ $cmake_build_type = RelWithDebInfo ] ; then cmake_build_type=Debug; fi
  83. tokudb_version=$tokudb_version-debug
  84. fi
  85. if [ $build_type = enterprise ] ; then
  86. tokudb_version=$tokudb_version-e
  87. fi
  88. fi
  89. # download all the mysql source
  90. if [ ! -d $mysql_distro ] ; then
  91. github_download Tokutek/$mysql_repo $(git_tree $git_tag $mysql_tree) $mysql_distro-$mysql_version
  92. fi
  93. cd $mysql_distro-$mysql_version
  94. if [ $? != 0 ] ; then exit 1; fi
  95. # install the backup source
  96. if [ ! -d toku_backup ] ; then
  97. github_download Tokutek/backup-$build_type $(git_tree $git_tag $backup_tree) backup-$build_type
  98. cp -r backup-$build_type/backup toku_backup
  99. fi
  100. if [ ! -d tokudb-engine ] ; then
  101. github_download Tokutek/tokudb-engine $(git_tree $git_tag $tokudbengine_tree) tokudb-engine
  102. # install the tokudb storage engine source
  103. cp -r tokudb-engine/storage/tokudb storage/
  104. # merge the mysql tests
  105. mv mysql-test mysql-test-save
  106. cp -r tokudb-engine/mysql-test .
  107. cp -r mysql-test-save/* mysql-test
  108. rm -rf mysql-test-save
  109. # install the tokudb scripts
  110. cp -r tokudb-engine/scripts/* scripts/
  111. fi
  112. if [ ! -d storage/tokudb/ft-index ] ; then
  113. github_download Tokutek/ft-index $(git_tree $git_tag $ftindex_tree) storage/tokudb/ft-index
  114. fi
  115. if [[ $mysql_repo =~ mariadb ]] || [[ $mysql_distro =~ ^mariadb ]] ; then
  116. github_download Tokutek/jemalloc $(git_tree $git_tag $jemalloc_tree) extra/jemalloc
  117. elif [ ! -d storage/tokudb/ft-index/third_party/jemalloc ] ; then
  118. github_download Tokutek/jemalloc $(git_tree $git_tag $jemalloc_tree) storage/tokudb/ft-index/third_party/jemalloc
  119. fi
  120. # append tokudb-specific version
  121. if [ $(fgrep tokudb VERSION | wc -l) = 0 ] ; then
  122. # append the tokudb version to the MYSQL_VERSION_EXTRA variable in the VERSION file
  123. sed --in-place="" -e "s/^MYSQL_VERSION_EXTRA=.*/&-tokudb-${tokudb_version}/" VERSION
  124. fi
  125. # prints a cmake command to eval
  126. function generate_cmake_cmd () {
  127. local ls_remote # dont combine this with the following line
  128. ls_remote=$(git ls-remote https://github.com/Tokutek/ft-index.git $git_tag)
  129. if [ $? != 0 ] ; then
  130. echo 1>&2 "git ls-remote https://github.com/Tokutek/ft-index.git $git_tag failed $?"
  131. test 0 = 1; return
  132. fi
  133. local ft_revision=0x$(echo $ls_remote | cut -c-7)
  134. echo -n CC=$cc CXX=$cxx cmake \
  135. -D BUILD_CONFIG=mysql_release \
  136. -D CMAKE_BUILD_TYPE=$cmake_build_type \
  137. -D CMAKE_TOKUDB_REVISION=$ft_revision \
  138. -D BUILD_TESTING=OFF \
  139. -D USE_GTAGS=OFF \
  140. -D USE_CTAGS=OFF \
  141. -D USE_ETAGS=OFF \
  142. -D USE_CSCOPE=OFF
  143. if [ $build_debug = 1 ] ; then
  144. echo -n " " \
  145. -D USE_VALGRIND=ON \
  146. -D TOKU_DEBUG_PARANOID=ON
  147. else
  148. echo -n " " \
  149. -D USE_VALGRIND=OFF \
  150. -D TOKU_DEBUG_PARANOID=OFF
  151. fi
  152. if [[ $mysql_distro =~ ^Percona ]] ; then
  153. echo -n " " \
  154. -D WITH_EMBEDDED_SERVER=OFF
  155. fi
  156. if [ $system = darwin ] ; then
  157. echo -n " " \
  158. -D WITH_SAFEMALLOC=OFF \
  159. -D WITH_SSL=system
  160. fi
  161. if [ $build_type = enterprise ] ; then
  162. echo -n " " \
  163. -D COMPILATION_COMMENT=\"TokuDB Enterprise Server \(GPL\)\"
  164. fi
  165. }
  166. function generate_cmake_cmd_rpm() {
  167. if [ $system = linux -a $mysql_distro = mariadb ] ; then
  168. linux_distro=linux
  169. if [ -f /etc/issue ] ; then
  170. if [[ "$(head -1 /etc/issue)" =~ "Red Hat Enterprise Linux Server release ([56])" ]] ; then
  171. linux_distro=rhel${BASH_REMATCH[1]}
  172. fi
  173. if [[ "$(head -1 /etc/issue)" =~ "CentOS release ([56])" ]] ; then
  174. linux_distro=centos${BASH_REMATCH[1]}
  175. fi
  176. fi
  177. echo -n " " -D RPM=$linux_distro
  178. elif [ $system = linux -a $mysql_distro != mariadb ] ; then
  179. echo 1>&2 "I don't know how to build rpms for mysql yet."
  180. test 0 = 1; return
  181. fi
  182. }
  183. package_source_done=0
  184. if [ $build_tgz != 0 ] ; then
  185. mkdir -p build.$cmake_build_type
  186. pushd build.$cmake_build_type
  187. export TOKUDB_VERSION=$tokudb_version
  188. # actually build
  189. cmd=$(generate_cmake_cmd)
  190. if [ $? != 0 ] ; then exit 1; fi
  191. eval $cmd ..
  192. if [ $package_source_done = 0 ] ; then
  193. make package_source
  194. package_source_done=1
  195. fi
  196. make package -j$makejobs
  197. popd
  198. fi
  199. if [ $build_rpm != 0 ] ; then
  200. mkdir -p build.rpm.$cmake_build_type
  201. pushd build.rpm.$cmake_build_type
  202. # actually build
  203. cmd=$(generate_cmake_cmd; generate_cmake_cmd_rpm)
  204. if [ $? != 0 ] ; then exit 1; fi
  205. eval $cmd ..
  206. if [ $package_source_done = 0 ] ; then
  207. make package_source
  208. package_source_done=1
  209. fi
  210. make package -j$makejobs
  211. popd
  212. fi