hanoidb/enable-lsm_btree
Kresten Krab Thorup 4b91c71781 Invoke local rebar
Some of us doesn't have rebar on the general path
2012-04-18 09:26:21 +02:00

60 lines
1.9 KiB
Bash
Executable file

#!/bin/sh
# This script adds lsm_btree to a riak github repo. Run it in the riak repo
# directory.
#
# First it adds lsm_btree, then runs "make all devrel" and then enables the
# lsm_btree storage backend in the resulting dev nodes.
#
# This script is intended to be temporary. Once lsm_btree is made into a proper
# riak citizen, this script will no longer be needed.
set -e
wd=`pwd`
if [ `basename $wd` != riak ]; then
echo "This doesn't appear to be a riak repo directory. Exiting."
exit 1
fi
if [ -d dev ]; then
echo
echo 'NOTE: THIS SCRIPT WILL DELETE YOUR EXISTING DEV DIRECTORY!'
while [ 1 ]; do
printf '\n%s' ' Do you wish to proceed? [no] '
read answer
answer=${answer:-n}
case $answer in
[Nn]*) exit 0 ;;
[Yy]*) break ;;
*) echo 'Please answer y or n.' ;;
esac
done
fi
./rebar get-deps
file=./deps/riak_kv/src/riak_kv.app.src
if ! grep -q lsm_btree $file ; then
echo
echo "Modifying $file, saving the original as ${file}.orig ..."
perl -i.orig -pe '/\bos_mon,/ && print qq( lsm_btree,\n)' $file
fi
file=./deps/riak_kv/rebar.config
if ! grep -q lsm_btree $file ; then
echo
echo "Modifying $file, saving the original as ${file}.orig ..."
perl -i.orig -pe '/\bsext\b/ && print qq( {lsm_btree, ".*", {git, "git\@github.com:basho/lsm_btree.git", "master"}},\n)' $file
fi
./rebar get-deps
rm -rf dev
make all devrel
echo
echo 'Modifying all dev/dev*/etc/app.config files, saving originals with .orig suffix...'
perl -i.orig -ne 'if (/\bstorage_backend,/) { s/(storage_backend, )[^\}]+/\1riak_kv_lsm_btree_backend/; print } elsif (/\{eleveldb,/) { $eleveldb++; print } elsif ($eleveldb && /^\s+\]\},/) { $eleveldb = 0; print; print qq(\n {lsm_btree, [\n {data_root, "./data/lsm_btree"}\n ]},\n\n) } else { print }' dev/dev*/etc/app.config
exit 0