public
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
#!/usr/bin/env bash
export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc
export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp
export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++
export LD=/opt/centos/devtoolset-1.1/root/usr/bin/ld
 
set -x
 
shopt -s compat31 2> /dev/null
 
function usage() {
echo "make.mysql.bash - build mysql with the fractal tree"
echo "--git_tag=$git_tag --git_server=$git_server"
echo "--mysqlbuild=$mysqlbuild"
echo "--mysql=$mysql"
echo "--build_type=$build_type"
echo "--build_debug=$build_debug"
echo "--build_tgz=$build_tgz"
echo "--build_rpm=$build_rpm"
echo "--cmake_build_type=$cmake_build_type"
echo "--cc=$cc --cxx=$cxx"
echo "--do_s3=$do_s3 --do_make_check=$do_make_check"
return 1
}
 
function retry() {
local cmd
local retries
local exitcode
cmd=$*
let retries=0
while [ $retries -le 10 ] ; do
echo `date` $cmd
bash -c "$cmd"
exitcode=$?
echo `date` $cmd $exitcode $retries
let retries=retries+1
if [ $exitcode -eq 0 ] ; then break; fi
sleep 10
done
test $exitcode = 0
}
 
function github_download() {
repo=$1; shift
rev=$1; shift
dest=$1; shift
mkdir $dest
 
if [ ! -z $github_token ] ; then
retry curl \
--header "Authorization:\\ token\\ $github_token" \
--location https://api.github.com/repos/$repo/tarball/$rev \
--output $dest.tar.gz
tar --extract \
--gzip \
--directory=$dest \
--strip-components=1 \
--file $dest.tar.gz
rm -f $dest.tar.gz
elif [ ! -z $github_user ] ; then
retry curl \
--user $github_user \
--location https://api.github.com/repos/$repo/tarball/$rev \
--output $dest.tar.gz
tar --extract \
--gzip \
--directory=$dest \
--strip-components=1 \
--file $dest.tar.gz
rm -f $dest.tar.gz
else
tempdir=$(mktemp -d -p $PWD)
retry git clone https://github.com/${repo}.git $tempdir
 
# export the right branch or tag
(cd $tempdir ;
git archive \
--format=tar \
$rev) | \
tar --extract \
--directory $dest
if [ $? != 0 ] ; then exit 1; fi
 
rm -rf $tempdir
fi
}
 
function get_ncpus() {
if [ -f /proc/cpuinfo ]; then
grep bogomips /proc/cpuinfo | wc -l
elif [ $system = darwin ] ; then
sysctl -n hw.ncpu
else
echo 1
fi
}
 
function build_jemalloc() {
if [ ! -d jemalloc ] ; then
# get the jemalloc repo jemalloc
github_download Tokutek/jemalloc $git_tag jemalloc
if [ $? != 0 ] ; then exit 1; fi
pushd jemalloc
if [ $? != 0 ] ; then exit 1; fi
./configure --with-private-namespace=jemalloc_
if [ $? != 0 ] ; then exit 1; fi
make
if [ $? != 0 ] ; then exit 1; fi
popd
fi
}
 
# check out the fractal tree source from subversion, build it, and make the fractal tree tarballs
function build_fractal_tree() {
if [ ! -d ft-index ] ; then
 
# get the ft-index repo
github_download Tokutek/ft-index $git_tag ft-index
if [ $? != 0 ] ; then exit 1; fi
 
# get the commit id of the ft-index repo
local ft_revision=0
if [ ! -z $github_token ] ; then
local ft_index_ls
ft_index_ls=$(git ls-remote https://$github_token:x-oauth-basic@github.com/Tokutek/ft-index.git $git_tag)
if [ $? != 0 ] ; then exit 1; fi
local ft_revision_hex
ft_revision_hex=0x$(echo $ft_index_ls | cut -c-7)
let ft_revision=$ft_revision_hex
fi
 
pushd ft-index
if [ $? != 0 ] ; then exit 1; fi
 
local ft_build_type=""
local use_valgrind=""
local debug_paranoid=""
if [[ $build_debug = 1 ]]; then
ft_build_type=Debug
use_valgrind="ON"
debug_paranoid="ON"
else
ft_build_type=Release
use_valgrind="OFF"
debug_paranoid="OFF"
fi
 
mkdir -p build
pushd build
if [ $? != 0 ] ; then exit 1; fi
cmake28 \
-D LIBTOKUDB=$tokufractaltree \
-D LIBTOKUPORTABILITY=$tokuportability \
-D CMAKE_TOKUDB_REVISION=$ft_revision \
-D CMAKE_BUILD_TYPE=$ft_build_type \
-D JEMALLOC_SOURCE_DIR=../../jemalloc \
-D CMAKE_INSTALL_PREFIX=../../$tokufractaltreedir \
-D BUILD_TESTING=OFF \
-D USE_GTAGS=OFF \
-D USE_CTAGS=OFF \
-D USE_ETAGS=OFF \
-D USE_CSCOPE=OFF \
-D USE_VALGRIND=$use_valgrind \
-D TOKU_DEBUG_PARANOID=$debug_paranoid \
..
make install -j$makejobs
if [ $? != 0 ] ; then exit 1; fi
 
popd # build
 
popd # ft-index
 
pushd $tokufractaltreedir/examples
if [ $? != 0 ] ; then exit 1; fi
 
# test the examples
sed -ie "s/LIBTOKUDB = tokudb/LIBTOKUDB = $tokufractaltree/" Makefile
sed -ie "s/LIBTOKUPORTABILITY = tokuportability/LIBTOKUPORTABILITY = $tokuportability/" Makefile
if [ $system = darwin ] ; then
DYLD_LIBRARY_PATH=$PWD/../lib:$DYLD_LIBRARY_PATH make check
exitcode=$?
else
if [ $do_make_check != 0 ] ; then
make check
exitcode=$?
else
exitcode=0
fi
fi
echo `date` make check examples $tokufractaltree $exitcode
if [ $exitcode != 0 ] ; then exit 1; fi
make clean
popd
# add jemalloc.so
if [ $system = linux ] ; then
cp jemalloc/lib/libjemalloc.so.1 $tokufractaltreedir/lib
elif [ $system = darwin ] ; then
cp jemalloc/lib/libjemalloc.1.dylib $tokufractaltreedir/lib
fi
cp jemalloc/lib/libjemalloc.a $tokufractaltreedir/lib/libjemalloc.a
 
# make tarballs
tar czf $tokufractaltreedir.tar.gz $tokufractaltreedir
md5sum $tokufractaltreedir.tar.gz >$tokufractaltreedir.tar.gz.md5
md5sum --check $tokufractaltreedir.tar.gz.md5
fi
}
 
function generate_cmake_cmd() {
local mysqlsrc=$1; shift
local extra_flags=$*
extra_flags=-DWITH_EMBEDDED_SERVER=OFF
 
echo -n cmake28 .. $extra_flags -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=$cmake_build_type
if [ $system = linux ] ; then
echo -n " " \
-DTOKU_JEMALLOC_LIBRARY=\"-Wl,--whole-archive \$TOKUFRACTALTREE/lib/libjemalloc.a -Wl,-no-whole-archive\"
elif [ $system = darwin ] ; then
echo -n " " \
-DWITH_SAFEMALLOC=OFF -DWITH_SSL=system \
-DTOKU_JEMALLOC_LIBRARY=\"-Wl,-force_load -Wl,\$TOKUFRACTALTREE/lib/libjemalloc.a\"
else
exit 1
fi
if [ $build_type = enterprise ] ; then
echo -n " " -DCOMPILATION_COMMENT=\"TokuDB Enterprise Server \(GPL\)\"
fi
echo
}
 
# generate a script that builds from the mysql src tarball and the fractal tree tarball
function generate_build_from_src() {
local mysqlsrc=$1; local tokufractaltreedir=$2
pushd $mysqlsrc >/dev/null 2>&1
if [ $? = 0 ] ; then
echo '#/usr/bin/env bash'
 
# defaults
echo 'makejobs=1'
 
# parse arguments
echo 'while [ $# -gt 0 ] ; do'
echo ' arg=$1; shift'
echo ' if [[ $arg =~ --(.*)=(.*) ]] ; then'
echo ' eval ${BASH_REMATCH[1]}=${BASH_REMATCH[2]}'
echo ' else'
echo ' break'
echo ' fi'
echo 'done'
# check tarballs
echo md5sum --check $mysqlsrc.tar.gz.md5
echo 'if [ $? != 0 ] ; then exit 1; fi'
echo md5sum --check $tokufractaltreedir.tar.gz.md5
echo 'if [ $? != 0 ] ; then exit 1; fi'
echo "if [ ! -d $mysqlsrc ] ; then"
echo " tar xzf $mysqlsrc.tar.gz"
echo ' if [ $? != 0 ] ; then exit 1; fi'
echo fi
echo "if [ ! -d $tokufractaltreedir ] ;then"
echo " tar xzf $tokufractaltreedir.tar.gz"
echo ' if [ $? != 0 ] ; then exit 1; fi'
echo fi
 
# setup environment variables
echo export TOKUDB_VERSION=$tokudb_version
echo export TOKUFRACTALTREE='$PWD'/$tokufractaltreedir
echo export TOKUDB_PATCHES=$tokudb_patches
echo export TOKUFRACTALTREE_LIBNAME=${tokufractaltree}_static
echo export TOKUPORTABILITY_LIBNAME=${tokuportability}_static
echo "pushd $mysqlsrc"
echo 'if [ $? != 0 ] ; then exit 1; fi'
 
if [ ! -f CMakeLists.txt ] ; then exit 1; fi
 
if [ $build_tgz != 0 ] ; then
echo "mkdir build.$cmake_build_type; pushd build.$cmake_build_type"
echo 'if [ $? != 0 ] ; then exit 1; fi'
 
cmd=$(generate_cmake_cmd $mysqlsrc)
echo $cmd
echo 'if [ $? != 0 ] ; then exit 1; fi'
 
# make binary distribution package
echo 'make package -j$makejobs'
echo 'if [ $? != 0 ] ; then exit 1; fi'
 
# fixup tarball name mismatch (if any)
echo "if [ ! -f $mysqldir.tar.gz ] ; then"
echo ' oldtb=$(ls *.gz)'
echo ' if [[ $oldtb =~ (.*).tar.gz ]] ; then oldmysqldir=${BASH_REMATCH[1]}; fi'
echo ' tar xzf $oldtb'
echo ' if [ $? != 0 ] ; then exit 1; fi'
echo ' mv $oldmysqldir' $mysqldir
echo " tar czf $mysqldir.tar.gz $mysqldir"
echo ' if [ $? != 0 ] ; then exit 1; fi'
echo 'fi'
 
# add ft files to the mysql tarball
echo tar xzf $mysqldir.tar.gz
echo 'if [ $? != 0 ] ; then exit 1; fi'
# add ftdump to mysql tarball
echo "cp ../../$tokufractaltreedir/bin/ftdump $mysqldir/bin/tokuftdump"
echo 'if [ $? != 0 ] ; then exit 1; fi'
 
# cleanup
echo rm $mysqldir.tar.gz
echo 'if [ $? != 0 ] ; then exit 1; fi'
echo tar czf $mysqldir.tar.gz $mysqldir
echo 'if [ $? != 0 ] ; then exit 1; fi'
 
# generate the md5 file
echo "if [ -f $mysqldir.tar.gz ] ; then"
echo " md5sum $mysqldir.tar.gz >$mysqldir.tar.gz.md5"
echo ' if [ $? != 0 ] ; then exit 1; fi'
echo 'fi'
 
echo popd
fi
 
# make RPMs
if [ $system = linux -a $build_rpm != 0 ]; then
echo "mkdir build.${cmake_build_type}.rpms; pushd build.${cmake_build_type}.rpms"
echo 'if [ $? != 0 ] ; then exit 1; fi'
 
if [[ $mysqlsrc =~ ^mariadb ]] ; then
echo linux_distro=linux
echo 'if [ -f /etc/issue ] ; then'
echo ' if [[ "$(head -1 /etc/issue)" =~ Red\ Hat\ Enterprise\ Linux\ Server\ release\ ([56]) ]] ; then linux_distro=rhel${BASH_REMATCH[1]}; fi'
echo ' if [[ "$(head -1 /etc/issue)" =~ CentOS\ release\ ([56]) ]] ; then linux_distro=centos${BASH_REMATCH[1]}; fi'
echo fi
 
cmd=$(generate_cmake_cmd $mysqlsrc -DRPM=\$linux_distro)
echo $cmd
echo 'if [ $? != 0 ] ; then exit 1; fi'
 
# make binary distribution package
echo 'make package -j$makejobs'
echo 'if [ $? != 0 ] ; then exit 1; fi'
else
echo 'mkdir -p {tmp,BUILD,RPMS,SOURCES,SPECS,SRPMS}'
 
# split myslqsrc into components
echo "if [[ $mysqlsrc =~ (.*)-([0-9]+\.[0-9]+\.[0-9]+.*)-tokudb-(.*) ]] ; then"
echo ' mysql_distro=${BASH_REMATCH[1]}'
echo ' mysql_version=${BASH_REMATCH[2]}'
echo ' mysql_distro_version=${mysql_distro}-${mysql_version}'
echo ' tokudb_distro=tokudb'
echo ' tokudb_version=7.0.1'
echo ' tokudb_distro_version=${tokudb_distro}-${tokudb_version}'
echo else
echo ' exit 1'
echo fi
 
# copy the source tarball
echo "cp ../../$mysqlsrc.tar.gz SOURCES/$mysqlsrc.tar.gz"
echo 'if [ $? != 0 ] ; then exit 1; fi'
 
# hack on the spec file
echo 'specfile=${mysql_distro}.${mysql_version}.spec'
echo 'cp ../support-files/$specfile SPECS/$specfile'
echo 'if [ $? != 0 ] ; then exit 1; fi'
echo 'sed -i -e"s/^%define mysql_version.*/&-${tokudb_distro_version}/" SPECS/$specfile'
echo 'sed -i -e"s/^%define release.*/%define release $(echo ${tokudb_distro_version}|tr - .)/" SPECS/$specfile'
# echo 'sed -i -e"s/^\(.*-DMYSQL_SERVER_SUFFIX=.*\)$/& -DEXTRA_VERSION=-${tokudb_distro_version}/" SPECS/$specfile'
# include README-TOKUDB in the RPM
echo 'sed -i -e"s/README/& %{src_dir}\/README-TOKUDB/" SPECS/$specfile'
 
# add jemalloc to the linker flags
echo 'sed -i -e"s/^\(.*-DMYSQL_SERVER_SUFFIX=.*\)$/& -DTOKU_JEMALLOC_LIBRARY=\"-Wl,--whole-archive \$\{TOKUFRACTALTREE\}\/lib\/libjemalloc.a -Wl,-no-whole-archive\"/" SPECS/$specfile'
 
# add the hot backup lib to the server package file list
echo 'sed -i -e"s/%{_datadir}\/mysql\/$/&\n%attr(755, root, root) %{_libdir}\/libHotBackup*.so/" SPECS/$specfile'
 
# build generic linux RPMs
echo 'export MYSQL_BUILD_MAKE_JFLAG=-j$makejobs'
echo 'rpmbuild -v --define="_topdir $PWD" --define="_tmppath $PWD/tmp" --define="src_base $mysql_distro" -ba SPECS/$specfile'
echo 'if [ $? != 0 ] ; then exit 1; fi'
 
# move the rpms
echo 'pushd RPMS/$(uname -m)'
echo 'if [ $? != 0 ] ; then exit 1; fi'
echo 'mv *.rpm ../..'
echo 'if [ $? != 0 ] ; then exit 1; fi'
echo 'popd'
echo 'pushd SRPMS'
echo 'if [ $? != 0 ] ; then exit 1; fi'
echo 'mv *.rpm ..'
echo 'if [ $? != 0 ] ; then exit 1; fi'
echo 'popd'
fi
 
# generate the md5 file
echo 'rpmfiles=$(ls *.rpm)'
echo 'for x in $rpmfiles; do'
echo ' md5sum $x >$x.md5'
echo ' if [ $? != 0 ] ; then exit 1; fi'
echo 'done'
 
echo popd
fi
echo popd
 
popd >/dev/null 2>&1
fi
}
 
# checkout the mysql source, generate a build script, and make the mysql source tarball
function build_mysql_src() {
# if [ ! -d $mysqlsrc ] ; then
 
# get the mysql repo
#if [ ! -d $mysql_distro ] ; then
# github_download Tokutek/$mysql_distro $git_tag $mysqlsrc
# if [ $? != 0 ] ; then exit 1; fi
#fi
mysqlsrc="percona-5.5.30-tokudb-7.0.1"
# get the hot backup source
if [ ! -d backup-$build_type ] ; then
github_download Tokutek/backup-$build_type $git_tag backup-$build_type
if [ $? != 0 ] ; then exit 1; fi
fi
 
# get the ft-engine repo
if [ ! -d ft-engine ] ; then
github_download Tokutek/ft-engine $git_tag ft-engine
if [ $? != 0 ] ; then exit 1; fi
fi
 
# append the tokudb version to the MYSQL_VERSION_EXTRA variable in the VERSION file
sed -i "" -e"s/^MYSQL_VERSION_EXTRA=.*/MYSQL_VERSION_EXTRA=-tokudb-7.0.1/" $mysqlsrc/VERSION
 
# add the backup source
mkdir $mysqlsrc/toku_backup
pushd backup-$build_type/backup
if [ $? != 0 ] ; then exit 1; fi
copy_files=$(ls CMakeLists.txt *.h *.cc *.cmake export.map)
cp $copy_files ../../$mysqlsrc/toku_backup
if [ $? != 0 ] ; then exit 1; fi
popd
 
# add the tokudb storage engine source
mkdir -p $mysqlsrc/storage/tokudb
pushd ft-engine/storage/tokudb
if [ $? != 0 ] ; then exit 1; fi
copy_files=$(ls CMakeLists.txt *.h *.cc)
cp $copy_files ../../../$mysqlsrc/storage/tokudb
if [ $? != 0 ] ; then exit 1; fi
popd
 
# merge the common mysql tests into the source
mv $mysqlsrc/mysql-test $mysqlsrc/mysql-test-save
cp -r ft-engine/mysql-test $mysqlsrc
cp -r $mysqlsrc/mysql-test-save/* $mysqlsrc/mysql-test
rm -rf $mysqlsrc/mysql-test-save
 
# add the common scripts into the source
cp -r ft-engine/scripts $mysqlsrc
 
# generate the tokudb.build.bash script from the mysql src and the fractal tree tarballs
generate_build_from_src $mysqlsrc $tokufractaltreedir >$mysqlsrc/scripts/tokudb.build.bash
 
# add README-TOKUDB
if [ ! -f $mysqlsrc/README-TOKUDB ] ; then
cp ft-index/README-TOKUDB $mysqlsrc
fi
sed -i -e's/FILES README DESTINATION/FILES README README-TOKUDB DESTINATION/' $mysqlsrc/CMakeLists.txt
 
# make the mysql src tarball
tar czf $mysqlsrc.tar.gz $mysqlsrc
if [ $? != 0 ] ; then exit 1; fi
md5sum $mysqlsrc.tar.gz >$mysqlsrc.tar.gz.md5
if [ $? != 0 ] ; then exit 1; fi
#fi
}
 
# make the mysql release tarball
# by executing the build script in the mysql source tarball and compiling with the fractal tree tarball
function build_mysql_release() {
if [ ! -d $mysqlbuild ] ; then
 
mkdir $mysqlbuild
pushd $mysqlbuild
 
# create links to the mysql source and fractal tree tarballs
ln $basedir/$mysqlsrc.tar.gz
ln $basedir/$mysqlsrc.tar.gz.md5
ln $basedir/$tokufractaltreedir.tar.gz
ln $basedir/$tokufractaltreedir.tar.gz.md5
 
# extract the build script
tar xzf $mysqlsrc.tar.gz $mysqlsrc/scripts/tokudb.build.bash
if [ $? != 0 ] ; then exit 1; fi
cp $mysqlsrc/scripts/tokudb.build.bash .
if [ $? != 0 ] ; then exit 1; fi
rm -rf $mysqlsrc
 
# execute the build script
bash -x tokudb.build.bash --makejobs=$makejobs
if [ $? != 0 ] ; then exit 1; fi
 
# move the build files
pushd $mysqlsrc/build.${cmake_build_type}
if [ $? = 0 ] ; then
cp $mysqldir.tar.gz* $basedir; if [ $? != 0 ] ; then exit 1; fi
popd
fi
if [ $build_rpm != 0 ] ; then
pushd $mysqlsrc/build.${cmake_build_type}.rpms
if [ $? = 0 ] ; then
rpmfiles=$(ls *.rpm *.rpm.md5)
for x in $rpmfiles; do cp $x $basedir; if [ $? != 0 ] ; then exit 1; fi; done
popd
fi
fi
 
popd
fi
}
 
function parse_mysqlbuild() {
local mysqlbuild=$1
local exitcode
if [[ $mysqlbuild =~ ((mysql|mariadb)-(.*))-((tokudb)-(.*))-(linux|darwin)-(x86_64|i386) ]] ; then
mysql=${BASH_REMATCH[1]}
mysql_distro=${BASH_REMATCH[2]}
mysql_version=${BASH_REMATCH[3]}
tokudb=${BASH_REMATCH[4]}
tokudb_distro=${BASH_REMATCH[5]}
tokudb_version=${BASH_REMATCH[6]}
target_system=${BASH_REMATCH[7]}
target_arch=${BASH_REMATCH[8]}
if [[ $tokudb_version =~ (.*)-e$ ]] ; then
build_type=enterprise
tokudb_version=${BASH_REMATCH[1]}
else
build_type=community
fi
if [[ $tokudb_version =~ (.*)-debug$ ]] ; then
build_debug=1
tokudb_verison=${BASH_REMATCH[1]}
else
build_debug=0
fi
if [[ $tokudb_version =~ ^([0-9]+)\\.([0-9]+)\\.([0-9]+)$ ]] ; then
git_tag=tokudb-$tokudb_version
elif [[ $tokudb_version =~ ^[0-9]+$ ]] ; then
git_tag=HEAD
else
git_tag=$tokudb_version
fi
exitcode=0
else
exitcode=1
fi
test $exitcode = 0
}
 
PATH=$HOME/bin:$PATH
 
system=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(uname -m | tr '[:upper:]' '[:lower:]')
makejobs=$(get_ncpus)
 
git_server=git@github.com
git_tag=HEAD
mysqlbuild=
mysql=mysql-5.5.30
do_s3=1
do_make_check=1
build_debug=0
build_type=community
build_tgz=1
build_rpm=0
tokudb_patches=1
cmake_build_type=RelWithDebInfo
 
while [ $# -gt 0 ] ; do
arg=$1; shift
if [ $arg = "--gcc44" ] ; then
cc=gcc44; cxx=g++44
elif [[ $arg =~ --(.*)=(.*) ]] ; then
eval ${BASH_REMATCH[1]}=${BASH_REMATCH[2]}
else
usage; exit 1;
fi
done
 
if [ ! -z $mysqlbuild ] ; then
parse_mysqlbuild $mysqlbuild
if [ $? != 0 ] ; then exit 1; fi
else
# set tokudb version
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
fi
 
# split mysql into mysql_distro and mysql_version
if [[ $mysql =~ ^(mysql|mariadb|percona)-(.*)$ ]] ; then
mysql_distro=${BASH_REMATCH[1]}
mysql_version=${BASH_REMATCH[2]}
else
exit 1
fi
 
# set build dir
builddir=build-tokudb-$tokudb_version
if [ ! -d $builddir ] ; then mkdir $builddir; fi
pushd $builddir
 
basedir=$PWD
 
# build the jemalloc library
build_jemalloc
 
# build the fractal tree tarball
tokufractaltree=tokufractaltreeindex-$tokudb_version
tokuportability=tokuportability-$tokudb_version
tokufractaltreedir=$tokufractaltree-$system-$arch
build_fractal_tree
 
# build the mysql source tarball
mysqldir=$mysql-tokudb-$tokudb_version-$system-$arch
mysqlsrc=$mysql-tokudb-$tokudb_version
build_mysql_src
 
# build the mysql release tarball
mysqlbuild=$mysqldir-build
build_mysql_release
 
# copy to s3
if [ $do_s3 != 0 ] ; then
files=$(ls $tokufractaltreedir.tar.gz* $mysqldir.tar.gz* $mysqlsrc.tar.gz* *.rpm*)
for f in $files; do
# add the file to the tokutek-mysql-build bucket
echo `date` s3put $f
s3put tokutek-mysql-build $f $f
exitcode=$?
# index the file by date
echo `date` s3put tokutek-mysql-build $f $exitcode
d=$(date +%Y%m%d)
s3put tokutek-mysql-build-date $d/$f /dev/null
exitcode=$?
echo `date` s3put tokutek-mysql-build-date $d/$f $exitcode
done
if [[ $git_tag =~ tokudb-.* ]] ; then
s3mkbucket tokutek-mysql-$git_tag
if [ $? = 0 ] ; then
files=$(ls $tokufractaltreedir.tar.gz* $mysqldir.tar.gz* $mysqlsrc.tar.gz* *.rpm*)
for f in $files; do
echo `date` s3copykey $git_tag $f
s3copykey tokutek-mysql-$git_tag $f tokutek-mysql-build $f
exitcode=$?
echo `date` s3copykey $git_tag $f $exitcode
done
fi
fi
fi
 
popd
 
exit 0

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.