From 26851a2e1c59124dea325e9a38cda25da463839a Mon Sep 17 00:00:00 2001 From: Eric B Merritt Date: Tue, 5 Feb 2013 16:49:41 -0800 Subject: fix config issues with undefined config --- src/rcl_prv_config.erl | 4 ++-- src/rcl_state.erl | 8 ++++---- 2 files changed, 6 insertions(+), 6 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_state.erl b/src/rcl_state.erl index ecf3115..149b5ab 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}. -- cgit v1.2.3 From a90291da9eb49e36e17c13afc31517bb636e6426 Mon Sep 17 00:00:00 2001 From: Eric B Merritt Date: Tue, 5 Feb 2013 16:49:59 -0800 Subject: fix bug in error reporting by relcool --- src/relcool.erl | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) 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. -- cgit v1.2.3 From 9c88211a86da5812272df0fd0bd82ace3c6232ed Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 6 Feb 2013 14:21:30 -0800 Subject: fix bug in app version comparison --- src/rcl_rel_discovery.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 -- cgit v1.2.3 From 6299d16b6205edfe3eff396ec72ef8566cfabe67 Mon Sep 17 00:00:00 2001 From: Eric B Merritt Date: Tue, 5 Feb 2013 16:51:03 -0800 Subject: fix problem in release names from discovered releases --- src/rcl_release.erl | 11 +++++++++-- src/rcl_util.erl | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) 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_util.erl b/src/rcl_util.erl index 06d957d..9cb20ac 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]). @@ -56,6 +57,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(). -- cgit v1.2.3 From 2436289d373f16648a9768d66a658c42b2a91781 Mon Sep 17 00:00:00 2001 From: Eric B Merritt Date: Tue, 5 Feb 2013 16:51:16 -0800 Subject: remove io:format that some how made it in --- src/rcl_prv_release.erl | 1 - 1 file changed, 1 deletion(-) 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 -- cgit v1.2.3 From 35040be995d9b2f1b3b601e69a998156145e1b35 Mon Sep 17 00:00:00 2001 From: Eric B Merritt Date: Tue, 5 Feb 2013 17:07:21 -0800 Subject: fix bug in on disk overriding the default release --- src/rcl_prv_discover.erl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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 -- cgit v1.2.3