Skip to content

Commit 7e3661a

Browse files
author
Andrei Zavada
committed
refactor and repair release assembly
* resuscitate riak-chkconfig; * make `make rel` relocatable again, fix riak-debug for it; * remove runner_* substitution vars in all rel/**/vars.config;
1 parent debd415 commit 7e3661a

11 files changed

+196
-152
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ test : testclean eunit test-deps
7676
rel: compile
7777
@$(REBAR) as rel release
7878
# freebsd tar won't write to stdout, so
79-
@tar -c -f rel.tar --exclude '*/.git/*' -C _build/rel/rel riak && tar -x -f rel.tar -C rel && rm rel.tar
79+
@tar -c -f rel.tar --exclude-vcs -C _build/rel/rel riak && tar -x -f rel.tar -C rel && rm rel.tar
8080

8181
rel-rpm: compile
8282
@$(REBAR) as rpm release
83-
@tar --exclude='*/.git/*' -c -C _build/rpm/rel riak | tar -x -C rel
83+
@tar --exclude-vcs -c -C _build/rpm/rel riak | tar -x -C rel
8484

8585
rel-deb: compile
8686
@$(REBAR) as deb release
87-
@tar --exclude='*/.git/*' -c -C _build/deb/rel riak | tar -x -C rel
87+
@tar --exclude=vcs -c -C _build/deb/rel riak | tar -x -C rel
8888

8989
rel-osx: compile
9090
@$(REBAR) as osx release

rel/files/riak

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
RUNNER_GEN_DIR={{platform_gen_dir}}
44
RELX_RIAK={{platform_bin_dir}}/riak
5-
PID_DIR={{pid_dir}}
6-
PIPE_DIR={{pipe_dir}}/ # terminating / (relx treats it as a prefix)
5+
export PID_DIR={{pid_dir}}
6+
export PIPE_DIR={{pipe_dir}}/ # terminating / (relx treats it as a prefix)
77

88
mkdir -p $PID_DIR $PIPE_DIR
99
chown riak:riak $PID_DIR $PIPE_DIR
@@ -53,12 +53,12 @@ function maybe_su {
5353

5454
case "$1" in
5555
start)
56-
maybe_su $RELX_RIAK $* -pa {{runner_patch_dir}} \
56+
maybe_su $RELX_RIAK $* -pa {{platform_patch_dir}} \
5757
&& write_pid_file
5858
test -r $PID_DIR/riak.pid && exit 0
5959
;;
6060
console|foreground)
61-
maybe_su $RELX_RIAK $* -pa {{runner_patch_dir}}
61+
maybe_su $RELX_RIAK $* -pa {{platform_patch_dir}}
6262
;;
6363
stop)
6464
maybe_su $RELX_RIAK $* \
@@ -68,6 +68,10 @@ case "$1" in
6868
shift
6969
maybe_su `which riak-admin` $*
7070
;;
71+
chkconfig)
72+
shift
73+
maybe_su `which riak-chkconfig` $*
74+
;;
7175
repl)
7276
shift
7377
maybe_su `which riak-repl` $*

rel/files/riak-admin

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,35 @@
55
# Identify the script name
66
SCRIPT="riak-admin"
77

8-
RPC_HOP="{{platform_bin_dir}}/riak rpc"
8+
PLATFORM_BASE_DIR={{platform_base_dir}}
9+
PLATFORM_BASE_DIR=${PLATFORM_BASE_DIR:-$(cd $(dirname "$0")/.. && pwd -P)}
10+
11+
PLATFORM_BIN_DIR={{platform_bin_dir}}
12+
if [ "$PLATFORM_BIN_DIR" = "${PLATFORM_BIN_DIR#/}" ]; then
13+
PLATFORM_BIN_DIR=$PLATFORM_BASE_DIR/$PLATFORM_BIN_DIR
14+
fi
15+
16+
RPC_HOP="${PLATFORM_BIN_DIR}/riak rpc"
17+
RPCt_HOP="${PLATFORM_BIN_DIR}/riak rpcterms"
18+
19+
PLATFORM_ETC_DIR={{platform_etc_dir}}
20+
if [ "$PLATFORM_ETC_DIR" = "${PLATFORM_ETC_DIR#/}" ]; then
21+
PLATFORM_ETC_DIR=$PLATFORM_BASE_DIR/$PLATFORM_ETC_DIR
22+
fi
23+
24+
PLATFORM_PATCH_DIR={{platform_patch_dir}}
25+
if [ "$PLATFORM_PATCH_DIR" = "${PLATFORM_PATCH_DIR#/}" ]; then
26+
PLATFORM_PATCH_DIR=$PLATFORM_BASE_DIR/$PLATFORM_PATCH_DIR
27+
fi
28+
29+
ERTS_VER=$(cd ${PLATFORM_BASE_DIR} && ls -d erts-*)
30+
ERTS_PATH="${PLATFORM_BASE_DIR}/$ERTS_VER/bin"
31+
COOKIE=`egrep '^[ \t]*distributed_cookie[ \t]*=[ \t]*' $PLATFORM_ETC_DIR/riak.conf 2> /dev/null | cut -d = -f 2 | tr -d ' '`
932

10-
ERTS_PATH="{{runner_base_dir}}/`(cd {{runner_base_dir}} && ls -d erts-*)`/bin"
11-
COOKIE=`egrep '^[ \t]*distributed_cookie[ \t]*=[ \t]*' {{platform_etc_dir}}/riak.conf 2> /dev/null | cut -d = -f 2 | tr -d ' '`
1233
NODE={{node}}
1334
HOST=${NODE#*@}
1435

15-
BOOT_FILE="{{runner_base_dir}}/releases/{{rel_vsn}}/start_clean"
36+
BOOT_FILE="${PLATFORM_BASE_DIR}/releases/{{release_version}}/start_clean"
1637

1738
usage() {
1839
echo "Usage: $SCRIPT { cluster | join | leave | backup | restore | test | "
@@ -804,7 +825,7 @@ case "$1" in
804825
echo "Lists the services available on the node. See also: wait-for-service"
805826
exit 1
806827
fi
807-
$RPC_HOPterms riak_core_node_watcher services ''
828+
$RPCt_HOP riak_core_node_watcher services ''
808829
;;
809830

810831
wait[_-]for[_-]service)
@@ -818,7 +839,7 @@ case "$1" in
818839
while (true); do
819840
# Make sure riak_core_node_watcher is up and running locally before trying to query it
820841
# to avoid ugly (but harmless) error messages
821-
NODEWATCHER=`$RPC_HOPterms erlang whereis "'riak_core_node_watcher'."`
842+
NODEWATCHER=`$RPCt_HOP erlang whereis "'riak_core_node_watcher'."`
822843
if [ "$NODEWATCHER" = "undefined" ]; then
823844
echo "$SVC is not up: node watcher is not running"
824845
continue
@@ -827,9 +848,9 @@ case "$1" in
827848
# Get the list of services that are available on the requested node
828849
# If no node is specified, get the list of services from the local node
829850
if [ "X$TARGETNODE" = "X" ]; then
830-
SERVICES=`$RPC_HOPterms riak_core_node_watcher services ''`
851+
SERVICES=`$RPCt_HOP riak_core_node_watcher services ''`
831852
else
832-
SERVICES=`$RPC_HOPterms riak_core_node_watcher services "'${TARGETNODE}'."`
853+
SERVICES=`$RPCt_HOP riak_core_node_watcher services "'${TARGETNODE}'."`
833854
fi
834855
echo "$SERVICES" | grep "[[,]$SVC[],]" > /dev/null 2>&1
835856
if [ "X$?" = "X0" ]; then
@@ -870,7 +891,7 @@ case "$1" in
870891
OLDNODE=$1
871892
NEWNODE=$2
872893
$ERTS_PATH/erl -noshell \
873-
-pa {{runner_patch_dir}} \
894+
-pa {{platform_patch_dir}} \
874895
-boot $BOOT_FILE \
875896
$CONFIG_ARGS \
876897
-eval "riak_kv_console:$ACTION(['$OLDNODE', '$NEWNODE'])" \
@@ -891,7 +912,7 @@ case "$1" in
891912
FILENAME=$3
892913

893914
$ERTS_PATH/erl -noshell -name riak_kv_backup@$HOST -setcookie $COOKIE \
894-
-pa {{runner_patch_dir}} \
915+
-pa {{platform_patch_dir}} \
895916
-boot $BOOT_FILE \
896917
-eval "riak_kv_backup:$ACTION('$NODE', \"$FILENAME\")" -s init stop
897918
;;
@@ -911,20 +932,20 @@ case "$1" in
911932
TYPE=$4
912933

913934
$ERTS_PATH/erl -noshell -name riak_kv_backup@$HOST -setcookie $COOKIE \
914-
-pa {{runner_patch_dir}} \
935+
-pa {{platform_patch_dir}} \
915936
-boot $BOOT_FILE \
916937
-eval "riak_kv_backup:$ACTION('$NODE', \"$FILENAME\", \"$TYPE\")" -s init stop
917938
;;
918939

919-
test)
940+
'test')
920941
# Make sure the local node IS running
921942

922943
shift
923944

924945
# Parse out the node name to pass to the client
925946

926947
$ERTS_PATH/erl -noshell -name riak_test@$HOST -setcookie $COOKIE \
927-
-pa {{runner_patch_dir}} \
948+
-pa {{platform_patch_dir}} \
928949
-boot $BOOT_FILE \
929950
-eval "case catch(riak:client_test(\"$NODE\")) of \
930951
ok -> init:stop(); \
@@ -959,7 +980,7 @@ case "$1" in
959980
RAND=$(($(($$ % 1000)) + 1))
960981
# Using np_etop instead of riak_etop to follow node_package convention
961982
$ERTS_PATH/erl -noshell -noinput \
962-
-pa {{runner_base_dir}} \
983+
-pa {{platform_patch_dir}} \
963984
-boot $BOOT_FILE \
964985
-hidden -name np_etop$RAND@$HOST -setcookie $COOKIE \
965986
-s etop -s erlang halt -output text \

rel/files/riak-chkconfig

100644100755
Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,32 @@
22
# -*- tab-width:4;indent-tabs-mode:nil -*-
33
# ex: ts=4 sw=4 et
44

5-
## cf_config defines the config arguments needed
6-
. bin/cf_config
5+
PLATFORM_BASE_DIR={{platform_base_dir}}
6+
PLATFORM_BASE_DIR=${PLATFORM_BASE_DIR:-$(cd $(dirname "$0")/.. && pwd -P)}
7+
RPC_HOP="${PLATFORM_BASE_DIR}/bin/riak rpc"
8+
RPCt_HOP="${PLATFORM_BASE_DIR}/bin/riak rpcterms"
79

8-
## "vm.args = $VMARGS_PATH"
9-
## "app.config = $CONFIG_PATH"
10+
ERTS_VER=$(cd ${PLATFORM_BASE_DIR} && ls -d erts-*)
11+
ERTS_PATH="${PLATFORM_BASE_DIR}/$ERTS_VER/bin"
12+
13+
PLATFORM_ETC_DIR={{platform_etc_dir}}
14+
if [ "$PLATFORM_ETC_DIR" = "${PLATFORM_ETC_DIR#/}" ]; then
15+
PLATFORM_ETC_DIR=$PLATFORM_BASE_DIR/$PLATFORM_ETC_DIR
16+
fi
17+
18+
COOKIE=`egrep '^[ \t]*distributed_cookie[ \t]*=[ \t]*' "$PLATFORM_ETC_DIR"/riak.conf 2> /dev/null | cut -d = -f 2 | tr -d ' '`
19+
NODE={{node}}
20+
HOST=${NODE#*@}
21+
22+
BOOT_FILE="${PLATFORM_BASE_DIR}/releases/{{release_version}}/start_clean"
23+
24+
PLATFORM_GEN_DIR={{platform_gen_dir}}
25+
if [ "$PLATFORM_GEN_DIR" = "${PLATFORM_GEN_DIR#/}" ]; then
26+
PLATFORM_GEN_DIR=$PLATFORM_BASE_DIR/$PLATFORM_GEN_DIR
27+
fi
28+
29+
CONFIG_PATH=`ls -1r ${PLATFORM_GEN_DIR}/generated.conf/app.*.config | head -n1`
30+
VMARGS_PATH=`ls -1r ${PLATFORM_GEN_DIR}/generated.conf/vm.*.args | head -n1`
1031

1132
CODE=" try
1233
{ok, _} = file:consult(\"$CONFIG_PATH\"),
@@ -18,6 +39,11 @@ CODE=" try
1839
halt(1)
1940
end."
2041

21-
$BINDIR/erl -noshell -boot start_clean -eval "$CODE"
42+
$ERTS_PATH/erl -noshell -noinput \
43+
-pa $PLATFORM_PATCH_DIR \
44+
-boot $BOOT_FILE \
45+
-hidden -name riak_chkconfig$RAND@$HOST -setcookie $COOKIE \
46+
-node $NODE -tracing off \
47+
-eval "$CODE"
2248

23-
echo $CUTTLE_CONF
49+
echo $CONFIG_PATH $VMARGS_PATH

0 commit comments

Comments
 (0)