2014-09-24 05:14:28 +00:00
|
|
|
#!/usr/bin/env bash
|
2014-09-17 08:22:14 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2014-09-20 23:26:40 +00:00
|
|
|
WORKING_DIR="$SCRIPT_DIR/../.sources"
|
2014-09-17 08:22:14 +00:00
|
|
|
export PATH="$PATH:/usr/local/bin"
|
|
|
|
|
2014-10-30 19:59:10 +00:00
|
|
|
source "$SCRIPT_DIR/lib.sh"
|
2014-09-17 08:22:14 +00:00
|
|
|
|
|
|
|
# cmake
|
|
|
|
# downloads: http://www.cmake.org/download/
|
|
|
|
|
|
|
|
function install_cmake() {
|
2014-10-02 17:58:56 +00:00
|
|
|
if [ "$OS" = "centos" ] || [ "$OS" = "ubuntu" ] || [ "$OS" = "darwin" ]; then
|
2014-09-17 08:22:14 +00:00
|
|
|
if [[ ! -f cmake-2.8.12.2.tar.gz ]]; then
|
|
|
|
log "downloading the cmake source"
|
|
|
|
wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
|
|
|
|
fi
|
|
|
|
if [[ ! -d cmake-2.8.12.2 ]]; then
|
|
|
|
log "unpacking the cmake source"
|
|
|
|
tar -xf cmake-2.8.12.2.tar.gz
|
|
|
|
fi
|
|
|
|
if [[ -f /usr/local/bin/cmake ]]; then
|
|
|
|
log "cmake is already installed. skipping."
|
|
|
|
else
|
|
|
|
log "building cmake"
|
|
|
|
pushd cmake-2.8.12.2 > /dev/null
|
2014-10-02 22:54:55 +00:00
|
|
|
CC=clang CXX=clang++ ./configure
|
2014-09-17 08:22:14 +00:00
|
|
|
make
|
2014-10-02 23:46:32 +00:00
|
|
|
sudo make install
|
2014-09-17 08:22:14 +00:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_thrift() {
|
2014-09-23 02:27:19 +00:00
|
|
|
if [[ ! -f /usr/local/lib/libthrift.a ]]; then
|
2014-10-02 22:54:55 +00:00
|
|
|
if [[ ! -f 0.9.1.tar.gz ]]; then
|
|
|
|
wget https://github.com/apache/thrift/archive/0.9.1.tar.gz
|
|
|
|
fi
|
|
|
|
if [[ ! -d thrift-0.9.1 ]]; then
|
|
|
|
tar -xf 0.9.1.tar.gz
|
|
|
|
fi
|
2014-09-17 08:22:14 +00:00
|
|
|
pushd thrift-0.9.1
|
|
|
|
./bootstrap.sh
|
2014-10-08 03:44:58 +00:00
|
|
|
./configure --with-cpp=yes --with-ruby=no --with-go=no --with-erlang=no --with-java=no --with-python=no
|
2014-09-17 08:22:14 +00:00
|
|
|
make
|
2014-09-25 07:27:07 +00:00
|
|
|
sudo make install
|
2014-09-17 08:22:14 +00:00
|
|
|
popd
|
|
|
|
else
|
|
|
|
log "thrift is installed. skipping."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_rocksdb() {
|
2014-10-02 22:54:55 +00:00
|
|
|
if [[ ! -f /usr/local/lib/librocksdb.a ]]; then
|
|
|
|
if [[ ! -f rocksdb-3.5.tar.gz ]]; then
|
|
|
|
wget https://github.com/facebook/rocksdb/archive/rocksdb-3.5.tar.gz
|
|
|
|
fi
|
|
|
|
if [[ ! -d rocksdb-rocksdb-3.5 ]]; then
|
|
|
|
tar -xf rocksdb-3.5.tar.gz
|
2014-09-20 23:36:04 +00:00
|
|
|
fi
|
2014-10-08 03:44:58 +00:00
|
|
|
if [ "$OS" = "ubuntu" ] || [ "$OS" = "centos" ]; then
|
2014-10-02 22:54:55 +00:00
|
|
|
if [[ ! -f rocksdb-rocksdb-3.5/librocksdb.a ]]; then
|
2014-10-08 23:09:02 +00:00
|
|
|
if [[ $OS = "ubuntu" ]]; then
|
2014-10-08 03:44:58 +00:00
|
|
|
CLANG_INCLUDE="-I/usr/include/clang/3.4/include"
|
|
|
|
elif [[ $OS = "centos" ]]; then
|
|
|
|
CLANG_VERSION=`clang --version | grep version | cut -d" " -f3`
|
2014-10-08 23:09:02 +00:00
|
|
|
CLANG_INCLUDE="-I/usr/lib/clang/$CLANG_VERSION/include"
|
|
|
|
fi
|
2014-10-02 22:54:55 +00:00
|
|
|
pushd rocksdb-rocksdb-3.5
|
2014-10-08 03:44:58 +00:00
|
|
|
make static_lib CFLAGS="$CLANG_INCLUDE"
|
|
|
|
popd
|
2014-10-02 22:54:55 +00:00
|
|
|
fi
|
2014-09-25 07:27:07 +00:00
|
|
|
sudo cp rocksdb-rocksdb-3.5/librocksdb.a /usr/local/lib
|
2014-10-02 22:54:55 +00:00
|
|
|
sudo cp -R rocksdb-rocksdb-3.5/include/rocksdb /usr/local/include
|
|
|
|
elif [[ $OS = "darwin" ]]; then
|
|
|
|
if [[ ! -f rocksdb-rocksdb-3.5/librocksdb.a ]]; then
|
|
|
|
pushd rocksdb-rocksdb-3.5
|
|
|
|
make static_lib
|
|
|
|
popd
|
|
|
|
fi
|
2014-10-02 23:25:39 +00:00
|
|
|
sudo cp rocksdb-rocksdb-3.5/librocksdb.a /usr/local/lib
|
|
|
|
sudo cp -R rocksdb-rocksdb-3.5/include/rocksdb /usr/local/include
|
2014-10-02 22:54:55 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
log "rocksdb already installed. skipping."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_boost() {
|
|
|
|
if [[ ! -f /usr/local/lib/libboost_thread.a ]]; then
|
|
|
|
if [[ ! -f boost_1_55_0.tar.gz ]]; then
|
|
|
|
wget -O boost_1_55_0.tar.gz http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/download
|
2014-09-20 23:42:20 +00:00
|
|
|
else
|
2014-10-02 22:54:55 +00:00
|
|
|
log "boost source is already downloaded. skipping."
|
2014-09-20 23:42:20 +00:00
|
|
|
fi
|
2014-10-02 22:54:55 +00:00
|
|
|
if [[ ! -d boost_1_55_0 ]]; then
|
|
|
|
tar -xf boost_1_55_0.tar.gz
|
|
|
|
fi
|
|
|
|
pushd boost_1_55_0
|
|
|
|
./bootstrap.sh
|
2014-10-31 17:31:06 +00:00
|
|
|
n=`getconf _NPROCESSORS_ONLN`
|
2014-10-02 22:54:55 +00:00
|
|
|
sudo ./b2 --with=all -j $n toolset=clang install
|
|
|
|
sudo ldconfig
|
|
|
|
popd
|
|
|
|
else
|
|
|
|
log "boost library is already installed. skipping."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_gflags() {
|
|
|
|
if [[ ! -f /usr/local/lib/libgflags.a ]]; then
|
|
|
|
if [[ ! -f v2.1.1.tar.gz ]]; then
|
|
|
|
wget https://github.com/schuhschuh/gflags/archive/v2.1.1.tar.gz
|
2014-09-20 23:26:40 +00:00
|
|
|
else
|
2014-10-02 22:54:55 +00:00
|
|
|
log "gflags source is already downloaded. skipping."
|
2014-09-20 23:26:40 +00:00
|
|
|
fi
|
2014-10-02 22:54:55 +00:00
|
|
|
if [[ ! -d gflags-2.1.1 ]]; then
|
|
|
|
tar -xf v2.1.1.tar.gz
|
2014-09-20 23:36:04 +00:00
|
|
|
fi
|
2014-10-02 22:54:55 +00:00
|
|
|
pushd gflags-2.1.1
|
|
|
|
cmake -DCMAKE_CXX_FLAGS=-fPIC -DGFLAGS_NAMESPACE:STRING=google .
|
|
|
|
make
|
|
|
|
sudo make install
|
|
|
|
popd
|
|
|
|
else
|
|
|
|
log "gflags library is already installed. skipping."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_glog() {
|
|
|
|
if [[ ! -d /usr/local/include/glog ]]; then
|
|
|
|
if [[ ! -f glog-0.3.3.tar.gz ]]; then
|
|
|
|
wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz
|
2014-09-20 23:26:40 +00:00
|
|
|
else
|
2014-10-02 22:54:55 +00:00
|
|
|
log "glog source is already downloaded. skipping."
|
|
|
|
fi
|
|
|
|
if [[ ! -d glog-0.3.3 ]]; then
|
|
|
|
tar -xf glog-0.3.3.tar.gz
|
2014-09-20 23:26:40 +00:00
|
|
|
fi
|
2014-10-02 22:54:55 +00:00
|
|
|
pushd glog-0.3.3
|
|
|
|
./configure CXXFLAGS="-DGFLAGS_NAMESPACE=google"
|
|
|
|
make
|
|
|
|
sudo make install
|
|
|
|
popd
|
|
|
|
else
|
|
|
|
log "glog is already installed. skipping."
|
2014-09-17 08:22:14 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-10-08 03:44:58 +00:00
|
|
|
function install_autoconf() {
|
|
|
|
if [[ ! -f /usr/bin/autoconf ]]; then
|
|
|
|
if [[ ! -f autoconf-2.69.tar.gz ]]; then
|
|
|
|
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
|
|
|
|
else
|
|
|
|
log "autoconf is already downloaded. skipping."
|
|
|
|
fi
|
|
|
|
if [[ ! -d autoconf-2.69 ]]; then
|
|
|
|
tar -xf autoconf-2.69.tar.gz
|
|
|
|
fi
|
|
|
|
pushd autoconf-2.69
|
|
|
|
./configure --prefix=/usr
|
|
|
|
make
|
|
|
|
sudo make install
|
|
|
|
popd
|
|
|
|
else
|
|
|
|
log "autoconf is already installed. skipping."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_automake() {
|
|
|
|
if [[ ! -f /usr/bin/automake ]]; then
|
|
|
|
if [[ ! -f automake-1.14.tar.gz ]]; then
|
|
|
|
wget http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz
|
|
|
|
else
|
|
|
|
log "automake is already downloaded. skipping."
|
|
|
|
fi
|
|
|
|
if [[ ! -d automake-1.14 ]]; then
|
|
|
|
tar -xf automake-1.14.tar.gz
|
|
|
|
fi
|
|
|
|
pushd automake-1.14
|
|
|
|
./configure --prefix=/usr
|
|
|
|
make
|
|
|
|
sudo make install
|
|
|
|
popd
|
|
|
|
else
|
|
|
|
log "automake is already installed. skipping."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_libtool() {
|
|
|
|
if [[ ! -f /usr/bin/libtool ]]; then
|
|
|
|
if [[ ! -f libtool-2.4.2.tar.gz ]]; then
|
|
|
|
wget http://mirror.anl.gov/pub/gnu/libtool/libtool-2.4.2.tar.gz
|
|
|
|
else
|
|
|
|
log "libtool is already downloaded. skipping."
|
|
|
|
fi
|
|
|
|
if [[ ! -d libtool-2.4.2 ]]; then
|
|
|
|
tar -xf libtool-2.4.2.tar.gz
|
|
|
|
fi
|
|
|
|
pushd libtool-2.4.2
|
|
|
|
./configure --prefix=/usr
|
|
|
|
make
|
|
|
|
sudo make install
|
|
|
|
popd
|
|
|
|
else
|
|
|
|
log "libtool is already installed. skipping."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-09-17 08:22:14 +00:00
|
|
|
function package() {
|
|
|
|
if [[ $OS = "ubuntu" ]]; then
|
|
|
|
if dpkg --get-selections | grep --quiet $1; then
|
|
|
|
log "$1 is already installed. skipping."
|
|
|
|
else
|
2014-09-25 07:27:07 +00:00
|
|
|
sudo apt-get install $@ -y
|
2014-09-17 08:22:14 +00:00
|
|
|
fi
|
|
|
|
elif [[ $OS = "centos" ]]; then
|
|
|
|
if rpm -qa | grep --quiet $1; then
|
|
|
|
log "$1 is already installed. skipping."
|
|
|
|
else
|
2014-09-25 07:27:07 +00:00
|
|
|
sudo yum install $@ -y
|
2014-09-17 08:22:14 +00:00
|
|
|
fi
|
|
|
|
elif [[ $OS = "darwin" ]]; then
|
|
|
|
if brew list | grep --quiet $1; then
|
|
|
|
log "$1 is already installed. skipping."
|
|
|
|
else
|
|
|
|
brew install $@ || brew upgrade $@
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function main() {
|
|
|
|
platform OS
|
|
|
|
|
2014-10-30 19:59:10 +00:00
|
|
|
mkdir -p "$WORKING_DIR"
|
|
|
|
cd "$WORKING_DIR"
|
2014-09-17 08:22:14 +00:00
|
|
|
|
|
|
|
if [[ $OS = "centos" ]]; then
|
|
|
|
log "detected centos"
|
|
|
|
elif [[ $OS = "ubuntu" ]]; then
|
|
|
|
log "detected ubuntu"
|
2014-09-23 07:28:34 +00:00
|
|
|
DISTRO=`cat /etc/*-release | grep DISTRIB_CODENAME | awk '{split($0,bits,"="); print bits[2]}'`
|
2014-09-17 08:22:14 +00:00
|
|
|
elif [[ $OS = "darwin" ]]; then
|
|
|
|
log "detected mac os x"
|
|
|
|
else
|
|
|
|
fatal "could not detect the current operating system. exiting."
|
|
|
|
fi
|
|
|
|
|
2014-09-25 08:45:13 +00:00
|
|
|
threads THREADS
|
2014-09-17 08:22:14 +00:00
|
|
|
|
|
|
|
if [[ $OS = "ubuntu" ]]; then
|
2014-09-23 07:28:34 +00:00
|
|
|
|
|
|
|
if [[ $DISTRO = "precise" ]]; then
|
2014-10-03 00:48:45 +00:00
|
|
|
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
2014-09-23 07:28:34 +00:00
|
|
|
fi
|
2014-10-03 00:48:45 +00:00
|
|
|
sudo apt-get update
|
2014-09-17 08:22:14 +00:00
|
|
|
|
|
|
|
package git
|
|
|
|
package unzip
|
|
|
|
package build-essential
|
2014-10-02 17:58:56 +00:00
|
|
|
package libtool
|
|
|
|
package autoconf
|
|
|
|
package automake
|
|
|
|
package pkg-config
|
|
|
|
package libssl-dev
|
|
|
|
package liblzma-dev
|
|
|
|
package bison
|
|
|
|
package flex
|
|
|
|
package python-pip
|
|
|
|
package python-dev
|
|
|
|
package libbz2-dev
|
2014-10-02 22:54:55 +00:00
|
|
|
package devscripts
|
|
|
|
package debhelper
|
|
|
|
package clang-3.4
|
|
|
|
package clang-format-3.4
|
2014-10-29 10:38:21 +00:00
|
|
|
package librpm-dev
|
2014-10-02 22:54:55 +00:00
|
|
|
set_cc clang
|
|
|
|
set_cxx clang++
|
2014-11-02 09:33:11 +00:00
|
|
|
|
2014-10-02 17:58:56 +00:00
|
|
|
if [[ $DISTRO = "precise" ]]; then
|
|
|
|
package gcc-4.7
|
|
|
|
package g++-4.7
|
2014-10-03 00:48:45 +00:00
|
|
|
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 100 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7
|
2014-10-02 22:54:55 +00:00
|
|
|
install_boost
|
2014-10-02 17:58:56 +00:00
|
|
|
install_cmake
|
|
|
|
else
|
|
|
|
package cmake
|
|
|
|
package libboost1.55-all-dev
|
|
|
|
fi
|
2014-09-23 07:28:34 +00:00
|
|
|
if [[ $DISTRO = "precise" ]]; then
|
|
|
|
package libunwind7-dev
|
|
|
|
fi
|
2014-10-30 09:37:32 +00:00
|
|
|
if [[ $DISTRO = "trusty" || $DISTRO = "utopic" ]]; then
|
2014-09-23 07:28:34 +00:00
|
|
|
package libunwind8-dev
|
|
|
|
fi
|
|
|
|
if [[ $DISTRO = "precise" ]]; then
|
2014-10-02 22:54:55 +00:00
|
|
|
install_gflags
|
|
|
|
install_glog
|
2014-09-23 07:28:34 +00:00
|
|
|
else
|
|
|
|
package libgoogle-glog-dev
|
|
|
|
fi
|
2014-09-17 08:22:14 +00:00
|
|
|
package libsnappy-dev
|
|
|
|
package libbz2-dev
|
|
|
|
package libreadline-dev
|
2014-10-02 17:58:56 +00:00
|
|
|
if [[ $DISTRO = "precise" ]]; then
|
|
|
|
package libproc-dev
|
|
|
|
else
|
|
|
|
package libprocps3-dev
|
|
|
|
fi
|
2014-09-17 08:22:14 +00:00
|
|
|
install_thrift
|
|
|
|
install_rocksdb
|
2014-09-23 02:27:19 +00:00
|
|
|
|
2014-09-17 08:22:14 +00:00
|
|
|
elif [[ $OS = "centos" ]]; then
|
2014-09-25 07:27:07 +00:00
|
|
|
sudo yum update -y
|
2014-10-08 03:44:58 +00:00
|
|
|
|
2014-09-17 08:22:14 +00:00
|
|
|
package git-all
|
|
|
|
package unzip
|
|
|
|
package xz
|
2014-10-08 23:09:02 +00:00
|
|
|
package xz-devel
|
2014-10-08 03:44:58 +00:00
|
|
|
package epel-release.noarch
|
|
|
|
package python-pip.noarch
|
2014-10-08 23:09:02 +00:00
|
|
|
package python-devel
|
2014-10-08 03:44:58 +00:00
|
|
|
|
|
|
|
pushd /etc/yum.repos.d
|
|
|
|
if [[ ! -f /etc/yum.repos.d/devtools-2.repo ]]; then
|
|
|
|
wget http://people.centos.org/tru/devtools-2/devtools-2.repo
|
|
|
|
fi
|
|
|
|
|
|
|
|
package devtoolset-2-gcc
|
|
|
|
package devtoolset-2-binutils
|
|
|
|
package devtoolset-2-gcc-c++
|
|
|
|
export CC=/opt/rh/devtoolset-2/root/usr/bin/gcc
|
|
|
|
export CPP=/opt/rh/devtoolset-2/root/usr/bin/cpp
|
|
|
|
export CXX=/opt/rh/devtoolset-2/root/usr/bin/c++
|
|
|
|
source /opt/rh/devtoolset-2/enable
|
|
|
|
if [[ ! -d /usr/lib/gcc ]]; then
|
|
|
|
ln -s /opt/rh/devtoolset-2/root/usr/lib/gcc /usr/lib/
|
|
|
|
fi
|
|
|
|
popd
|
|
|
|
|
2014-10-08 23:09:02 +00:00
|
|
|
package cmake28
|
2014-10-08 03:44:58 +00:00
|
|
|
if [[ ! -f /usr/bin/cmake ]]; then
|
|
|
|
ln -s /usr/bin/cmake28 /usr/bin/cmake
|
|
|
|
fi
|
|
|
|
if [[ ! -f /usr/bin/ccmake ]]; then
|
|
|
|
ln -s /usr/bin/ccmake28 /usr/bin/ccmake
|
|
|
|
fi
|
|
|
|
|
2014-10-08 23:09:02 +00:00
|
|
|
package clang
|
|
|
|
package clang-devel
|
2014-10-08 03:44:58 +00:00
|
|
|
|
|
|
|
set_cc clang
|
|
|
|
set_cxx clang++
|
|
|
|
|
2014-10-08 23:09:02 +00:00
|
|
|
package bzip2
|
|
|
|
package bzip2-devel
|
|
|
|
package openssl-devel
|
|
|
|
package readline-devel
|
|
|
|
package procps-devel
|
2014-11-02 09:33:11 +00:00
|
|
|
package rpm-devel
|
2014-10-08 03:44:58 +00:00
|
|
|
|
|
|
|
install_boost
|
|
|
|
install_gflags
|
|
|
|
install_glog
|
2014-10-08 23:09:02 +00:00
|
|
|
package doxygen
|
|
|
|
package snappy
|
|
|
|
package snappy-devel
|
|
|
|
package byacc
|
|
|
|
package flex
|
|
|
|
package bison
|
|
|
|
package libunwind
|
|
|
|
package libunwind-devel
|
2014-10-08 03:44:58 +00:00
|
|
|
|
|
|
|
# One day, CentOS packages will be updated and installing from yum will not fuck things up
|
|
|
|
# Until that day comes, leave these lines commented and keep installing from source
|
|
|
|
# package libtool.x86_64
|
|
|
|
# package boost.x86_64
|
|
|
|
|
|
|
|
install_autoconf
|
|
|
|
install_automake
|
|
|
|
install_libtool
|
|
|
|
install_thrift
|
|
|
|
set_cc gcc
|
|
|
|
set_cxx g++
|
|
|
|
install_rocksdb
|
2014-09-17 08:22:14 +00:00
|
|
|
|
|
|
|
elif [[ $OS = "darwin" ]]; then
|
2014-10-29 20:52:37 +00:00
|
|
|
type brew >/dev/null 2>&1 || {
|
|
|
|
echo >&2 "could not find homebrew. please install it from http://brew.sh/";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
2014-10-08 04:11:50 +00:00
|
|
|
brew update
|
|
|
|
|
|
|
|
package rocksdb
|
2014-09-17 08:22:14 +00:00
|
|
|
package cmake
|
2014-10-08 04:11:50 +00:00
|
|
|
package boost
|
2014-09-17 08:22:14 +00:00
|
|
|
package gflags
|
|
|
|
package glog
|
|
|
|
package thrift
|
|
|
|
fi
|
|
|
|
|
2014-10-30 19:59:10 +00:00
|
|
|
cd "$SCRIPT_DIR/../"
|
2014-09-24 20:07:28 +00:00
|
|
|
sudo pip install -r requirements.txt
|
2014-09-24 04:22:42 +00:00
|
|
|
git submodule init
|
|
|
|
git submodule update
|
2014-09-17 08:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main
|