diff options
-rw-r--r-- | lib/reltool/src/reltool_server.erl | 5 | ||||
-rw-r--r-- | lib/reltool/src/reltool_utils.erl | 16 | ||||
-rw-r--r-- | lib/reltool/test/reltool_server_SUITE.erl | 27 | ||||
-rw-r--r-- | lib/reltool/test/reltool_server_SUITE_data/use_selected_vsn/b-1.0/rel/.gitignore | 0 |
4 files changed, 44 insertions, 4 deletions
diff --git a/lib/reltool/src/reltool_server.erl b/lib/reltool/src/reltool_server.erl index 084174a02a..034a42e1e2 100644 --- a/lib/reltool/src/reltool_server.erl +++ b/lib/reltool/src/reltool_server.erl @@ -1498,9 +1498,10 @@ decode(#app{} = App, [{Key, Val} | KeyVals]) -> lib_dir when is_list(Val), App#app.use_selected_vsn=:=undefined -> case filelib:is_dir(Val) of true -> + Dir = reltool_utils:normalize_dir(Val), App#app{use_selected_vsn = dir, - active_dir = Val, - sorted_dirs = [Val]}; + active_dir = Dir, + sorted_dirs = [Dir]}; false -> reltool_utils:throw_error("Illegal lib dir for ~p: ~p", [App#app.name, Val]) diff --git a/lib/reltool/src/reltool_utils.erl b/lib/reltool/src/reltool_utils.erl index ea0b00bbaf..6149d6ef06 100644 --- a/lib/reltool/src/reltool_utils.erl +++ b/lib/reltool/src/reltool_utils.erl @@ -22,6 +22,7 @@ -export([root_dir/0, erl_libs/0, lib_dirs/1, split_app_name/1, prim_consult/1, default_rels/0, choose_default/3, + normalize_dir/1, assign_image_list/1, get_latest_resize/1, wait_for_stop_motion/2, mod_conds/0, list_to_mod_cond/1, mod_cond_to_index/1, @@ -87,6 +88,21 @@ split_app_name(Name) -> {list_to_atom(Name), ""} end. + +normalize_dir(RelDir) -> + Tokens = filename:split(filename:absname(RelDir)), + filename:join(lists:reverse(normalize_dir(Tokens, []))). + +normalize_dir([".."|Dirs], [_Dir|Path]) -> + normalize_dir(Dirs, Path); +normalize_dir(["."|Dirs], Path) -> + normalize_dir(Dirs, Path); +normalize_dir([Dir|Dirs], Path) -> + normalize_dir(Dirs, [Dir|Path]); +normalize_dir([], Path) -> + Path. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% prim_consult(Bin) when is_binary(Bin) -> diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl index 998687136f..8a98dc36cf 100644 --- a/lib/reltool/test/reltool_server_SUITE.erl +++ b/lib/reltool/test/reltool_server_SUITE.erl @@ -89,7 +89,8 @@ all() -> gen_rel_files, save_config, dependencies, - use_selected_vsn]. + use_selected_vsn, + use_selected_vsn_relative_path]. groups() -> []. @@ -2084,7 +2085,6 @@ use_selected_vsn(Config) -> {app,b,[{incl_cond,include},{lib_dir,B2Dir}]}]}, {ok, Pid3} = ?msym({ok, _}, reltool:start_server([{config, Sys3}])), % test_server:break("Pid3 = list_to_pid(\""++pid_to_list(Pid3)++"\")."), - ?msym({ok,#app{vsn="2.0",active_dir=B2Dir}},reltool_server:get_app(Pid3,b)), {ok,B31} = ?msym({ok,#app{vsn="2.0",active_dir=B2Dir}}, reltool_server:get_app(Pid3,b)), %% Change from a pre-selected dir to use latest @@ -2123,6 +2123,29 @@ use_selected_vsn(Config) -> ok. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +use_selected_vsn_relative_path(Config) -> + LibDir = filename:join([datadir(Config),"use_selected_vsn","b-1.0"]), + RelDir = filename:join(LibDir,"rel"), + + {ok,Cwd} = file:get_cwd(), + ok = file:set_cwd(RelDir), + + Sys = {sys,[{incl_cond, exclude}, + {app,kernel,[{incl_cond,include}]}, + {app,sasl,[{incl_cond,include}]}, + {app,stdlib,[{incl_cond,include}]}, + {app,b,[{incl_cond,include},{lib_dir,".."}]}]}, + {ok, Pid} = ?msym({ok, _}, reltool:start_server([{config, Sys}])), + + ?msym({ok,#app{vsn="1.0",active_dir=LibDir}},reltool_server:get_app(Pid,b)), + + ?m(ok, reltool:stop(Pid)), + + ok = file:set_cwd(Cwd), + ok. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Library functions diff --git a/lib/reltool/test/reltool_server_SUITE_data/use_selected_vsn/b-1.0/rel/.gitignore b/lib/reltool/test/reltool_server_SUITE_data/use_selected_vsn/b-1.0/rel/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/lib/reltool/test/reltool_server_SUITE_data/use_selected_vsn/b-1.0/rel/.gitignore |