2012-11-07 20:41:26 +00:00
|
|
|
#!/usr/bin/env bash
|
2012-07-23 22:39:43 +00:00
|
|
|
|
2015-07-21 19:31:19 +00:00
|
|
|
# You need to use this script once to build a set of stagedevrels for prior
|
2012-09-17 21:14:55 +00:00
|
|
|
# releases of Riak (for mixed version / upgrade testing). You should
|
2012-07-23 22:39:43 +00:00
|
|
|
# create a directory and then run this script from within that directory.
|
|
|
|
# I have ~/test-releases that I created once, and then re-use for testing.
|
|
|
|
#
|
2012-07-23 22:45:08 +00:00
|
|
|
# See rtdev-setup-releases.sh as an example of setting up mixed version layout
|
2012-07-23 22:39:43 +00:00
|
|
|
# for testing.
|
|
|
|
|
|
|
|
# Different versions of Riak were released using different Erlang versions,
|
|
|
|
# make sure to build with the appropriate version.
|
|
|
|
|
|
|
|
# This is based on my usage of having multiple Erlang versions in different
|
|
|
|
# directories. If using kerl or whatever, modify to use kerl's activate logic.
|
|
|
|
# Or, alternatively, just substitute the paths to the kerl install paths as
|
|
|
|
# that should work too.
|
|
|
|
|
2014-09-16 20:12:55 +00:00
|
|
|
: ${R15B01:=$HOME/erlang-R15B01}
|
|
|
|
: ${R16B02:=$HOME/erlang-R16B02}
|
|
|
|
|
2015-08-03 19:41:28 +00:00
|
|
|
# These are the default tags to use when building basho OTP releases.
|
|
|
|
# Export different tags to get a different build. N.B. You will need to
|
|
|
|
# remove the builds from kerl (e.g., kerl delete build $BUILDNAME) and
|
|
|
|
# possibly remove the directories above.
|
|
|
|
: ${R16_TAG:="OTP_R16B02_basho9"}
|
|
|
|
: ${R15_TAG:="basho_OTP_R15B01p"}
|
|
|
|
|
2014-09-16 20:12:55 +00:00
|
|
|
# By default the Open Source version of Riak will be used, but for internal
|
|
|
|
# testing you can override this variable to use `riak_ee` instead
|
|
|
|
: ${RT_USE_EE:=""}
|
|
|
|
GITURL_RIAK="git://github.com/basho/riak"
|
|
|
|
GITURL_RIAK_EE="git@github.com:basho/riak_ee"
|
2015-07-31 21:23:40 +00:00
|
|
|
GITDIR="riak-src"
|
2014-09-16 20:12:55 +00:00
|
|
|
|
2012-07-24 01:35:38 +00:00
|
|
|
|
2012-08-21 18:32:48 +00:00
|
|
|
checkbuild()
|
|
|
|
{
|
|
|
|
ERLROOT=$1
|
2012-09-17 21:14:55 +00:00
|
|
|
|
2012-08-21 18:32:48 +00:00
|
|
|
if [ ! -d $ERLROOT ]; then
|
2012-09-17 21:14:55 +00:00
|
|
|
echo -n " - $ERLROOT cannot be found, install with kerl? [Y|n]: "
|
2012-08-21 18:32:48 +00:00
|
|
|
read ans
|
|
|
|
if [[ $ans == n || $ans == N ]]; then
|
2012-09-17 21:14:55 +00:00
|
|
|
echo
|
|
|
|
echo " [ERROR] Can't build $ERLROOT without kerl, aborting!"
|
2012-08-21 18:32:48 +00:00
|
|
|
exit 1
|
2012-09-17 21:14:55 +00:00
|
|
|
else
|
|
|
|
if [ ! -x kerl ]; then
|
|
|
|
echo " - Fetching kerl."
|
2013-01-14 17:23:50 +00:00
|
|
|
if [ ! `which curl` ]; then
|
|
|
|
echo "You need 'curl' to be able to run this script, exiting"
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-07-30 15:39:22 +00:00
|
|
|
curl -O https://raw.githubusercontent.com/spawngrid/kerl/master/kerl > /dev/null 2>&1; chmod a+x kerl
|
2012-09-17 21:14:55 +00:00
|
|
|
fi
|
2012-08-21 18:32:48 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-07-24 01:35:38 +00:00
|
|
|
kerl()
|
|
|
|
{
|
|
|
|
RELEASE=$1
|
|
|
|
BUILDNAME=$2
|
|
|
|
|
2015-08-03 19:10:30 +00:00
|
|
|
export CFLAGS="-g -O2"
|
|
|
|
export LDFLAGS="-g"
|
|
|
|
if [ -n "`uname -r | grep el6`" ]; then
|
|
|
|
export CFLAGS="-g -DOPENSSL_NO_EC=1"
|
|
|
|
fi
|
2015-08-01 02:09:48 +00:00
|
|
|
BUILDFLAGS="--disable-hipe --enable-smp-support --without-odbc"
|
|
|
|
if [ $(uname -s) = "Darwin" ]; then
|
2015-08-03 19:10:30 +00:00
|
|
|
export CFLAGS="-g -O0"
|
2015-08-01 02:09:48 +00:00
|
|
|
BUILDFLAGS="$BUILDFLAGS --enable-darwin-64bit --with-dynamic-trace=dtrace"
|
|
|
|
else
|
|
|
|
BUILDFLAGS="$BUILDFLAGS --enable-m64-build"
|
2015-07-30 22:10:16 +00:00
|
|
|
fi
|
|
|
|
|
2015-08-01 02:09:48 +00:00
|
|
|
KERL_ENV="KERL_CONFIGURE_OPTIONS=${BUILDFLAGS}"
|
|
|
|
MAKE="make -j10"
|
|
|
|
|
2012-09-17 21:14:55 +00:00
|
|
|
echo " - Building Erlang $RELEASE (this could take a while)"
|
2015-08-03 19:10:30 +00:00
|
|
|
# Use the Basho-patched version of Erlang
|
|
|
|
if [ "$RELEASE" == "R15B01" ]; then
|
2015-08-03 19:41:28 +00:00
|
|
|
BUILD_CMD="./kerl build git git://github.com/basho/otp.git $R15_TAG $BUILDNAME"
|
2015-08-03 19:10:30 +00:00
|
|
|
elif [ "$RELEASE" == "R16B02" ]; then
|
2015-08-03 19:41:28 +00:00
|
|
|
BUILD_CMD="./kerl build git git://github.com/basho/otp.git $R16_TAG $BUILDNAME"
|
2015-08-03 19:10:30 +00:00
|
|
|
else
|
2015-08-03 19:41:28 +00:00
|
|
|
BUILD_CMD="./kerl build $RELEASE $BUILDNAME"
|
2015-08-03 19:10:30 +00:00
|
|
|
fi
|
2015-08-03 19:41:28 +00:00
|
|
|
env "$KERL_ENV" "MAKE=$MAKE" $BUILD_CMD
|
2013-03-20 16:25:20 +00:00
|
|
|
RES=$?
|
2013-02-20 20:42:29 +00:00
|
|
|
if [ "$RES" -ne 0 ]; then
|
|
|
|
echo "[ERROR] Kerl build $BUILDNAME failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-09-17 21:14:55 +00:00
|
|
|
echo " - Installing $RELEASE into $HOME/$BUILDNAME"
|
2015-08-03 19:41:28 +00:00
|
|
|
./kerl install $BUILDNAME "$HOME/$BUILDNAME" > /dev/null 2>&1
|
2013-03-20 16:25:20 +00:00
|
|
|
RES=$?
|
2013-02-20 20:42:29 +00:00
|
|
|
if [ "$RES" -ne 0 ]; then
|
|
|
|
echo "[ERROR] Kerl install $BUILDNAME failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-07-24 01:35:38 +00:00
|
|
|
}
|
2012-07-23 22:39:43 +00:00
|
|
|
|
|
|
|
build()
|
|
|
|
{
|
|
|
|
SRCDIR=$1
|
|
|
|
ERLROOT=$2
|
2014-09-16 20:12:55 +00:00
|
|
|
TAG="$3"
|
2015-07-31 21:23:40 +00:00
|
|
|
if [ -z $4 ]; then
|
2015-08-03 19:10:30 +00:00
|
|
|
LOCKED_DEPS=true
|
2015-07-31 21:23:40 +00:00
|
|
|
else
|
2015-08-03 19:10:30 +00:00
|
|
|
LOCKED_DEPS=$4
|
2015-07-31 21:23:40 +00:00
|
|
|
fi
|
|
|
|
|
2014-09-16 20:12:55 +00:00
|
|
|
if [ -z "$RT_USE_EE" ]; then
|
|
|
|
GITURL=$GITURL_RIAK
|
|
|
|
GITTAG=riak-$TAG
|
|
|
|
else
|
|
|
|
GITURL=$GITURL_RIAK_EE
|
|
|
|
GITTAG=riak_ee-$TAG
|
|
|
|
fi
|
2012-07-23 22:39:43 +00:00
|
|
|
|
2015-07-31 21:23:40 +00:00
|
|
|
echo "Getting sources from github"
|
|
|
|
if [ ! -d $GITDIR ]; then
|
|
|
|
git clone $GITURL $GITDIR
|
|
|
|
else
|
|
|
|
cd $GITDIR
|
2015-08-03 19:10:30 +00:00
|
|
|
git pull origin develop
|
2015-07-31 21:23:40 +00:00
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
2012-09-17 21:14:55 +00:00
|
|
|
echo "Building $SRCDIR:"
|
|
|
|
|
|
|
|
checkbuild $ERLROOT
|
2012-07-24 01:35:38 +00:00
|
|
|
if [ ! -d $ERLROOT ]; then
|
2012-08-21 18:32:48 +00:00
|
|
|
BUILDNAME=`basename $ERLROOT`
|
|
|
|
RELEASE=`echo $BUILDNAME | awk -F- '{ print $2 }'`
|
|
|
|
kerl $RELEASE $BUILDNAME
|
2012-07-24 01:35:38 +00:00
|
|
|
fi
|
|
|
|
|
2015-07-31 21:23:40 +00:00
|
|
|
if [ ! -d $SRCDIR ]
|
|
|
|
then
|
|
|
|
GITRES=1
|
|
|
|
echo " - Cloning $GITURL"
|
|
|
|
git clone $GITDIR $SRCDIR
|
2014-09-16 20:12:55 +00:00
|
|
|
GITRES=$?
|
2015-07-31 21:23:40 +00:00
|
|
|
if [ $GITRES -eq 0 -a -n "$TAG" ]; then
|
|
|
|
cd $SRCDIR
|
|
|
|
git checkout $GITTAG
|
|
|
|
GITRES=$?
|
|
|
|
cd ..
|
|
|
|
fi
|
2012-09-17 21:14:55 +00:00
|
|
|
fi
|
|
|
|
|
2015-07-31 21:23:40 +00:00
|
|
|
if [ ! -f "$SRCDIR/built" ]
|
|
|
|
then
|
|
|
|
|
|
|
|
RUN="env PATH=$ERLROOT/bin:$ERLROOT/lib/erlang/bin:$PATH \
|
2012-07-23 22:39:43 +00:00
|
|
|
C_INCLUDE_PATH=$ERLROOT/usr/include \
|
|
|
|
LD_LIBRARY_PATH=$ERLROOT/usr/lib"
|
2014-09-16 20:12:55 +00:00
|
|
|
|
2015-07-31 21:23:40 +00:00
|
|
|
echo " - Building devrel in $SRCDIR (this could take a while)"
|
|
|
|
cd $SRCDIR
|
2014-09-16 20:12:55 +00:00
|
|
|
|
2015-08-03 19:10:30 +00:00
|
|
|
if $LOCKED_DEPS
|
2015-07-31 21:23:40 +00:00
|
|
|
then
|
|
|
|
CMD="make locked-deps devrel"
|
|
|
|
else
|
|
|
|
CMD="make all devrel"
|
|
|
|
fi
|
|
|
|
|
|
|
|
$RUN $CMD
|
|
|
|
RES=$?
|
|
|
|
if [ "$RES" -ne 0 ]; then
|
|
|
|
echo "[ERROR] make devrel failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
touch built
|
|
|
|
cd ..
|
|
|
|
echo " - $SRCDIR built."
|
|
|
|
else
|
|
|
|
echo " - already built"
|
2013-02-20 20:42:29 +00:00
|
|
|
fi
|
2012-07-23 22:39:43 +00:00
|
|
|
}
|
|
|
|
|
2015-07-31 21:23:40 +00:00
|
|
|
build "riak-1.4.12" $R15B01 1.4.12 false
|
2015-06-01 18:49:52 +00:00
|
|
|
build "riak-2.0.2" $R16B02 2.0.2
|
|
|
|
build "riak-2.0.4" $R16B02 2.0.4
|
2015-08-04 02:42:01 +00:00
|
|
|
build "riak-2.0.6" $R16B02 2.0.6
|
2013-02-28 21:39:37 +00:00
|
|
|
echo
|