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
|
|
|
|
2015-03-12 19:06:23 +03:00
|
|
|
SKIP_ROOT_INSTALLS=False
|
2015-03-13 22:09:08 +03:00
|
|
|
if [ "$1" = "--skip_root_installs" ]; then
|
2015-03-12 19:06:23 +03:00
|
|
|
SKIP_ROOT_INSTALLS=True
|
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
|
2015-01-08 00:23:03 +03:00
|
|
|
if [ "$USER" == "root" ]; then
|
|
|
|
echo "Vitess cannot run as root. Please bootstrap with a non-root user."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-01-28 11:04:36 +03:00
|
|
|
go version 2>&1 >/dev/null
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Go is not installed or is not on \$PATH"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-02-25 11:30:03 +04:00
|
|
|
. ./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
|
2015-03-12 09:01:59 +03:00
|
|
|
if [ -f $zk_dist/.build_finished ]; then
|
|
|
|
echo "skipping zookeeper build. remove $zk_dist to force rebuild."
|
2013-07-18 01:07:28 +04:00
|
|
|
else
|
2015-03-12 09:01:59 +03:00
|
|
|
rm -rf $zk_dist
|
2013-07-18 01:07:28 +04:00
|
|
|
(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
|
2015-03-12 09:01:59 +03:00
|
|
|
fi
|
|
|
|
touch $zk_dist/.build_finished
|
2013-07-18 01:07:28 +04:00
|
|
|
fi
|
|
|
|
|
2015-03-02 19:48:22 +03:00
|
|
|
# install protoc and proto python libraries
|
|
|
|
protobuf_dist=$VTROOT/dist/protobuf
|
2015-03-12 19:06:23 +03:00
|
|
|
if [ $SKIP_ROOT_INSTALLS == "True" ]; then
|
|
|
|
echo "skipping protobuf build, as root version was already installed."
|
|
|
|
elif [ -f $protobuf_dist/.build_finished ]; then
|
2015-03-12 09:01:59 +03:00
|
|
|
echo "skipping protobuf build. remove $protobuf_dist to force rebuild."
|
2015-03-02 19:48:22 +03:00
|
|
|
else
|
2015-03-12 09:01:59 +03:00
|
|
|
rm -rf $protobuf_dist
|
2015-03-04 01:57:25 +03:00
|
|
|
mkdir -p $protobuf_dist/lib/python2.7/site-packages
|
2015-03-12 19:06:23 +03:00
|
|
|
# The directory may not have existed yet, so it may not have been
|
|
|
|
# picked up by dev.env yet, but the install needs it to exist first,
|
|
|
|
# and be in PYTHONPATH.
|
2015-03-04 01:57:25 +03:00
|
|
|
export PYTHONPATH=$(prepend_path $PYTHONPATH $protobuf_dist/lib/python2.7/site-packages)
|
2015-03-12 19:06:23 +03:00
|
|
|
./travis/install_protobuf.sh $protobuf_dist
|
2015-03-02 19:48:22 +03:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "protobuf build failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-03-12 09:01:59 +03:00
|
|
|
touch $protobuf_dist/.build_finished
|
2015-03-02 19:48:22 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# install gRPC C++ base, so we can install the python adapters
|
|
|
|
grpc_dist=$VTROOT/dist/grpc
|
2015-03-12 19:06:23 +03:00
|
|
|
if [ $SKIP_ROOT_INSTALLS == "True" ]; then
|
|
|
|
echo "skipping grp build, as root version was already installed."
|
|
|
|
elif [ -f $grpc_dist/.build_finished ]; then
|
2015-03-12 09:01:59 +03:00
|
|
|
echo "skipping gRPC build. remove $grpc_dist to force rebuild."
|
2015-03-02 19:48:22 +03:00
|
|
|
else
|
2015-03-12 09:01:59 +03:00
|
|
|
rm -rf $grpc_dist
|
2015-03-12 19:06:23 +03:00
|
|
|
mkdir -p $grpc_dist
|
|
|
|
./travis/install_grpc.sh $grpc_dist
|
2015-03-02 19:48:22 +03:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "gRPC build failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-03-12 09:01:59 +03:00
|
|
|
touch $grpc_dist/.build_finished
|
2015-03-02 19:48:22 +03:00
|
|
|
fi
|
|
|
|
|
2013-07-18 01:07:28 +04:00
|
|
|
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-12-14 23:48:10 +03:00
|
|
|
go get golang.org/x/net/context
|
|
|
|
go get golang.org/x/tools/cmd/goimports
|
2013-07-31 03:17:41 +04:00
|
|
|
go get github.com/golang/glog
|
2014-12-20 00:10:48 +03:00
|
|
|
go get github.com/golang/lint/golint
|
2015-01-29 02:44:42 +03:00
|
|
|
go get github.com/tools/godep
|
2015-02-27 20:07:03 +03:00
|
|
|
go get google.golang.org/grpc
|
|
|
|
go get -a github.com/golang/protobuf/protoc-gen-go
|
2013-07-18 01:07:28 +04:00
|
|
|
|
2014-12-24 14:45:24 +03:00
|
|
|
# goversion_min returns true if major.minor go version is at least some value.
|
|
|
|
function goversion_min() {
|
|
|
|
[[ "$(go version)" =~ go([0-9]+)\.([0-9]+) ]]
|
|
|
|
gotmajor=${BASH_REMATCH[1]}
|
|
|
|
gotminor=${BASH_REMATCH[2]}
|
|
|
|
[[ "$1" =~ ([0-9]+)\.([0-9]+) ]]
|
|
|
|
wantmajor=${BASH_REMATCH[1]}
|
|
|
|
wantminor=${BASH_REMATCH[2]}
|
|
|
|
[ "$gotmajor" -lt "$wantmajor" ] && return 1
|
|
|
|
[ "$gotmajor" -gt "$wantmajor" ] && return 0
|
|
|
|
[ "$gotminor" -lt "$wantminor" ] && return 1
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2015-01-28 10:46:06 +03:00
|
|
|
# Packages for uploading code coverage to coveralls.io.
|
|
|
|
# The cover tool needs to be installed into the Go toolchain, so it will fail
|
|
|
|
# if Go is installed somewhere that requires root access. However, this tool
|
|
|
|
# is optional, so we should hide any errors to avoid confusion.
|
2014-12-24 14:45:24 +03:00
|
|
|
if goversion_min 1.4; then
|
2015-01-28 10:46:06 +03:00
|
|
|
go get golang.org/x/tools/cmd/cover &> /dev/null
|
2014-12-24 14:45:24 +03:00
|
|
|
else
|
2015-01-28 10:46:06 +03:00
|
|
|
go get code.google.com/p/go.tools/cmd/cover &> /dev/null
|
2014-12-24 14:45:24 +03:00
|
|
|
fi
|
2014-10-01 05:59:51 +04:00
|
|
|
go get github.com/modocache/gover
|
|
|
|
go get github.com/mattn/goveralls
|
|
|
|
|
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-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
|
2015-02-23 18:42:32 +03:00
|
|
|
if [ -z "$MYSQL_FLAVOR" ]; then
|
|
|
|
export MYSQL_FLAVOR=MariaDB
|
|
|
|
fi
|
2014-08-29 00:14:26 +04:00
|
|
|
case "$MYSQL_FLAVOR" in
|
2015-02-20 00:03:12 +03:00
|
|
|
"Mysql56")
|
|
|
|
echo "Mysql 5.6 support is under development and not supported yet."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
|
2015-02-23 18:42:32 +03:00
|
|
|
"MariaDB")
|
2014-08-29 00:14:26 +04:00
|
|
|
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."
|
|
|
|
;;
|
|
|
|
|
2015-02-23 18:42:32 +03:00
|
|
|
*)
|
|
|
|
echo "Unsupported MYSQL_FLAVOR $MYSQL_FLAVOR"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
|
2014-08-29 00:14:26 +04:00
|
|
|
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
|
2015-01-08 00:23:03 +03:00
|
|
|
|
|
|
|
echo
|
2015-01-28 10:48:29 +03:00
|
|
|
echo "bootstrap finished - run 'source dev.env' in your shell before building."
|