Skip to content

Commit

Permalink
Attempt at a fix for vm.args usage (#688)
Browse files Browse the repository at this point in the history
* Attempt at a fix for vm.args usage

* bump sleep time to see if it fixes tests on travis
  • Loading branch information
djnym authored and tsloughter committed Feb 21, 2019
1 parent 5e7bd9d commit edad2b4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 84 deletions.
49 changes: 4 additions & 45 deletions priv/templates/extended_bin
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ relx_rem_sh() {
# Setup remote shell command to control node
exec "$BINDIR/erl" "$NAME_TYPE" "$id" -remsh "$NAME" -boot start_clean \
-boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
-setcookie "$COOKIE" -hidden -kernel net_ticktime $TICKTIME $VM_ARGS
-setcookie "$COOKIE" -hidden -kernel net_ticktime $TICKTIME
}

# Generate a random id
Expand All @@ -182,9 +182,7 @@ relx_gen_id() {
relx_nodetool() {
command="$1"; shift

ESCRIPT_TMP=$(escript_emulator_args_tmp $ROOTDIR/bin/nodetool)

"$ERTS_DIR/bin/escript" "$ESCRIPT_TMP" "$NAME_TYPE" "$NAME" \
"$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" "$NAME_TYPE" "$NAME" \
-setcookie "$COOKIE" "$command" $@
}

Expand Down Expand Up @@ -233,41 +231,6 @@ replace_os_vars() {
}1' < "$1" > "$2"
}

escript_emulator_args() {
if [ -n "${VM_ARGS}" ]; then
if grep -q '%%!' $1; then
cmd=$(echo sed -i"'.prev'" "'/%%!.*/ s| ${VM_ARGS}||'" $1)
eval "$cmd"
cmd=$(echo sed -i"'.prev'" "'/%%!.*/ s|$| ${VM_ARGS}|'" $1)
eval "$cmd"
rm ${1}.prev
else
cmd=$(echo sed -i"'.prev'" "'/#!.*/ a \\
%%! ${VM_ARGS}\n'" $1)
eval "$cmd"
rm ${1}.prev
fi
fi
}

escript_emulator_args_tmp() {
#
# If the user provided $ROOTDIR/tmp directory then don't override
# original files of the package but use temporary files instead
#
local TMP_DIR="$ROOTDIR/tmp";

if [ -d "$TMP_DIR" ] && [ -w "$TMP_DIR" ]; then
local TMP_FILE="$TMP_DIR/$(basename $1)"
cp $1 $TMP_FILE
escript_emulator_args $TMP_FILE
echo $TMP_FILE
else
escript_emulator_args $1
echo $1
fi
}

add_path() {
# Use $CWD/$1 if exists, otherwise releases/VSN/$1
IN_FILE_PATH=$2
Expand Down Expand Up @@ -649,9 +612,7 @@ case "$1" in

relx_run_hooks "$PRE_INSTALL_UPGRADE_HOOKS"

ESCRIPT_TMP=$(escript_emulator_args_tmp $ROOTDIR/bin/install_upgrade.escript)

exec "$BINDIR/escript" "$ESCRIPT_TMP" \
exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
"$COMMAND" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@"

relx_run_hooks "$POST_INSTALL_UPGRADE_HOOKS"
Expand All @@ -665,10 +626,8 @@ case "$1" in
fi

COMMAND="$1"; shift

ESCRIPT_TMP=$(escript_emulator_args_tmp $ROOTDIR/bin/install_upgrade.escript)

exec "$BINDIR/escript" "$ESCRIPT_TMP" \
exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
"versions" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@"
;;

Expand Down
Loading

0 comments on commit edad2b4

Please sign in to comment.