From 35a98133836d75f7f0c91b0e2e7d5b6272175927 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Tue, 16 Feb 2021 17:46:25 -0700 Subject: [PATCH] add exports of RELEASE_NAME, RELEASE_VERSION and RELEASE_PROG to script These environment variables are for libraries like Opentelemetry to get information about the running release (and the script used to run the release in the case of RELEASE_PROG), particularly when release_handler isn't available. --- priv/templates/bin | 8 +++++++- priv/templates/bin_windows | 5 +++++ priv/templates/bin_windows_ps | 5 +++++ priv/templates/extended_bin | 6 ++++++ priv/templates/extended_bin_windows | 5 +++++ priv/templates/extended_bin_windows_ps | 5 +++++ 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/priv/templates/bin b/priv/templates/bin index c2cedd41f..395d4bb3f 100644 --- a/priv/templates/bin +++ b/priv/templates/bin @@ -8,8 +8,14 @@ if [ -z "$SCRIPT" ]; then fi; SCRIPT_DIR="$(cd "$(dirname "$SCRIPT")" && pwd -P)" RELEASE_ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd -P)" -REL_NAME="{{ rel_name }}" +export REL_NAME="{{ rel_name }}" REL_VSN="{{ rel_vsn }}" + +# export these to match mix release environment variables +export RELEASE_NAME="{{ rel_name }}" +export RELEASE_VSN="{{ rel_vsn }}" +export RELEASE_PROG="${SCRIPT}" + ERTS_VSN="{{ erts_vsn }}" REL_DIR="$RELEASE_ROOT_DIR/releases/$REL_VSN" ERL_OPTS="{{ erl_opts }}" diff --git a/priv/templates/bin_windows b/priv/templates/bin_windows index 7c7c80a9e..36e2e034f 100644 --- a/priv/templates/bin_windows +++ b/priv/templates/bin_windows @@ -7,6 +7,11 @@ set rel_vsn={{ rel_vsn }} set erts_vsn={{ erts_vsn }} set erl_opts={{ erl_opts }} +:: export these to match mix release environment variables +set RELEASE_NAME={{ rel_name }} +set RELEASE_VSN={{ rel_vsn }} +set RELEASE_PROG=%~nx0 + :: Set the root release directory based on the location of this batch file set script_dir=%~dp0 for %%A in ("%script_dir%\..") do ( diff --git a/priv/templates/bin_windows_ps b/priv/templates/bin_windows_ps index 1fe51025a..f0691fb7e 100644 --- a/priv/templates/bin_windows_ps +++ b/priv/templates/bin_windows_ps @@ -10,6 +10,11 @@ $rel_vsn = '{{ rel_vsn }}' $erts_vsn = '{{ erts_vsn }}' $erl_opts = '{{ erl_opts }}' +# export these to match mix release environment variables +$RELEASE_NAME = '{{ rel_name }}' +$RELEASE_VERSION = '{{ rel_vsn }}' +$RELEASE_PROG = $MyInvocation.MyCommand.Name + # Ensure we have PSScriptRoot if (!(Test-Path variable:global:PSScriptRoot)) { # Support for powershell 2.0 diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index 4c304aec4..a94f4fd6f 100644 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -34,6 +34,12 @@ RELEASE_ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd -P)" # Make the value available to variable substitution calls below export REL_NAME="{{ rel_name }}" REL_VSN="{{ rel_vsn }}" + +# export these to match mix release environment variables +export RELEASE_NAME="{{ rel_name }}" +export RELEASE_VSN="{{ rel_vsn }}" +export RELEASE_PROG="${SCRIPT}" + ERTS_VSN="{{ erts_vsn }}" REL_DIR="$RELEASE_ROOT_DIR/releases/$REL_VSN" RUNNER_LOG_DIR="${RUNNER_LOG_DIR:-$RELEASE_ROOT_DIR/log}" diff --git a/priv/templates/extended_bin_windows b/priv/templates/extended_bin_windows index 57c23a774..d472e439c 100644 --- a/priv/templates/extended_bin_windows +++ b/priv/templates/extended_bin_windows @@ -21,6 +21,11 @@ set rel_vsn={{ rel_vsn }} set erts_vsn={{ erts_vsn }} set erl_opts={{ erl_opts }} +:: export these to match mix release environment variables +set RELEASE_NAME={{ rel_name }} +set RELEASE_VSN={{ rel_vsn }} +set RELEASE_PROG=%~nx0 + :: Make sure `findstr` is accessible set PATH=%PATH%;%SystemRoot%\System32 diff --git a/priv/templates/extended_bin_windows_ps b/priv/templates/extended_bin_windows_ps index 3d9453d2f..edf7fc93d 100644 --- a/priv/templates/extended_bin_windows_ps +++ b/priv/templates/extended_bin_windows_ps @@ -27,6 +27,11 @@ $rel_vsn = '{{ rel_vsn }}' $erts_vsn = '{{ erts_vsn }}' $erl_opts = '{{ erl_opts }}' +# export these to match mix release environment variables +$RELEASE_NAME = '{{ rel_name }}' +$RELEASE_VERSION = '{{ rel_vsn }}' +$RELEASE_PROG = $MyInvocation.MyCommand.Name + # Ensure we have PSScriptRoot if (!(Test-Path variable:global:PSScriptRoot)) { # Support powershell 2.0