aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--priv/templates/bin_windows.dtl16
-rw-r--r--priv/templates/extended_bin.dtl45
-rw-r--r--priv/templates/extended_bin_windows.dtl42
-rw-r--r--src/rlx_prv_overlay.erl21
-rw-r--r--test/rlx_release_SUITE.erl10
-rw-r--r--test/rlx_test_utils.erl1
6 files changed, 84 insertions, 51 deletions
diff --git a/priv/templates/bin_windows.dtl b/priv/templates/bin_windows.dtl
index 7a8952b..226549d 100644
--- a/priv/templates/bin_windows.dtl
+++ b/priv/templates/bin_windows.dtl
@@ -9,7 +9,7 @@
:: Set the root release directory based on the location of this batch file
@set script_dir=%~dp0
@for %%A in ("%script_dir%\..") do (
- @set "release_root_dir=%%~fA"
+ set "release_root_dir=%%~fA"
)
@set rel_dir=%release_root_dir%\releases\%rel_vsn%
@@ -42,9 +42,9 @@ cd %rootdir%
:find_erts_dir
@set erts_dir=%release_root_dir%\erts-%erts_vsn%
@if exist %erts_dir% (
- @goto :set_erts_dir_from_default
+ goto :set_erts_dir_from_default
) else (
- @goto :set_erts_dir_from_erl
+ goto :set_erts_dir_from_erl
)
@goto :eof
@@ -57,11 +57,11 @@ cd %rootdir%
:: Set the ERTS dir from erl
:set_erts_dir_from_erl
@for /f "delims=" %%i in ('where erl') do (
- @set erl=%%i
+ set erl=%%i
)
@set dir_cmd="%erl%" -noshell -eval "io:format(\"~s\", [filename:nativename(code:root_dir())])." -s init stop
@for /f %%i in ('%%dir_cmd%%') do (
- @set erl_root=%%i
+ set erl_root=%%i
)
@set erts_dir=%erl_root%\erts-%erts_vsn%
@set rootdir=%erl_root%
@@ -71,15 +71,15 @@ cd %rootdir%
:find_sys_config
@set possible_sys=%rel_dir%\sys.config
@if exist "%possible_sys%" (
- @set sys_config=-config "%possible_sys%"
+ set sys_config=-config "%possible_sys%"
)
@goto :eof
:: set boot_script variable
:set_boot_script_var
@if exist "%rel_dir%\%rel_name%.boot" (
- @set boot_script=%rel_dir%\%rel_name%
+ set boot_script=%rel_dir%\%rel_name%
) else (
- @set boot_script=%rel_dir%\start
+ set boot_script=%rel_dir%\start
)
@goto :eof
diff --git a/priv/templates/extended_bin.dtl b/priv/templates/extended_bin.dtl
index ffff615..9a3ab61 100644
--- a/priv/templates/extended_bin.dtl
+++ b/priv/templates/extended_bin.dtl
@@ -38,6 +38,11 @@ relx_get_pid() {
fi
}
+relx_get_longname() {
+ id="longname$(relx_gen_id)-${NAME}"
+ "$BINDIR/erl" -boot start_clean -eval 'io:format("~s~n", [node()])' -noshell -s init stop -name $id | sed -e 's/.*@//g'
+}
+
# Connect to a remote node
relx_rem_sh() {
# Generate a unique id used to allow multiple remsh to the same node
@@ -123,26 +128,6 @@ fi
NAME_TYPE="$(echo "$NAME_ARG" | awk '{print $1}')"
NAME="$(echo "$NAME_ARG" | awk '{print $2}')"
-# User can specify an sname without @hostname
-# This will fail when creating remote shell
-# So here we check for @ and add @hostname if missing
-case $NAME in
- *@*)
- # Nothing to do
- ;;
- *)
- # Add @hostname
- case $NAME_TYPE in
- -sname)
- NAME=$NAME@`hostname -s`
- ;;
- -name)
- NAME=$NAME@`hostname -f`
- ;;
- esac
- ;;
-esac
-
PIPE_DIR="${PIPE_DIR:-/tmp/erl_pipes/$NAME/}"
# Extract the target cookie
@@ -165,6 +150,26 @@ ERTS_LIB_DIR="$ERTS_DIR/../lib"
cd "$ROOTDIR"
+# User can specify an sname without @hostname
+# This will fail when creating remote shell
+# So here we check for @ and add @hostname if missing
+case $NAME in
+ *@*)
+ # Nothing to do
+ ;;
+ *)
+ # Add @hostname
+ case $NAME_TYPE in
+ -sname)
+ NAME=$NAME@`hostname -s`
+ ;;
+ -name)
+ NAME=$NAME@$(relx_get_longname)
+ ;;
+ esac
+ ;;
+esac
+
# Check the first argument for instructions
case "$1" in
start|start_boot)
diff --git a/priv/templates/extended_bin_windows.dtl b/priv/templates/extended_bin_windows.dtl
index e69c4e7..cb9f747 100644
--- a/priv/templates/extended_bin_windows.dtl
+++ b/priv/templates/extended_bin_windows.dtl
@@ -23,7 +23,7 @@
:: of this script
@set script_dir=%~dp0
@for %%A in ("%script_dir%\..") do @(
- @set release_root_dir=%%~fA
+ set release_root_dir=%%~fA
)
@set rel_dir=%release_root_dir%\releases\%rel_vsn%
@@ -44,13 +44,13 @@
:: Extract node type and name from vm.args
@for /f "usebackq tokens=1-2" %%I in (`findstr /b "\-name \-sname" "%vm_args%"`) do @(
- @set node_type=%%I
- @set node_name=%%J
+ set node_type=%%I
+ set node_name=%%J
)
:: Extract cookie from vm.args
@for /f "usebackq tokens=1-2" %%I in (`findstr /b \-setcookie "%vm_args%"`) do @(
- @set cookie=%%J
+ set cookie=%%J
)
:: Write the erl.ini file to set up paths relative to this script
@@ -58,7 +58,7 @@
:: If a start.boot file is not present, copy one from the named .boot file
@if not exist "%rel_dir%\start.boot" (
- @copy "%rel_dir%\%rel_name%.boot" "%rel_dir%\start.boot" >nul
+ copy "%rel_dir%\%rel_name%.boot" "%rel_dir%\start.boot" >nul
)
@if "%1"=="install" @goto install
@@ -81,9 +81,9 @@
:find_erts_dir
@set possible_erts_dir=%release_root_dir%\erts-%erts_vsn%
@if exist "%possible_erts_dir%" (
- @call :set_erts_dir_from_default
+ call :set_erts_dir_from_default
) else (
- @call :set_erts_dir_from_erl
+ call :set_erts_dir_from_erl
)
@goto :eof
@@ -96,11 +96,11 @@
:: Set the ERTS dir from erl
:set_erts_dir_from_erl
@for /f "delims=" %%i in ('where erl') do @(
- @set erl=%%i
+ set erl=%%i
)
@set dir_cmd="%erl%" -noshell -eval "io:format(\"~s\", [filename:nativename(code:root_dir())])." -s init stop
@for /f %%i in ('%%dir_cmd%%') do @(
- @set erl_root=%%i
+ set erl_root=%%i
)
@set erts_dir=%erl_root%\erts-%erts_vsn%
@set rootdir=%erl_root%
@@ -110,16 +110,16 @@
:find_sys_config
@set possible_sys=%rel_dir%\sys.config
@if exist %possible_sys% (
- @set sys_config=-config %possible_sys%
+ set sys_config=-config %possible_sys%
)
@goto :eof
:: set boot_script variable
:set_boot_script_var
@if exist "%rel_dir%\%rel_name%.boot" (
- @set boot_script=%rel_dir%\%rel_name%
+ set boot_script=%rel_dir%\%rel_name%
) else (
- @set boot_script=%rel_dir%\start
+ set boot_script=%rel_dir%\start
)
@goto :eof
@@ -144,10 +144,10 @@
:install
@if "" == "%2" (
:: Install the service
- @set args=%erl_opts% -setcookie %cookie% ++ -rootdir \"%rootdir%\"
- @set start_erl=%erts_dir%\bin\start_erl.exe
- @set description=Erlang node %node_name% in %rootdir%
- @%erlsrv% add %service_name% %node_type% "%node_name%" -c "%description%" ^
+ set args=%erl_opts% -setcookie %cookie% ++ -rootdir \"%rootdir%\"
+ set start_erl=%erts_dir%\bin\start_erl.exe
+ set description=Erlang node %node_name% in %rootdir%
+ %erlsrv% add %service_name% %node_type% "%node_name%" -c "%description%" ^
-w "%rootdir%" -m "%start_erl%" -args "%args%" ^
-stopaction "init:stop()."
) else (
@@ -175,11 +175,11 @@
:: Relup and reldown
:relup
@if "" == "%2" (
- @echo Missing package argument
- @echo Usage: %rel_name% %1 {package base name}
- @echo NOTE {package base name} MUST NOT include the .tar.gz suffix
- @set ERRORLEVEL=1
- @exit /b %ERRORLEVEL%
+ echo Missing package argument
+ echo Usage: %rel_name% %1 {package base name}
+ echo NOTE {package base name} MUST NOT include the .tar.gz suffix
+ set ERRORLEVEL=1
+ exit /b %ERRORLEVEL%
)
@%escript% "%rootdir%/bin/install_upgrade.escript" "%rel_name%" "%node_name%" "%cookie%" "%2"
@goto :eof
diff --git a/src/rlx_prv_overlay.erl b/src/rlx_prv_overlay.erl
index ab0f74e..cdce915 100644
--- a/src/rlx_prv_overlay.erl
+++ b/src/rlx_prv_overlay.erl
@@ -161,6 +161,21 @@ read_overlay_vars(State, OverlayVars, FileNames) ->
Error
end.
+-spec check_overlay_inclusion(rlx_state:t(), string(), proplists:proplist()) ->
+ proplists:proplist().
+check_overlay_inclusion(State, RelativeRoot, Terms) ->
+ check_overlay_inclusion(State, RelativeRoot, Terms, []).
+
+-spec check_overlay_inclusion(rlx_state:t(), string(), proplists:proplist(), proplists:proplist()) ->
+ proplists:proplist().
+check_overlay_inclusion(State, RelativeRoot, [File|T], Terms) when is_list(File) ->
+ IncludedTerms = merge_overlay_vars(State, [filename:join(RelativeRoot, File)]),
+ check_overlay_inclusion(State, RelativeRoot, T, Terms ++ IncludedTerms);
+check_overlay_inclusion(State, RelativeRoot, [Tuple|T], Terms) ->
+ check_overlay_inclusion(State, RelativeRoot, T, Terms ++ [Tuple]);
+check_overlay_inclusion(_State, _RelativeRoot, [], Terms) ->
+ Terms.
+
-spec merge_overlay_vars(rlx_state:t(), [file:name()]) ->
proplists:proplist().
merge_overlay_vars(State, FileNames) ->
@@ -169,7 +184,11 @@ merge_overlay_vars(State, FileNames) ->
RelativePath = filename:join(RelativeRoot, erlang:iolist_to_binary(FileName)),
case file:consult(RelativePath) of
{ok, Terms} ->
- lists:ukeymerge(1, lists:ukeysort(1, Terms), Acc);
+ % the location of the included overlay files will be relative
+ %% to the current one being read
+ OverlayRelativeRoot = filename:dirname(FileName),
+ NewTerms = check_overlay_inclusion(State, OverlayRelativeRoot, Terms),
+ lists:ukeymerge(1, lists:ukeysort(1, NewTerms), Acc);
{error, Reason} ->
ec_cmd_log:warn(rlx_state:log(State),
format_error({unable_to_read_varsfile, FileName, Reason})),
diff --git a/test/rlx_release_SUITE.erl b/test/rlx_release_SUITE.erl
index eeab491..766eb40 100644
--- a/test/rlx_release_SUITE.erl
+++ b/test/rlx_release_SUITE.erl
@@ -471,6 +471,7 @@ overlay_release(Config) ->
ConfigFile = filename:join([LibDir1, "relx.config"]),
OverlayVars1 = filename:join([LibDir1, "vars1.config"]),
OverlayVars2 = filename:join([LibDir1, "vars2.config"]),
+ OverlayVars3 = filename:join([LibDir1, "vars3.config"]),
Template = filename:join([LibDir1, "test_template"]),
TestDir = "first_test_dir",
TestFile = "test_file",
@@ -502,7 +503,12 @@ overlay_release(Config) ->
VarsFile2 = filename:join([LibDir1, "vars2.config"]),
rlx_test_utils:write_config(VarsFile2, [{google, "yahoo"},
- {yahoo2, [{foo, "foo"}]}]),
+ {yahoo2, [{foo, "foo"}]},
+ OverlayVars3]),
+
+ VarsFile3 = filename:join([LibDir1, "vars3.config"]),
+ rlx_test_utils:write_config(VarsFile3, [{google, "yahoo"},
+ {yahoo4, [{foo, "{{yahoo}}/{{yahoo2.foo}}4"}]}]),
ok = rlx_util:mkdir_p(TestDirFull),
ok = file:write_file(TestFileFull, rlx_test_utils:test_template_contents()),
@@ -604,6 +610,8 @@ overlay_release(Config) ->
proplists:get_value(foo_dir, TemplateData)),
?assertEqual("yahoo/foo",
proplists:get_value(yahoo3, TemplateData)),
+ ?assertEqual("yahoo/foo4",
+ proplists:get_value(yahoo4, TemplateData)),
?assertEqual("yahoo",
proplists:get_value(google, TemplateData)).
diff --git a/test/rlx_test_utils.erl b/test/rlx_test_utils.erl
index 0428966..644c49f 100644
--- a/test/rlx_test_utils.erl
+++ b/test/rlx_test_utils.erl
@@ -94,4 +94,5 @@ test_template_contents() ->
"{yahoo2_foo, \"{{yahoo2.foo}}\"}.\n"
"{foo_dir, \"{{foo_dir}}\"}.\n"
"{yahoo3, \"{{yahoo3.bar}}\"}.\n"
+ "{yahoo4, \"{{yahoo4.foo}}\"}.\n"
"{google, \"{{google}}\"}.\n".