Create a gist now

Instantly share code, notes, and snippets.

Install Thrift 0.9.1 with all language support
# Set these to apache/thrift, 0.9.1 for official 0.9.1 Thrift release.
# 1.0.0 will not compile on Trusty because of an old automake version.
# 1.0.0 requires automake at least 1.13
THRIFT_REPO=apache/thrift
THRIFT_BRANCH=0.9.1
THRIFT_REPO=radekg/thrift
THRIFT_BRANCH=dev-rust-thrift
INSTALL_C_GLIB=no
INSTALL_RUBY=yes
INSTALL_PYTHON=yes
INSTALL_MONO=no
INSTALL_OPENJDK=no
INSTALL_HASKELL=no
INSTALL_PHP=no
INSTALL_NODEJS=no
INSTALL_ERLANG=no
INSTALL_LUA=no
INSTALL_GO=no
INSTALL_D=no
INSTALL_RUST=yes
# Missing support for:
# INSTALL_QT4=no
# INSTALL_HAXE=no
WORKING_DIR=$(pwd)/thrift-src
FORCE_THRIFT_MAKE=yes
# -----------------------------------------------------------------------------
# Base build dependencies
# -----------------------------------------------------------------------------
echo ""
echo " ==> Installing Base build dependencies..."
apt-get update -y
apt-get install python-software-properties -y
apt-get install -y curl git-core build-essential \
libboost-dev libboost-test-dev libboost-program-options-dev \
libevent-dev automake libtool flex bison pkg-config g++ libssl-dev \
libbit-vector-perl
# -----------------------------------------------------------------------------
# Language libraries:
# -----------------------------------------------------------------------------
if [ "$INSTALL_C_GLIB" = "yes" ]; then
echo ""
echo " ==> Installing C GLib dependencies..."
apt-get install -y libglib2.0-dev
fi
if [ "$INSTALL_PYTHON" = "yes" ]; then
echo ""
echo " ==> Installing Python dependencies..."
apt-get install -y python-dev python-twisted
fi
if [ "$INSTALL_RUBY" = "yes" ]; then
echo ""
echo " ==> Installing Ruby dependencies..."
if [ "$(lsb_release -sc)" = "precise" ]; then
apt-get install -y ruby-dev librspec-ruby rake rubygems
elif [ "$(lsb_release -sc)" = "trusty" ]; then
apt-get install -y ruby-full ruby-dev rake rubygems-integration
fi
BUNDLER_V=1.3.1
if [ -z "$(gem list bundler | grep 'bundler (${BUNDLER_V})')" ]; then
echo " ==> GEM bundler ${BUNDLER_V}..."
gem install bundler --version "=${BUNDLER_V}" --no-ri --no-rdoc
fi
fi
if [ "$INSTALL_MONO" = "yes" ]; then
echo ""
echo " ==> Installing Mono (C#) dependencies..."
apt-get install -y mono-gmcs libmono-2.0-1 mono-devel
fi
if [ "$INSTALL_OPENJDK" = "yes" ]; then
echo ""
echo " ==> Installing OpenJDK 6 dependencies..."
apt-get install -y openjdk-6-jdk maven2
fi
if [ "$INSTALL_HASKELL" = "yes" ]; then
echo ""
echo " ==> Installing Haskell and updating Cabal dependencies..."
if [ "$(lsb_release -sc)" = "precise" ]; then
apt-get install -y ghc6 cabal-install libghc6-binary-dev libghc6-network-dev libghc6-http-dev
elif [ "$(lsb_release -sc)" = "trusty" ]; then
if [ -z "$(cat /etc/apt/sources.list | grep 'deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe')"]; then
add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"
fi
apt-get update -y
apt-get install -y haskell-platform
fi
# for Haskell, install dependencies
cabal update
cabal install hashable --global
cabal install unordered-containers --global
cabal install vector --global
fi
if [ "$INSTALL_PHP" = "yes" ]; then
echo ""
echo " ==> Installing PHP5 dependencies..."
apt-get install -y php5 php5-dev
fi
if [ "$INSTALL_NODEJS" = "yes" ]; then
echo ""
echo " ==> Installing Node.js dependencies..."
apt-get install -y nodejs
fi
if [ "$INSTALL_ERLANG" = "yes" ]; then
echo ""
echo " ==> Installing Erlang dependencies..."
apt-get install -y erlang
fi
if [ "$INSTALL_LUA" = "yes" ]; then
echo ""
echo " ==> Installing Lua dependencies..."
apt-get install -y liblua5.1-0-dev liblua50-dev liblualib50-dev
fi
if [ "$INSTALL_GO" = "yes" ]; then
echo ""
echo " ==> Installing Go dependencies..."
if [ "$(lsb_release -sc)" = "precise" ]; then
add-apt-repository ppa:duh/golang -y
apt-get update -y
apt-get install -y golang
elif [ "$(lsb_release -sc)" = "trusty" ]; then
apt-get install -y golang-go
fi
fi
if [ "$INSTALL_D" = "yes" ]; then
echo ""
echo " ==> Installing D dependencies..."
apt-get install -y gdc
fi
if [ "$INSTALL_RUST" = "yes" ]; then
echo ""
echo " ==> Installing Rust dependencies..."
if [ -z "$(rustc -V)" ]; then
mkdir -p /tmp/rustup
cd /tmp/rustup
curl https://static.rust-lang.org/rustup.sh >> rustup.sh
chmod +x rustup.sh
./rustup.sh -y
cd /
rm -Rf /tmp/rustup
else
echo " ==> Rust found: $(rustc -V)"
echo " + rustc: $(which rustc)"
echo " + cargo: $(which cargo)"
fi
fi
# -----------------------------------------------------------------------------
# Thrift source setup
# -----------------------------------------------------------------------------
mkdir -p $WORKING_DIR && cd $WORKING_DIR
if [ ! -d $WORKING_DIR/.git ]; then
echo ""
echo " ==> Cloning Thrift from https://github.com/${THRIFT_REPO}.git#${THRIFT_BRANCH}..."
git clone https://github.com/$THRIFT_REPO.git .
git fetch origin
git checkout -b $THRIFT_BRANCH origin/$THRIFT_BRANCH
else
echo ""
echo " ==> Pulling Thrift changes from https://github.com/${THRIFT_REPO}.git#${THRIFT_BRANCH}..."
git pull origin $THRIFT_BRANCH
fi
# -----------------------------------------------------------------------------
# Thrift installation
# -----------------------------------------------------------------------------
if [ -z "$(thrift -version)" ]; then
echo ""
echo " ==> Thrift: bootstrap and configure..."
./bootstrap.sh || exit 1
./configure --with-boost=/usr/local || exit 1
fi
if [[ -z "$(thrift -version)" || "$(FORCE_THRIFT_MAKE)" = "yes" ]]; then
make || exit 1
make install || exit 1
fi
@radekg
Owner
radekg commented May 29, 2015

Updated for ubuntu 14.04. Add Lua and NodeJS.

@radekg
Owner
radekg commented May 31, 2015

Another update; changing the structure to make the language selection more atomic. The program now covers ubuntu 12 and 14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment