diff options
author | Siri Hansen <[email protected]> | 2012-03-22 16:39:20 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2012-03-22 16:39:20 +0100 |
commit | 38f068341ebf04e5d6bf5eff7fb01e44bce228b6 (patch) | |
tree | a8fd5fff96972a307887ad482142d5ef1e17f0e2 /lib/reltool/src | |
parent | 602d96340b97315c156b597a5ccbfcc135a9a682 (diff) | |
download | otp-38f068341ebf04e5d6bf5eff7fb01e44bce228b6.tar.gz otp-38f068341ebf04e5d6bf5eff7fb01e44bce228b6.tar.bz2 otp-38f068341ebf04e5d6bf5eff7fb01e44bce228b6.zip |
[reltool] Allow lib_dir on app level to use relative path
This commit adds a normalization of the directory given with the
lib_dir parameter on application level. This will covert the path to
absolute, remove trailing slash and any occurrencies of "xxx/..".
Diffstat (limited to 'lib/reltool/src')
-rw-r--r-- | lib/reltool/src/reltool_server.erl | 5 | ||||
-rw-r--r-- | lib/reltool/src/reltool_utils.erl | 16 |
2 files changed, 19 insertions, 2 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) -> |