aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/rcl_prv_config.erl4
-rw-r--r--src/rcl_prv_discover.erl17
-rw-r--r--src/rcl_prv_release.erl1
-rw-r--r--src/rcl_rel_discovery.erl6
-rw-r--r--src/rcl_release.erl11
-rw-r--r--src/rcl_state.erl8
-rw-r--r--src/rcl_util.erl5
-rw-r--r--src/relcool.erl25
8 files changed, 55 insertions, 22 deletions
diff --git a/src/rcl_prv_config.erl b/src/rcl_prv_config.erl
index 5d51300..60655b1 100644
--- a/src/rcl_prv_config.erl
+++ b/src/rcl_prv_config.erl
@@ -46,9 +46,9 @@ init(State) ->
-spec do(rcl_state:t()) ->{ok, rcl_state:t()} | relcool:error().
do(State) ->
case rcl_state:config_file(State) of
- [] ->
+ undefined ->
search_for_dominating_config(State);
- ConfigFile ->
+ ConfigFile when erlang:is_list(ConfigFile) ->
load_config(ConfigFile, State)
end.
diff --git a/src/rcl_prv_discover.erl b/src/rcl_prv_discover.erl
index c5a625d..2f88354 100644
--- a/src/rcl_prv_discover.erl
+++ b/src/rcl_prv_discover.erl
@@ -48,9 +48,8 @@ do(State0) ->
case rcl_rel_discovery:do(State0, LibDirs, AppMeta) of
{ok, Releases} ->
State1 = rcl_state:available_apps(State0, AppMeta),
- State3 = lists:foldl(fun(Rel, State2) ->
- rcl_state:add_release(State2, Rel)
- end, State1, Releases),
+ State3 = lists:foldl(fun add_if_not_found/2,
+ State1, Releases),
{ok, State3};
Error ->
Error
@@ -68,6 +67,18 @@ format_error(_) ->
%%%===================================================================
%%% Internal Functions
%%%===================================================================
+%% @doc only add the release if its not documented in the system
+add_if_not_found(Rel, State) ->
+ RelName = rcl_release:name(Rel),
+ RelVsn = rcl_release:vsn(Rel),
+ try
+ rcl_state:get_release(State, RelName, RelVsn),
+ State
+ catch
+ throw:not_found ->
+ rcl_state:add_release(State, Rel)
+ end.
+
get_lib_dirs(State) ->
LibDirs0 = rcl_state:lib_dirs(State),
case rcl_state:get(State, disable_default_libs, false) of
diff --git a/src/rcl_prv_release.erl b/src/rcl_prv_release.erl
index 4574a0e..eac1f20 100644
--- a/src/rcl_prv_release.erl
+++ b/src/rcl_prv_release.erl
@@ -143,7 +143,6 @@ solve_release(State0, DepGraph, RelName, RelVsn) ->
"Solving Release ~p-~s~n",
[RelName, RelVsn]),
try
- io:format("Solving ~p ~p", [RelName, RelVsn]),
Release = rcl_state:get_release(State0, RelName, RelVsn),
Goals = rcl_release:goals(Release),
case Goals of
diff --git a/src/rcl_rel_discovery.erl b/src/rcl_rel_discovery.erl
index 0fbcf23..0f923a0 100644
--- a/src/rcl_rel_discovery.erl
+++ b/src/rcl_rel_discovery.erl
@@ -144,7 +144,7 @@ resolve_apps([], _AppMeta, Release, Acc) ->
rcl_release:application_details(Release, Acc);
resolve_apps([AppInfo | Apps], AppMeta, Release, Acc) ->
AppName = erlang:element(1, AppInfo),
- AppVsn = erlang:element(2, AppInfo),
+ AppVsn = ec_semver:parse(erlang:element(2, AppInfo)),
case find_app(AppName, AppVsn, AppMeta) of
Error = {error, _} ->
Error;
@@ -154,8 +154,8 @@ resolve_apps([AppInfo | Apps], AppMeta, Release, Acc) ->
find_app(AppName, AppVsn, AppMeta) ->
case ec_lists:find(fun(App) ->
- NAppName = rcl_app:name(App),
- NAppVsn = rcl_app:version(App),
+ NAppName = rcl_app_info:name(App),
+ NAppVsn = rcl_app_info:vsn(App),
AppName == NAppName andalso
AppVsn == NAppVsn
end, AppMeta) of
diff --git a/src/rcl_release.erl b/src/rcl_release.erl
index ea20f1f..97465d0 100644
--- a/src/rcl_release.erl
+++ b/src/rcl_release.erl
@@ -89,7 +89,7 @@
%%============================================================================
-spec new(atom(), string()) -> t().
new(ReleaseName, ReleaseVsn) ->
- #release_t{name=ReleaseName, vsn=ReleaseVsn,
+ #release_t{name=to_atom(ReleaseName), vsn=ReleaseVsn,
annotations=ec_dictionary:new(ec_dict)}.
-spec name(t()) -> atom().
@@ -170,7 +170,7 @@ format(Release) ->
format(Indent, #release_t{name=Name, vsn=Vsn, erts=ErtsVsn, realized=Realized,
goals = Goals, applications=Apps}) ->
BaseIndent = rcl_util:indent(Indent),
- [BaseIndent, "release: ", erlang:atom_to_list(Name), "-", Vsn, "\n",
+ [BaseIndent, "release: ", rcl_util:to_string(Name), "-", Vsn, "\n",
rcl_util:indent(Indent + 1), " erts-", ErtsVsn,
", realized = ", erlang:atom_to_list(Realized), "\n",
BaseIndent, "goals: \n",
@@ -380,3 +380,10 @@ parse_version({AppName, Version, Constraint0, Constraint1})
{AppName, rcl_depsolver:parse_version(Version), Constraint1, Constraint0};
parse_version(Constraint) ->
Constraint.
+
+to_atom(RelName)
+ when erlang:is_list(RelName) ->
+ erlang:list_to_atom(RelName);
+to_atom(Else)
+ when erlang:is_atom(Else) ->
+ Else.
diff --git a/src/rcl_state.erl b/src/rcl_state.erl
index 25497f8..6fd5655 100644
--- a/src/rcl_state.erl
+++ b/src/rcl_state.erl
@@ -65,7 +65,7 @@
action :: atom(),
output_dir :: file:name(),
lib_dirs=[] :: [file:name()],
- config_file=[] :: file:filename(),
+ config_file=[] :: file:filename() | undefined,
goals=[] :: [rcl_depsolver:constraint()],
providers = [] :: [rcl_provider:t()],
available_apps = [] :: [rcl_app_info:t()],
@@ -102,7 +102,7 @@ new(PropList, Target)
#state_t{log = proplists:get_value(log, PropList, rcl_log:new(error)),
output_dir=proplists:get_value(output_dir, PropList, ""),
lib_dirs=proplists:get_value(lib_dirs, PropList, ""),
- config_file=proplists:get_value(config, PropList, ""),
+ config_file=proplists:get_value(config, PropList, undefined),
action = Target,
goals=proplists:get_value(goals, PropList, []),
providers = [],
@@ -143,11 +143,11 @@ lib_dirs(#state_t{lib_dirs=LibDir}) ->
goals(#state_t{goals=TS}) ->
TS.
--spec config_file(t()) -> file:filename().
+-spec config_file(t()) -> file:filename() | undefined.
config_file(#state_t{config_file=ConfigFiles}) ->
ConfigFiles.
--spec config_file(t(), file:filename()) -> t().
+-spec config_file(t(), file:filename() | undefined) -> t().
config_file(State, ConfigFiles) ->
State#state_t{config_file=ConfigFiles}.
diff --git a/src/rcl_util.erl b/src/rcl_util.erl
index a879c58..61e1392 100644
--- a/src/rcl_util.erl
+++ b/src/rcl_util.erl
@@ -23,6 +23,7 @@
-export([mkdir_p/1,
to_binary/1,
+ to_string/1,
is_error/1,
error_reason/1,
indent/1,
@@ -57,6 +58,10 @@ to_binary(String) when erlang:is_list(String) ->
erlang:iolist_to_binary(String);
to_binary(Bin) when erlang:is_binary(Bin) ->
Bin.
+to_string(Atom) when erlang:is_atom(Atom) ->
+ erlang:atom_to_list(Atom);
+to_string(Else) when erlang:is_list(Else) ->
+ Else.
%% @doc get the reason for a particular relcool error
-spec error_reason(relcool:error()) -> any().
diff --git a/src/relcool.erl b/src/relcool.erl
index 83886c5..c8c0cde 100644
--- a/src/relcool.erl
+++ b/src/relcool.erl
@@ -44,12 +44,20 @@
-spec main([string()]) -> ok | error() | {ok, rcl_state:t()}.
main(Args) ->
OptSpecList = opt_spec_list(),
- case rcl_cmd_args:args2state(getopt:parse(OptSpecList, Args)) of
- {ok, State} ->
- run_relcool_process(rcl_state:caller(State, command_line));
- Error={error, _} ->
+ Result =
+ case rcl_cmd_args:args2state(getopt:parse(OptSpecList, Args)) of
+ {ok, State} ->
+ run_relcool_process(rcl_state:caller(State, command_line));
+ Error={error, _} ->
+ Error
+ end,
+ case Result of
+ {error, _} ->
report_error(rcl_state:caller(rcl_state:new([], undefined),
- command_line), Error)
+ command_line),
+ Result);
+ _ ->
+ Result
end.
%% @doc provides an API to run the Relcool process from erlang applications
@@ -128,7 +136,7 @@ opt_spec_list() ->
"Disable the default system added lib dirs (means you must add them all manually"},
{log_level, $V, "verbose", {integer, 1},
"Verbosity level, maybe between 0 and 2"},
- {config, $c, "config", string, "The path to a config file"},
+ {config, $c, "config", {string, ""}, "The path to a config file"},
{root_dir, $r, "root", string, "The project root directory"}].
-spec format_error(Reason::term()) -> iolist().
@@ -194,9 +202,12 @@ run_provider(Provider, {ok, State0}) ->
[rcl_provider:impl(Provider)]),
case rcl_provider:do(Provider, State0) of
{ok, State1} ->
+ rcl_log:debug(rcl_state:log(State0), "Provider successfully run: ~p~n",
+ [rcl_provider:impl(Provider)]),
{ok, State1};
E={error, _} ->
-
+ rcl_log:debug(rcl_state:log(State0), "Provider (~p) failed with: ~p~n",
+ [rcl_provider:impl(Provider), E]),
E
end.