2012-02-25 11:30:03 +04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2012-06-07 22:55:06 +04:00
|
|
|
# Copyright 2012, Google Inc. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can
|
|
|
|
# be found in the LICENSE file.
|
2012-02-25 11:30:03 +04:00
|
|
|
|
|
|
|
if [ ! -f bootstrap.sh ]; then
|
|
|
|
echo "bootstrap.sh must be run from its current directory" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
. ./dev.env
|
|
|
|
|
2012-09-13 22:12:27 +04:00
|
|
|
mkdir -p $VTROOT/dist
|
|
|
|
mkdir -p $VTROOT/bin
|
|
|
|
mkdir -p $VTROOT/lib
|
2012-10-27 00:11:44 +04:00
|
|
|
mkdir -p $VTROOT/vthook
|
2012-06-04 09:24:54 +04:00
|
|
|
|
2013-07-18 01:07:28 +04:00
|
|
|
# install zookeeper
|
|
|
|
zk_dist=$VTROOT/dist/vt-zookeeper-3.3.5
|
|
|
|
if [ -d $zk_dist ]; then
|
|
|
|
echo "skipping zookeeper build"
|
|
|
|
else
|
|
|
|
(cd $VTTOP/third_party/zookeeper && \
|
|
|
|
tar -xjf zookeeper-3.3.5.tbz && \
|
|
|
|
mkdir -p $zk_dist/lib && \
|
|
|
|
cp zookeeper-3.3.5/contrib/fatjar/zookeeper-3.3.5-fatjar.jar $zk_dist/lib && \
|
|
|
|
(cd zookeeper-3.3.5/src/c && \
|
|
|
|
./configure --prefix=$zk_dist && \
|
|
|
|
make -j3 install) && rm -rf zookeeper-3.3.5)
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "zookeeper build failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
ln -nfs $VTTOP/third_party/go/launchpad.net $VTROOT/src
|
|
|
|
go install launchpad.net/gozk/zookeeper
|
|
|
|
|
2014-04-17 20:59:13 +04:00
|
|
|
go get code.google.com/p/goprotobuf/proto
|
2014-05-08 22:34:58 +04:00
|
|
|
go get code.google.com/p/go.tools/cmd/goimports
|
2013-07-31 03:17:41 +04:00
|
|
|
go get github.com/golang/glog
|
2013-07-18 01:07:28 +04:00
|
|
|
|
2013-03-09 00:01:49 +04:00
|
|
|
ln -snf $VTTOP/config $VTROOT/config
|
|
|
|
ln -snf $VTTOP/data $VTROOT/data
|
|
|
|
ln -snf $VTTOP/py $VTROOT/py-vtdb
|
|
|
|
ln -snf $VTTOP/go/zk/zkctl/zksrv.sh $VTROOT/bin/zksrv.sh
|
2014-05-13 23:18:06 +04:00
|
|
|
ln -snf $VTTOP/test/vthook-copy_snapshot_from_storage.sh $VTROOT/vthook/copy_snapshot_from_storage
|
|
|
|
ln -snf $VTTOP/test/vthook-copy_snapshot_to_storage.sh $VTROOT/vthook/copy_snapshot_to_storage
|
2014-04-04 22:33:57 +04:00
|
|
|
ln -snf $VTTOP/test/vthook-test.sh $VTROOT/vthook/test.sh
|
2013-03-09 00:01:49 +04:00
|
|
|
|
2013-07-19 04:24:47 +04:00
|
|
|
# install mysql
|
2014-08-29 00:14:26 +04:00
|
|
|
case "$MYSQL_FLAVOR" in
|
|
|
|
"MariaDB")
|
|
|
|
myversion=`$VT_MYSQL_ROOT/bin/mysql --version | grep MariaDB`
|
|
|
|
if [ "$myversion" == "" ]; then
|
|
|
|
echo "Couldn't find MariaDB in $VT_MYSQL_ROOT. Set VT_MYSQL_ROOT to override search location."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "Found MariaDB installation in $VT_MYSQL_ROOT."
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
export VT_MYSQL_ROOT=$VTROOT/dist/mysql
|
|
|
|
if [ -d $VT_MYSQL_ROOT ]; then
|
|
|
|
echo "Skipping Google MySQL build. Delete $VT_MYSQL_ROOT to force rebuild."
|
|
|
|
else
|
2014-04-03 01:52:07 +04:00
|
|
|
echo "Getting and compiling Google MySQL"
|
|
|
|
git clone https://code.google.com/r/sougou-vitess-mysql/ third_party/mysql
|
|
|
|
pushd third_party/mysql
|
|
|
|
set -e
|
|
|
|
git apply ../mysql.patch
|
|
|
|
source google/env.inc
|
|
|
|
source google/compile.inc
|
2013-07-19 04:24:47 +04:00
|
|
|
|
2014-04-03 01:52:07 +04:00
|
|
|
# Install
|
|
|
|
make -s install #DESTDIR=$VTROOT/dist/mysql
|
|
|
|
rm -rf $VTROOT/dist/mysql/mysql-test
|
|
|
|
rm -rf $VTROOT/dist/mysql/sql-bench
|
|
|
|
popd
|
|
|
|
rm -rf third_party/mysql
|
2014-08-29 00:14:26 +04:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2013-07-19 04:24:47 +04:00
|
|
|
|
2014-08-23 00:53:54 +04:00
|
|
|
# save the flavor that was used in bootstrap, so it can be restored
|
|
|
|
# every time dev.env is sourced.
|
2014-08-29 00:14:26 +04:00
|
|
|
echo "$MYSQL_FLAVOR" > $VTROOT/dist/MYSQL_FLAVOR
|
2014-08-23 00:53:54 +04:00
|
|
|
|
2012-09-13 22:12:27 +04:00
|
|
|
# generate pkg-config, so go can use mysql C client
|
|
|
|
if [ ! -x $VT_MYSQL_ROOT/bin/mysql_config ]; then
|
2014-08-29 00:14:26 +04:00
|
|
|
echo "Cannot execute $VT_MYSQL_ROOT/bin/mysql_config. Did you install a client dev package?" 1>&2
|
2012-09-13 22:12:27 +04:00
|
|
|
exit 1
|
2012-09-05 01:20:28 +04:00
|
|
|
fi
|
2013-07-18 01:07:28 +04:00
|
|
|
|
2012-09-13 22:12:27 +04:00
|
|
|
cp $VTTOP/config/gomysql.pc.tmpl $VTROOT/lib/gomysql.pc
|
|
|
|
echo "Version:" "$($VT_MYSQL_ROOT/bin/mysql_config --version)" >> $VTROOT/lib/gomysql.pc
|
|
|
|
echo "Cflags:" "$($VT_MYSQL_ROOT/bin/mysql_config --cflags) -ggdb -fPIC" >> $VTROOT/lib/gomysql.pc
|
2014-08-20 03:07:43 +04:00
|
|
|
if [ "$MYSQL_FLAVOR" == "MariaDB" ]; then
|
|
|
|
# Use static linking because the shared library doesn't export
|
|
|
|
# some internal functions we use, like cli_safe_read.
|
|
|
|
echo "Libs:" "$($VT_MYSQL_ROOT/bin/mysql_config --libs_r | sed 's,-lmysqlclient_r,-l:libmysqlclient.a -lstdc++,')" >> $VTROOT/lib/gomysql.pc
|
|
|
|
else
|
|
|
|
echo "Libs:" "$($VT_MYSQL_ROOT/bin/mysql_config --libs_r)" >> $VTROOT/lib/gomysql.pc
|
|
|
|
fi
|
2012-09-05 01:20:28 +04:00
|
|
|
|
2012-09-13 22:12:27 +04:00
|
|
|
# install bson
|
2012-06-04 09:24:54 +04:00
|
|
|
bson_dist=$VTROOT/dist/py-vt-bson-0.3.2
|
2012-02-25 11:30:03 +04:00
|
|
|
if [ -d $bson_dist ]; then
|
|
|
|
echo "skipping bson python build"
|
|
|
|
else
|
|
|
|
cd $VTTOP/third_party/py/bson-0.3.2 && \
|
2013-07-20 02:53:56 +04:00
|
|
|
python ./setup.py install --prefix=$bson_dist && \
|
|
|
|
rm -r build
|
2012-02-25 11:30:03 +04:00
|
|
|
fi
|
|
|
|
|
2012-08-30 22:46:16 +04:00
|
|
|
# install cbson
|
2012-09-05 01:32:02 +04:00
|
|
|
cbson_dist=$VTROOT/dist/py-cbson
|
|
|
|
if [ -d $cbson_dist ]; then
|
|
|
|
echo "skipping cbson python build"
|
|
|
|
else
|
|
|
|
cd $VTTOP/py/cbson && \
|
|
|
|
python ./setup.py install --prefix=$cbson_dist
|
|
|
|
fi
|
2012-09-05 01:20:28 +04:00
|
|
|
|
2013-07-20 03:23:02 +04:00
|
|
|
# create pre-commit hooks
|
|
|
|
echo "creating git pre-commit hooks"
|
|
|
|
ln -sf $VTTOP/misc/git/pre-commit $VTTOP/.git/hooks/pre-commit
|
2012-02-25 11:30:03 +04:00
|
|
|
echo "source dev.env in your shell to complete the setup."
|