summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_rel_utils.erl18
-rw-r--r--src/rebar_reltool.erl5
2 files changed, 22 insertions, 1 deletions
diff --git a/src/rebar_rel_utils.erl b/src/rebar_rel_utils.erl
index d9a1fc6..4725f58 100644
--- a/src/rebar_rel_utils.erl
+++ b/src/rebar_rel_utils.erl
@@ -38,6 +38,7 @@
load_config/1,
get_sys_tuple/1,
get_target_dir/1,
+ get_root_dir/1,
get_target_parent_dir/1]).
-include("rebar.hrl").
@@ -158,6 +159,23 @@ get_target_dir(ReltoolConfig) ->
filename:absname(TargetDir)
end.
+%%
+%% Look for {root_dir, RootDir} in the reltool config file; if none is
+%% found, use the name of the release as the default target directory.
+%%
+get_root_dir(ReltoolConfig) ->
+ case rebar_config:get_global(root_dir, undefined) of
+ undefined ->
+ case lists:keyfind(root_dir, 1, ReltoolConfig) of
+ {root_dir, RootDir} ->
+ filename:absname(RootDir);
+ false ->
+ code:root_dir()
+ end;
+ RootDir ->
+ filename:absname(RootDir)
+ end.
+
get_target_parent_dir(ReltoolConfig) ->
case lists:reverse(tl(lists:reverse(filename:split(get_target_dir(ReltoolConfig))))) of
[] -> ".";
diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl
index e08f55f..4847e53 100644
--- a/src/rebar_reltool.erl
+++ b/src/rebar_reltool.erl
@@ -196,11 +196,14 @@ run_reltool(Server, _Config, ReltoolConfig) ->
TargetDir = rebar_rel_utils:get_target_dir(ReltoolConfig),
mk_target_dir(TargetDir),
+ %% Determine the otp root dir to use
+ RootDir = rebar_rel_utils:get_root_dir(ReltoolConfig),
+
%% Dump the spec, if necessary
dump_spec(Spec),
%% Have reltool actually run
- case reltool:eval_target_spec(Spec, code:root_dir(), TargetDir) of
+ case reltool:eval_target_spec(Spec, RootDir, TargetDir) of
ok ->
ok;
{error, Reason} ->