diff options
author | Luis Rascão <[email protected]> | 2016-12-17 17:05:06 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2016-12-17 17:05:06 +0000 |
commit | bec4f5c38fe7e094f6d7e3a820fb635b7d65a949 (patch) | |
tree | b12444d684dd04af871db22f76efdfcae31d69cd /src/rlx_prv_assembler.erl | |
parent | 083a3aecbd10cea625e0706007f8f831a33ebeaf (diff) | |
parent | a231a354c6e9db32832f6346a3fdea10f7996432 (diff) | |
download | relx-bec4f5c38fe7e094f6d7e3a820fb635b7d65a949.tar.gz relx-bec4f5c38fe7e094f6d7e3a820fb635b7d65a949.tar.bz2 relx-bec4f5c38fe7e094f6d7e3a820fb635b7d65a949.zip |
Merge pull request #551 from BakoBako/assembler-hooks-rm-rebar-log
Replace rebar_log in assembler
Diffstat (limited to 'src/rlx_prv_assembler.erl')
-rw-r--r-- | src/rlx_prv_assembler.erl | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl index a17d0f4..450eec9 100644 --- a/src/rlx_prv_assembler.erl +++ b/src/rlx_prv_assembler.erl @@ -392,7 +392,8 @@ write_bin_file(State, Release, OutputDir, RelDir) -> include_nodetool(BinDir), Hooks = expand_hooks(BinDir, rlx_state:get(State, - extended_start_script_hooks, [])), + extended_start_script_hooks, []), + State), extended_bin_file_contents(OsFamily, RelName, RelVsn, rlx_release:erts(Release), ErlOpts, Hooks) @@ -426,12 +427,12 @@ write_bin_file(State, Release, OutputDir, RelDir) -> E end. -expand_hooks(_Bindir, []) -> []; -expand_hooks(BinDir, Hooks) -> - expand_hooks(BinDir, Hooks, []). +expand_hooks(_Bindir, [], _State) -> []; +expand_hooks(BinDir, Hooks, _State) -> + expand_hooks(BinDir, Hooks, [], _State). -expand_hooks(_BinDir, [], Acc) -> Acc; -expand_hooks(BinDir, [{Phase, Hooks0} | Rest], Acc) -> +expand_hooks(_BinDir, [], Acc, _State) -> Acc; +expand_hooks(BinDir, [{Phase, Hooks0} | Rest], Acc, State) -> %% filter and expand hooks to their respective shell scripts Hooks = lists:foldl( @@ -442,17 +443,20 @@ expand_hooks(BinDir, [{Phase, Hooks0} | Rest], Acc) -> HookScriptFilename = filename:join([BinDir, hook_filename(Hook)]), %% write the hook script file to it's proper location - ok = render_hook(hook_template(Hook), HookScriptFilename), + ok = render_hook(hook_template(Hook), HookScriptFilename, State), %% and return the invocation that's to be templated in the %% extended script Acc0 ++ [hook_invocation(Hook)]; false -> - rebar_api:info("~p hook is not allowed in the ~p phase, ignoring it", - [Hook, Phase]), + ec_cmd_log:error( + rlx_state:log(State), + io_lib:format("~p hook is not allowed in the ~p phase, ignoring it", [Hook, Phase]) + ), + Acc0 end end, [], Hooks0), - expand_hooks(BinDir, Rest, Acc ++ [{Phase, Hooks}]). + expand_hooks(BinDir, Rest, Acc ++ [{Phase, Hooks}], State). %% the pid script hook is only allowed in the %% post_start phase @@ -496,10 +500,14 @@ hook_template({wait_for_process, _}) -> builtin_hook_wait_for_process. %% custom hooks are not rendered, they should %% be copied by the release overlays -render_hook(custom, _) -> ok; -render_hook(TemplateName, Script) -> - rebar_api:debug("rendering ~p hook to ~p", - [TemplateName, Script]), +render_hook(custom, _, _) -> ok; +render_hook(TemplateName, Script, State) -> + ec_cmd_log:info( + rlx_state:log(State), + "rendering ~p hook to ~p~n", + [TemplateName, Script] + ), + Template = render(TemplateName), ok = filelib:ensure_dir(Script), _ = ec_file:remove(Script), |