From b7bcf5528bb30cc8f2a9b95dc967e2a555243db1 Mon Sep 17 00:00:00 2001 From: joewilliams Date: Wed, 5 Oct 2011 20:17:43 -0700 Subject: [PATCH] Handle vm.args properly while building upgrades This patch corrects the vm.args behavior while building upgrade tarballs by copying the file from the release into the upgrade. Additionally it patches the dummy runner script in the upgrade test project to work properly. --- src/rebar_upgrade.erl | 5 ++- test/upgrade_project/rel/files/dummy | 49 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/rebar_upgrade.erl b/src/rebar_upgrade.erl index 0cecaab..0b39035 100644 --- a/src/rebar_upgrade.erl +++ b/src/rebar_upgrade.erl @@ -151,7 +151,10 @@ boot_files(TargetDir, Ver, Name) -> filename:join([".", ?TMP, "releases", Ver, Name ++ ".boot"])), {ok, _} = file:copy( filename:join([TargetDir, "releases", Ver, "start_clean.boot"]), - filename:join([".", ?TMP, "releases", Ver, "start_clean.boot"])). + filename:join([".", ?TMP, "releases", Ver, "start_clean.boot"])), + {ok, _} = file:copy( + filename:join([TargetDir, "releases", Ver, "vm.args"]), + filename:join([".", ?TMP, "releases", Ver, "vm.args"])). make_tar(NameVer) -> Filename = NameVer ++ ".tar.gz", diff --git a/test/upgrade_project/rel/files/dummy b/test/upgrade_project/rel/files/dummy index 78d6bae..03b27aa 100755 --- a/test/upgrade_project/rel/files/dummy +++ b/test/upgrade_project/rel/files/dummy @@ -21,21 +21,6 @@ cd $RUNNER_BASE_DIR # Make sure log directory exists mkdir -p $RUNNER_LOG_DIR - -# Extract the target node name from node.args -NAME_ARG=`egrep '^-s?name' $RUNNER_ETC_DIR/vm.args` -if [ -z "$NAME_ARG" ]; then - echo "vm.args needs to have either -name or -sname parameter." - exit 1 -fi - -# Extract the target cookie -COOKIE_ARG=`grep '^-setcookie' $RUNNER_ETC_DIR/vm.args` -if [ -z "$COOKIE_ARG" ]; then - echo "vm.args needs to have a -setcookie parameter." - exit 1 -fi - # Identify the script name SCRIPT=`basename $0` @@ -44,11 +29,12 @@ START_ERL=`cat $RUNNER_BASE_DIR/releases/start_erl.data` ERTS_VSN=${START_ERL% *} APP_VSN=${START_ERL#* } -# Add ERTS bin dir to our path -ERTS_PATH=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin - -# Setup command to control the node -NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG" +# Use releases/VSN/vm.args if it exists otherwise use etc/vm.args +if [ -e "$RUNNER_BASE_DIR/releases/$APP_VSN/vm.args" ]; then + VMARGS_PATH="$RUNNER_BASE_DIR/releases/$APP_VSN/vm.args" +else + VMARGS_PATH="$RUNNER_ETC_DIR/vm.args" +fi # Use releases/VSN/sys.config if it exists otherwise use etc/app.config if [ -e "$RUNNER_BASE_DIR/releases/$APP_VSN/sys.config" ]; then @@ -57,13 +43,26 @@ else CONFIG_PATH="$RUNNER_ETC_DIR/app.config" fi -# Use releases/VSN/vm.args if it exists otherwise use etc/vm.args -if [-e "$RUNNER_BASE_DIR/releases/$APP_VSN/vm.args" ]; then - VMARGS_PATH="$RUNNER_BASE_DIR/releases/$APP_VSN/vm.args" -else - VMARGS_PATH="$RUNNER_ETC_DIR/vm.args" +# Extract the target node name from node.args +NAME_ARG=`egrep '^-s?name' $VMARGS_PATH` +if [ -z "$NAME_ARG" ]; then + echo "vm.args needs to have either -name or -sname parameter." + exit 1 fi +# Extract the target cookie +COOKIE_ARG=`grep '^-setcookie' $VMARGS_PATH` +if [ -z "$COOKIE_ARG" ]; then + echo "vm.args needs to have a -setcookie parameter." + exit 1 +fi + +# Add ERTS bin dir to our path +ERTS_PATH=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin + +# Setup command to control the node +NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG" + # Check the first argument for instructions case "$1" in start)