Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 74 lines (70 sloc) 2.72 KB
#!/bin/bash
echo "===> Running post_compile hook for generating Riak release"
# check if target files are already there and only generate release if there the files are NOT there
if [ -z $REBAR_PROFILE ]; then
TARGET_DIR="priv/bin/default"
else
TARGET_DIR="priv/bin/$REBAR_PROFILE"
fi
BIN_RIAK_ADMIN="$TARGET_DIR/riak-admin"
BIN_RIAK_DEBUG="$TARGET_DIR/riak-debug"
BIN_RIAK_SEARCH="$TARGET_DIR/search-cmd"
if [ -f $BIN_RIAK_ADMIN ] && [ -f $BIN_RIAK_DEBUG ] && [ -f $BIN_RIAK_SEARCH ]; then
echo "===> Binary release artefacts found, skipping release generation."
exit 0
fi
# artefacts are not present in the target directory
CWD=$(pwd)
OLD_DEPS_DIR=$REBAR_DEPS_DIR
OLD_BUILD_DIR=$REBAR_BUILD_DIR
echo "REBAR_PROFILE = $REBAR_PROFILE"
echo "REBAR_DEPS_DIR = $REBAR_DEPS_DIR"
echo "REBAR_BUILD_DIR = $REBAR_BUILD_DIR"
echo "REBAR_ROOT_DIR = $REBAR_ROOT_DIR"
echo "REBAR_CHECKOUTS_DIR = $REBAR_CHECKOUTS_DIR"
echo "REBAR_PLUGINS_DIR = $REBAR_PLUGINS_DIR"
echo "REBAR_GLOBAL_CONFIG_DIR = $REBAR_GLOBAL_CONFIG_DIR"
echo "REBAR_GLOBAL_CACHE_DIR = $REBAR_GLOBAL_CACHE_DIR"
echo "REBAR_TEMPLATE_DIR = $REBAR_TEMPLATE_DIR"
echo "REBAR_APP_DIRS = $REBAR_APP_DIRS"
echo "REBAR_SRC_DIRS = $REBAR_SRC_DIRS"
echo "ERLANG_ERTS_VER = $ERLANG_ERTS_VER"
echo "ERLANG_ROOT_DIR = $ERLANG_ROOT_DIR"
echo "ERL = $ERL"
echo "ERLC = $ERLC"
echo "ERLANG_ARCH = $ERLANG_ARCH"
echo "ERLANG_TARGET = $ERLANG_TARGET"
echo "Post compile hook: Generating druuid artefacts..."
cd $REBAR_DEPS_DIR/druuid
if make ; then
echo "Post compile hook: druuid artefacts generated."
fi
cd -
echo "Post compile hook: Changing directory into Riak dependency..."
echo $REBAR_DEPS_DIR > $REBAR_BUILD_DIR/../../priv/.rebar_deps_dir
cd $REBAR_DEPS_DIR/riak
echo "Post compile hook: Working from $(pwd)..."
echo "Post compile hook: Set REBAR_DEPS_DIR to $(pwd)/deps"
echo "Post compile hook: Set REBAR_BUILD_DIR to $(pwd)/rel"
REBAR_DEPS_DIR=$(pwd)/deps
REBAR_BUILD_DIR=$(pwd)/rel
echo "Post compile hook: Generating manual Riak release..."
make all devrel
if [ $? -eq 0 ]; then
echo "Post compile hook: Done generating release."
cd $CWD
echo "Post compile hook: Copying artefacts to shared directory..."
# now there are several devrels created in a subfolder, each containing a copy of the riak executables
# we need to copy the executables elsewhere, so just copy from first devrel (dev1)
DEVREL=dev1
if [ -z $REBAR_PROFILE ]; then
mkdir -p priv/bin/default
cp _build/default/lib/riak/dev/$DEVREL/bin/* priv/bin/default/
else
mkdir -p priv/bin/$REBAR_PROFILE
cp _build/$REBAR_PROFILE/lib/riak/dev/$DEVREL/bin/* priv/bin/$REBAR_PROFILE/
fi
echo "Post compile hook: Success!"
fi
REBAR_DEPS_DIR=$OLD_DEPS_DIR
REBAR_BUILD_DIR=$OLD_BUILD_DIR