aboutsummaryrefslogtreecommitdiffstats
path: root/src/rlx_prv_overlay.erl
diff options
context:
space:
mode:
authorEric <[email protected]>2013-05-09 17:13:06 -0700
committerEric <[email protected]>2013-05-10 11:09:49 -0700
commitc5f0a8c9175b2d152c69f72da15e7ceff411f86b (patch)
tree1ae9a327feeb420983f9a85fdb6c800900369480 /src/rlx_prv_overlay.erl
parentefbdfbe117939cd50d0252a210b9b7634de42bb4 (diff)
downloadrelx-c5f0a8c9175b2d152c69f72da15e7ceff411f86b.tar.gz
relx-c5f0a8c9175b2d152c69f72da15e7ceff411f86b.tar.bz2
relx-c5f0a8c9175b2d152c69f72da15e7ceff411f86b.zip
internal rename completion of all relcool to relx calls
Diffstat (limited to 'src/rlx_prv_overlay.erl')
-rw-r--r--src/rlx_prv_overlay.erl182
1 files changed, 91 insertions, 91 deletions
diff --git a/src/rlx_prv_overlay.erl b/src/rlx_prv_overlay.erl
index 35e37bf..5fffd78 100644
--- a/src/rlx_prv_overlay.erl
+++ b/src/rlx_prv_overlay.erl
@@ -20,9 +20,9 @@
%%%
%%% @doc Given a complete built release this provider assembles that release
%%% into a release directory.
--module(rcl_prv_overlay).
+-module(rlx_prv_overlay).
--behaviour(rcl_provider).
+-behaviour(rlx_provider).
-export([init/1,
do/1,
@@ -30,26 +30,26 @@
-define(DIRECTORY_RE, ".*(\/|\\\\)$").
--include_lib("relcool/include/relcool.hrl").
+-include_lib("relx/include/relx.hrl").
%%============================================================================
%% API
%%============================================================================
--spec init(rcl_state:t()) -> {ok, rcl_state:t()}.
+-spec init(rlx_state:t()) -> {ok, rlx_state:t()}.
init(State) ->
{ok, State}.
%% @doc recursively dig down into the library directories specified in the state
%% looking for OTP Applications
--spec do(rcl_state:t()) -> {ok, rcl_state:t()} | relcool:error().
+-spec do(rlx_state:t()) -> {ok, rlx_state:t()} | relx:error().
do(State) ->
- {RelName, RelVsn} = rcl_state:default_configured_release(State),
- Release = rcl_state:get_realized_release(State, RelName, RelVsn),
- case rcl_release:realized(Release) of
+ {RelName, RelVsn} = rlx_state:default_configured_release(State),
+ Release = rlx_state:get_realized_release(State, RelName, RelVsn),
+ case rlx_release:realized(Release) of
true ->
generate_overlay_vars(State, Release);
false ->
- ?RCL_ERROR({unresolved_release, RelName, RelVsn})
+ ?RLX_ERROR({unresolved_release, RelName, RelVsn})
end.
-spec format_error(ErrorDetail::term()) -> iolist().
@@ -62,13 +62,13 @@ format_error({unable_to_read_varsfile, FileName, Reason}) ->
io_lib:format("Unable to read vars file (~s) for overlay due to: ~p",
[FileName, Reason]);
format_error({overlay_failed, Errors}) ->
- [[format_error(rcl_util:error_reason(Error)), "\n"] || Error <- Errors];
+ [[format_error(rlx_util:error_reason(Error)), "\n"] || Error <- Errors];
format_error({dir_render_failed, Dir, Error}) ->
io_lib:format("rendering mkdir path failed ~s with ~p",
[Dir, Error]);
format_error({unable_to_make_symlink, AppDir, TargetDir, Reason}) ->
io_lib:format("Unable to symlink directory ~s to ~s because \n~s~s",
- [AppDir, TargetDir, rcl_util:indent(1),
+ [AppDir, TargetDir, rlx_util:indent(1),
file:format_error(Reason)]);
format_error({copy_failed, FromFile, ToFile, Err}) ->
io_lib:format("Unable to copy from ~s to ~s because of ~p",
@@ -92,25 +92,25 @@ format_error({unable_to_make_dir, Absolute, Error}) ->
%%%===================================================================
%%% Internal Functions
%%%===================================================================
--spec generate_overlay_vars(rcl_state:t(), rcl_release:t()) ->
- {ok, rcl_state:t()} | relcool:error().
+-spec generate_overlay_vars(rlx_state:t(), rlx_release:t()) ->
+ {ok, rlx_state:t()} | relx:error().
generate_overlay_vars(State, Release) ->
StateVars = generate_state_vars(State),
ReleaseVars = generate_release_vars(Release),
get_overlay_vars_from_file(State, StateVars ++ ReleaseVars).
--spec get_overlay_vars_from_file(rcl_state:t(), proplists:proplist()) ->
- {ok, rcl_state:t()} | relcool:error().
+-spec get_overlay_vars_from_file(rlx_state:t(), proplists:proplist()) ->
+ {ok, rlx_state:t()} | relx:error().
get_overlay_vars_from_file(State, OverlayVars) ->
- case rcl_state:get(State, overlay_vars, undefined) of
+ case rlx_state:get(State, overlay_vars, undefined) of
undefined ->
do_overlay(State, OverlayVars);
FileName ->
read_overlay_vars(State, OverlayVars, FileName)
end.
--spec read_overlay_vars(rcl_state:t(), proplists:proplist(), file:name()) ->
- {ok, rcl_state:t()} | relcool:error().
+-spec read_overlay_vars(rlx_state:t(), proplists:proplist(), file:name()) ->
+ {ok, rlx_state:t()} | relx:error().
read_overlay_vars(State, OverlayVars, FileName) ->
RelativeRoot = get_relative_root(State),
RelativePath = filename:join(RelativeRoot, erlang:iolist_to_binary(FileName)),
@@ -123,12 +123,12 @@ read_overlay_vars(State, OverlayVars, FileName) ->
Error
end;
{error, Reason} ->
- ?RCL_ERROR({unable_to_read_varsfile, FileName, Reason})
+ ?RLX_ERROR({unable_to_read_varsfile, FileName, Reason})
end.
-spec render_overlay_vars(proplists:proplist(), proplists:proplist(),
proplists:proplist()) ->
- {ok, proplists:proplist()} | relcool:error().
+ {ok, proplists:proplist()} | relx:error().
render_overlay_vars(OverlayVars, [{Key, Value} | Rest], Acc)
when erlang:is_list(Value) ->
case io_lib:printable_list(Value) of
@@ -161,66 +161,66 @@ render_overlay_vars(OverlayVars, [KeyValue | Rest], Acc) ->
render_overlay_vars(_OverlayVars, [], Acc) ->
{ok, Acc}.
--spec generate_release_vars(rcl_release:t()) -> proplists:proplist().
+-spec generate_release_vars(rlx_release:t()) -> proplists:proplist().
generate_release_vars(Release) ->
- [{erts_vsn, rcl_release:erts(Release)},
- {release_erts_version, rcl_release:erts(Release)},
- {release_name, rcl_release:name(Release)},
- {rel_vsn, rcl_release:vsn(Release)},
- {release_version, rcl_release:vsn(Release)},
+ [{erts_vsn, rlx_release:erts(Release)},
+ {release_erts_version, rlx_release:erts(Release)},
+ {release_name, rlx_release:name(Release)},
+ {rel_vsn, rlx_release:vsn(Release)},
+ {release_version, rlx_release:vsn(Release)},
{release_applications, lists:map(fun(App) ->
- rcl_app_info:name(App)
- end, rcl_release:application_details(Release))},
- {release, [generate_app_vars(App)|| App <- rcl_release:application_details(Release)]},
+ rlx_app_info:name(App)
+ end, rlx_release:application_details(Release))},
+ {release, [generate_app_vars(App)|| App <- rlx_release:application_details(Release)]},
{release_goals, [if
erlang:is_list(Constraint) ->
Constraint;
true ->
- rcl_depsolver:format_constraint(Constraint)
- end || Constraint <- rcl_release:goals(Release)]}].
+ rlx_depsolver:format_constraint(Constraint)
+ end || Constraint <- rlx_release:goals(Release)]}].
--spec generate_app_vars(rcl_app_info:t()) -> AppInfo::tuple().
+-spec generate_app_vars(rlx_app_info:t()) -> AppInfo::tuple().
generate_app_vars(App) ->
- {rcl_app_info:name(App),
- [{version, rcl_app_info:vsn_as_string(App)},
- {dir, rcl_app_info:dir(App)},
- {active_dependencies, rcl_app_info:active_deps(App)},
- {library_dependencies, rcl_app_info:library_deps(App)},
- {link, rcl_app_info:link(App)}]}.
+ {rlx_app_info:name(App),
+ [{version, rlx_app_info:vsn_as_string(App)},
+ {dir, rlx_app_info:dir(App)},
+ {active_dependencies, rlx_app_info:active_deps(App)},
+ {library_dependencies, rlx_app_info:library_deps(App)},
+ {link, rlx_app_info:link(App)}]}.
--spec generate_state_vars(rcl_state:t()) -> proplists:proplist().
+-spec generate_state_vars(rlx_state:t()) -> proplists:proplist().
generate_state_vars(State) ->
- [{log, rcl_log:format(rcl_state:log(State))},
- {output_dir, rcl_state:output_dir(State)},
- {target_dir, rcl_state:output_dir(State)},
- {overridden, [AppName || {AppName, _} <- rcl_state:overrides(State)]},
- {overrides, rcl_state:overrides(State)},
- {goals, [rcl_depsolver:format_constraint(Constraint) ||
- Constraint <- rcl_state:goals(State)]},
- {lib_dirs, rcl_state:lib_dirs(State)},
- {config_file, rcl_state:config_file(State)},
- {providers, rcl_state:providers(State)},
- {sys_config, rcl_state:sys_config(State)},
- {root_dir, rcl_state:root_dir(State)},
- {default_release_name, case rcl_state:default_configured_release(State) of
+ [{log, rlx_log:format(rlx_state:log(State))},
+ {output_dir, rlx_state:output_dir(State)},
+ {target_dir, rlx_state:output_dir(State)},
+ {overridden, [AppName || {AppName, _} <- rlx_state:overrides(State)]},
+ {overrides, rlx_state:overrides(State)},
+ {goals, [rlx_depsolver:format_constraint(Constraint) ||
+ Constraint <- rlx_state:goals(State)]},
+ {lib_dirs, rlx_state:lib_dirs(State)},
+ {config_file, rlx_state:config_file(State)},
+ {providers, rlx_state:providers(State)},
+ {sys_config, rlx_state:sys_config(State)},
+ {root_dir, rlx_state:root_dir(State)},
+ {default_release_name, case rlx_state:default_configured_release(State) of
{Name0, _} ->
Name0
end},
- {default_release_version, case rcl_state:default_configured_release(State) of
+ {default_release_version, case rlx_state:default_configured_release(State) of
{_, Vsn0} ->
Vsn0
end},
- {default_release, case rcl_state:default_configured_release(State) of
+ {default_release, case rlx_state:default_configured_release(State) of
{Name1, undefined} ->
erlang:atom_to_list(Name1);
{Name1, Vsn1} ->
erlang:atom_to_list(Name1) ++ "-" ++ Vsn1
end}].
--spec do_overlay(rcl_state:t(), proplists:proplist()) ->
- {ok, rcl_state:t()} | relcool:error().
+-spec do_overlay(rlx_state:t(), proplists:proplist()) ->
+ {ok, rlx_state:t()} | relx:error().
do_overlay(State, OverlayVars) ->
- case rcl_state:get(State, overlay, undefined) of
+ case rlx_state:get(State, overlay, undefined) of
undefined ->
{ok, State};
Overlays ->
@@ -231,44 +231,44 @@ do_overlay(State, OverlayVars) ->
end, Overlays))
end.
--spec handle_errors(rcl_state:t(), [ok | relcool:error()]) ->
- {ok, rcl_state:t()} | relcool:error().
+-spec handle_errors(rlx_state:t(), [ok | relx:error()]) ->
+ {ok, rlx_state:t()} | relx:error().
handle_errors(State, Result) ->
case [Error || Error <- Result,
- rcl_util:is_error(Error)] of
+ rlx_util:is_error(Error)] of
Errors = [_|_] ->
- ?RCL_ERROR({overlay_failed, Errors});
+ ?RLX_ERROR({overlay_failed, Errors});
[] ->
{ok, State}
end.
--spec do_individual_overlay(rcl_state:t(), proplists:proplist(),
+-spec do_individual_overlay(rlx_state:t(), proplists:proplist(),
OverlayDirective::term()) ->
- {ok, rcl_state:t()} | relcool:error().
+ {ok, rlx_state:t()} | relx:error().
do_individual_overlay(State, OverlayVars, {mkdir, Dir}) ->
- ModuleName = make_template_name("rcl_mkdir_template", Dir),
+ ModuleName = make_template_name("rlx_mkdir_template", Dir),
case erlydtl:compile(erlang:iolist_to_binary(Dir), ModuleName) of
{ok, ModuleName} ->
case render(ModuleName, OverlayVars) of
{ok, IoList} ->
Absolute = absolutize(State,
- filename:join(rcl_state:output_dir(State),
+ filename:join(rlx_state:output_dir(State),
erlang:iolist_to_binary(IoList))),
- case rcl_util:mkdir_p(Absolute) of
+ case rlx_util:mkdir_p(Absolute) of
{error, Error} ->
- ?RCL_ERROR({unable_to_make_dir, Absolute, Error});
+ ?RLX_ERROR({unable_to_make_dir, Absolute, Error});
ok ->
ok
end;
{error, Error} ->
- ?RCL_ERROR({dir_render_failed, Dir, Error})
+ ?RLX_ERROR({dir_render_failed, Dir, Error})
end;
{error, Reason} ->
- ?RCL_ERROR({unable_to_compile_template, Dir, Reason})
+ ?RLX_ERROR({unable_to_compile_template, Dir, Reason})
end;
do_individual_overlay(State, OverlayVars, {copy, From, To}) ->
- FromTemplateName = make_template_name("rcl_copy_from_template", From),
- ToTemplateName = make_template_name("rcl_copy_to_template", To),
+ FromTemplateName = make_template_name("rlx_copy_from_template", From),
+ ToTemplateName = make_template_name("rlx_copy_to_template", To),
file_render_do(OverlayVars, From, FromTemplateName,
fun(FromFile) ->
file_render_do(OverlayVars, To, ToTemplateName,
@@ -277,8 +277,8 @@ do_individual_overlay(State, OverlayVars, {copy, From, To}) ->
end)
end);
do_individual_overlay(State, OverlayVars, {template, From, To}) ->
- FromTemplateName = make_template_name("rcl_template_from_template", From),
- ToTemplateName = make_template_name("rcl_template_to_template", To),
+ FromTemplateName = make_template_name("rlx_template_from_template", From),
+ ToTemplateName = make_template_name("rlx_template_to_template", To),
file_render_do(OverlayVars, From, FromTemplateName,
fun(FromFile) ->
file_render_do(OverlayVars, To, ToTemplateName,
@@ -291,15 +291,15 @@ do_individual_overlay(State, OverlayVars, {template, From, To}) ->
write_template(OverlayVars,
FromFile1,
absolutize(State,
- filename:join(rcl_state:output_dir(State),
+ filename:join(rlx_state:output_dir(State),
erlang:iolist_to_binary(ToFile))))
end)
end).
--spec copy_to(rcl_state:t(), file:name(), file:name()) -> ok | relcool:error().
+-spec copy_to(rlx_state:t(), file:name(), file:name()) -> ok | relx:error().
copy_to(State, FromFile0, ToFile0) ->
RelativeRoot = get_relative_root(State),
- ToFile1 = absolutize(State, filename:join(rcl_state:output_dir(State),
+ ToFile1 = absolutize(State, filename:join(rlx_state:output_dir(State),
erlang:iolist_to_binary(ToFile0))),
FromFile1 = absolutize(State, filename:join(RelativeRoot,
@@ -309,7 +309,7 @@ copy_to(State, FromFile0, ToFile0) ->
filelib:ensure_dir(ToFile1),
ToFile1;
true ->
- rcl_util:mkdir_p(ToFile1),
+ rlx_util:mkdir_p(ToFile1),
erlang:iolist_to_binary(filename:join(ToFile1,
filename:basename(FromFile1)))
end,
@@ -319,15 +319,15 @@ copy_to(State, FromFile0, ToFile0) ->
ok = file:write_file_info(ToFile2, FileInfo),
ok;
{error, Err} ->
- ?RCL_ERROR({copy_failed,
+ ?RLX_ERROR({copy_failed,
FromFile1,
ToFile1, Err})
end.
get_relative_root(State) ->
- case rcl_state:config_file(State) of
+ case rlx_state:config_file(State) of
[] ->
- rcl_state:root_dir(State);
+ rlx_state:root_dir(State);
Config ->
filename:dirname(Config)
end.
@@ -343,19 +343,19 @@ is_directory(ToFile0, ToFile1) ->
-spec render_template(proplists:proplist(), iolist()) ->
- ok | relcool:error().
+ ok | relx:error().
render_template(OverlayVars, Data) ->
- TemplateName = make_template_name("rcl_template_renderer", Data),
+ TemplateName = make_template_name("rlx_template_renderer", Data),
case erlydtl:compile(Data, TemplateName) of
Good when Good =:= ok; Good =:= {ok, TemplateName} ->
case render(TemplateName, OverlayVars) of
{ok, IoData} ->
{ok, IoData};
{error, Reason} ->
- ?RCL_ERROR({unable_to_render_template, Data, Reason})
+ ?RLX_ERROR({unable_to_render_template, Data, Reason})
end;
{error, Reason} ->
- ?RCL_ERROR({unable_to_compile_template, Data, Reason})
+ ?RLX_ERROR({unable_to_compile_template, Data, Reason})
end.
write_template(OverlayVars, FromFile, ToFile) ->
@@ -369,18 +369,18 @@ write_template(OverlayVars, FromFile, ToFile) ->
ok = file:write_file_info(ToFile, FileInfo),
ok;
{error, Reason} ->
- ?RCL_ERROR({unable_to_write, ToFile, Reason})
+ ?RLX_ERROR({unable_to_write, ToFile, Reason})
end;
{error, Reason} ->
- ?RCL_ERROR({unable_to_enclosing_dir, ToFile, Reason})
+ ?RLX_ERROR({unable_to_enclosing_dir, ToFile, Reason})
end;
Error ->
Error
end.
-spec file_render_do(proplists:proplist(), iolist(), module(),
- fun((term()) -> {ok, rcl_state:t()} | relcool:error())) ->
- {ok, rcl_state:t()} | relcool:error().
+ fun((term()) -> {ok, rlx_state:t()} | relx:error())) ->
+ {ok, rlx_state:t()} | relx:error().
file_render_do(OverlayVars, Data, TemplateName, NextAction) ->
case erlydtl:compile(erlang:iolist_to_binary(Data), TemplateName) of
{ok, TemplateName} ->
@@ -388,10 +388,10 @@ file_render_do(OverlayVars, Data, TemplateName, NextAction) ->
{ok, IoList} ->
NextAction(IoList);
{error, Error} ->
- ?RCL_ERROR({render_failed, Data, Error})
+ ?RLX_ERROR({render_failed, Data, Error})
end;
{error, Reason} ->
- ?RCL_ERROR({unable_to_compile_template, Data, Reason})
+ ?RLX_ERROR({unable_to_compile_template, Data, Reason})
end.
-spec make_template_name(string(), term()) -> module().
@@ -414,5 +414,5 @@ render(ModuleName, OverlayVars) ->
end.
absolutize(State, FileName) ->
- filename:absname(filename:join(rcl_state:root_dir(State),
+ filename:absname(filename:join(rlx_state:root_dir(State),
erlang:iolist_to_binary(FileName))).