From 4ebfe9a6464d981b77008e083d258b4b720c6838 Mon Sep 17 00:00:00 2001 From: Paul Schoenfelder Date: Mon, 20 May 2019 15:22:27 -0400 Subject: [PATCH] Address #670 - Improvements to read-only support --- priv/libexec/erts.sh | 3 +++ priv/templates/release_rc_exec.eex | 12 +++++++++++- priv/templates/release_rc_main.eex | 12 ------------ priv/templates/release_rc_win_main.ps1.eex | 5 ++++- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/priv/libexec/erts.sh b/priv/libexec/erts.sh index 19c2cd16..651692e3 100755 --- a/priv/libexec/erts.sh +++ b/priv/libexec/erts.sh @@ -307,6 +307,9 @@ if __info="$(erl -noshell -eval 'io:format("~s~n~s~n", [code:root_dir(), erlang: ROOTDIR="$(echo "$__info" | head -n1)" export ERTS_VSN if [ -z "$ERTS_VSN" ]; then + if [ ! -f "${START_ERL_DATA}" ]; then + fail "Unable to boot release, missing start_erl.data at '"${START_ERL_DATA}"'" + fi # Update start_erl.data ERTS_VSN="$(echo "$__info" | tail -n1)" echo "$ERTS_VSN $REL_VSN" > "$START_ERL_DATA" diff --git a/priv/templates/release_rc_exec.eex b/priv/templates/release_rc_exec.eex index e643ec70..5573c7d5 100644 --- a/priv/templates/release_rc_exec.eex +++ b/priv/templates/release_rc_exec.eex @@ -7,13 +7,23 @@ unset CDPATH SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)" RELEASE_ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" RELEASES_DIR="${RELEASE_ROOT_DIR}/releases" +RELEASE_MUTABLE_DIR="${RELEASE_MUTABLE_DIR:-"${RELEASE_ROOT_DIR}/var"}" +START_ERL_DATA="${RELEASE_MUTABLE_DIR}/start_erl.data" REL_NAME="${REL_NAME:-<%= release_name %>}" -REL_VSN="${REL_VSN:-$(cut -d' ' -f2 "${RELEASES_DIR}"/start_erl.data)}" +if [ ! -f "${START_ERL_DATA}" ]; then + cp "${RELEASES_DIR}/start_erl.data" "${START_ERL_DATA}" +fi +REL_VSN="${REL_VSN:-$(cut -d' ' -f2 "${START_ERL_DATA}")}" +ERTS_VSN="${ERTS_VSN:-$(cut -d' ' -f1 "${START_ERL_DATA}")}" +<%= if (include_erts == false or is_nil(erts_vsn)) do %>USE_HOST_ERTS=true<% end %> export RELEASE_ROOT_DIR export RELEASES_DIR +export RELEASE_MUTABLE_DIR +export START_ERL_DATA export REL_NAME export REL_VSN +export ERTS_VSN export DEBUG_BOOT # Set DEBUG_BOOT to output verbose debugging info during execution diff --git a/priv/templates/release_rc_main.eex b/priv/templates/release_rc_main.eex index 917ac52b..b56d4d63 100644 --- a/priv/templates/release_rc_main.eex +++ b/priv/templates/release_rc_main.eex @@ -10,25 +10,13 @@ fi unset CDPATH -# Name of the release -REL_NAME="${REL_NAME:-<%= release_name %>}" -# Current version of the release -REL_VSN="${REL_VSN:-<%= release_version %>}" # Options passed to erl ERL_OPTS="${ERL_OPTS:-<%= release.profile.erl_opts %>}" # Environment variables for run_erl RUN_ERL_ENV="${RUN_ERL_ENV:-<%= release.profile.run_erl_env %>}" -# Current version of ERTS being used -<%= if (include_erts == false or is_nil(erts_vsn)) do %>USE_HOST_ERTS=true<% end %> -# If this is not present/unset, it will be detected -<%= if ((is_binary(include_erts) or include_erts) and not is_nil(erts_vsn)) do %>ERTS_VSN="${ERTS_VSN:-<%= erts_vsn %>}"<% end %> DISTILLERY_VSN="<%= Application.spec(:distillery, :vsn) %>" -export REL_NAME -export REL_VSN export ERL_OPTS export RUN_ERL_ENV -export USE_HOST_ERTS -export ERTS_VSN export DISTILLERY_VSN # If readlink has no -f option, or greadlink is not available, diff --git a/priv/templates/release_rc_win_main.ps1.eex b/priv/templates/release_rc_win_main.ps1.eex index 518b145f..5fd5ce08 100644 --- a/priv/templates/release_rc_win_main.ps1.eex +++ b/priv/templates/release_rc_win_main.ps1.eex @@ -87,7 +87,10 @@ if ($Env:RELEASE_MUTABLE_DIR -eq $null) { # be stored in. defaults to /log in the release root directory $Env:RUNNER_LOG_DIR = (join-path $Env:RELEASE_MUTABLE_DIR "log") # Path to start_erl.data -$Env:START_ERL_DATA = (join-path $release_root_dir (join-path "releases" "start_erl.data")) +$Env:START_ERL_DATA = (join-path $Env:RELEASE_MUTABLE_DIR "start_erl.data") +if (-not (test-path $Env:START_ERL_DATA)) { + copy-item -Path (join-path $releases_dir "start_erl.data") -Destination $Env:START_ERL_DATA -Force +} # Directory containing lifecycle hook scripts $Env:HOOKS_DIR = (join-path $Env:REL_DIR "hooks") # Allow override of where to read configuration from