aboutsummaryrefslogtreecommitdiffstats
path: root/src/relcool.erl
diff options
context:
space:
mode:
authorEric <[email protected]>2012-12-07 09:09:17 -0500
committerEric <[email protected]>2012-12-07 09:09:17 -0500
commitaac84f08f2b557ae2a7bf45001c47aec503203ab (patch)
treeb5e1d71e7935e0f1f3a9118638e05c574f8a63aa /src/relcool.erl
parent89e5d70f95f4d23811500d6bf2643714f6c95fa2 (diff)
parent819690cd8bda0f7f91740b8fa5df71256656de52 (diff)
downloadrelx-aac84f08f2b557ae2a7bf45001c47aec503203ab.tar.gz
relx-aac84f08f2b557ae2a7bf45001c47aec503203ab.tar.bz2
relx-aac84f08f2b557ae2a7bf45001c47aec503203ab.zip
Merge remote-tracking branch 'canonical/next'
* canonical/next: fix nasty bug that didn't let relcool output errors make the default output _rel instead of relcool_output allow a user to specify additional opts to erlexec add examples of simple and complete relcool configs make sure ebin is removed on clean add inadvertantly deleted relcool.app.src support travis CI in relcool cleanup the rebar config remove docs (they have been moved to the wiki) all relcool to symlink in 'overridden' apps rcl_prv_discover now supports setting up 'link' type app_info messages support specifing overrides in the configuration support a new 'link' field in rcl_app_info minor cleanup and refactoring for rcl_prv_assembler, rcl_prv_discover
Diffstat (limited to 'src/relcool.erl')
-rw-r--r--src/relcool.erl34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/relcool.erl b/src/relcool.erl
index 44debc9..0d75c62 100644
--- a/src/relcool.erl
+++ b/src/relcool.erl
@@ -22,6 +22,7 @@
-export([main/1,
do/7,
+ do/8,
format_error/1,
opt_spec_list/0]).
@@ -59,15 +60,30 @@ main(Args) ->
%% @param OutputDir - The directory where the release should be built to
%% @param Configs - The list of config files for the system
do(RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Configs) ->
+ do(RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, [], Configs).
+
+%% @doc provides an API to run the Relcool process from erlang applications
+%%
+%% @param RelName - The release name to build (maybe `undefined`)
+%% @param RelVsn - The release version to build (maybe `undefined`)
+%% @param Goals - The release goals for the system in depsolver or Relcool goal
+%% format
+%% @param LibDirs - The library dirs that should be used for the system
+%% @param OutputDir - The directory where the release should be built to
+%% @param Overrides - A list of overrides for the system
+%% @param Configs - The list of config files for the system
+do(RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Overrides, Configs) ->
State = rcl_state:new([{relname, RelName},
{relvsn, RelVsn},
{goals, Goals},
+ {overrides, Overrides},
{output_dir, OutputDir},
{lib_dirs, LibDirs},
{log, rcl_log:new(LogLevel)}],
Configs),
run_relcool_process(rcl_state:caller(State, api)).
+
-spec opt_spec_list() -> [getopt:option_spec()].
opt_spec_list() ->
[
@@ -112,14 +128,17 @@ run_providers(State0) ->
{ok, State1} ->
Providers = rcl_state:providers(State1),
Result = run_providers(ConfigProvider, Providers, State1),
- case rcl_state:caller(State1) of
- command_line ->
- init:stop(0);
- api ->
- Result
- end
+ handle_output(State1, rcl_state:caller(State1), Result)
end.
+handle_output(State, command_line, E={error, _}) ->
+ report_error(State, E),
+ init:stop(127);
+handle_output(_State, command_line, _) ->
+ init:stop(0);
+handle_output(_State, api, Result) ->
+ Result.
+
run_providers(ConfigProvider, Providers, State0) ->
case Providers of
[ConfigProvider | Rest] ->
@@ -135,10 +154,13 @@ run_providers(ConfigProvider, Providers, State0) ->
run_provider(_Provider, Error = {error, _}) ->
Error;
run_provider(Provider, {ok, State0}) ->
+ rcl_log:debug(rcl_state:log(State0), "Running provider ~p~n",
+ [rcl_provider:impl(Provider)]),
case rcl_provider:do(Provider, State0) of
{ok, State1} ->
{ok, State1};
E={error, _} ->
+
E
end.