diff options
author | Tristan Sloughter <[email protected]> | 2017-02-02 10:18:20 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2017-02-02 10:18:20 -0800 |
commit | d3d9bc73afaf4b145d7e6d484096534b297faf7f (patch) | |
tree | 3e7231591577f6b6a3b3d24e7400fac16db8f317 | |
parent | a4d7fa1914dd0ea6c53221c3a4056fc23a7bde9d (diff) | |
parent | 59ace4da2dbc317a922f3ef0022ccc0455b882da (diff) | |
download | relx-d3d9bc73afaf4b145d7e6d484096534b297faf7f.tar.gz relx-d3d9bc73afaf4b145d7e6d484096534b297faf7f.tar.bz2 relx-d3d9bc73afaf4b145d7e6d484096534b297faf7f.zip |
Merge pull request #559 from lrascao/feature/fix_crash_on_relup_warning
Feature/fix crash on relup warning
-rw-r--r-- | src/rlx_cmd_args.erl | 3 | ||||
-rw-r--r-- | src/rlx_config.erl | 2 | ||||
-rw-r--r-- | src/rlx_prv_relup.erl | 37 | ||||
-rw-r--r-- | src/rlx_state.erl | 16 |
4 files changed, 52 insertions, 6 deletions
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl index 7f3f39b..b20344c 100644 --- a/src/rlx_cmd_args.erl +++ b/src/rlx_cmd_args.erl @@ -282,6 +282,9 @@ create(include_erts, Opts) -> Erts when is_list(Erts) -> {include_erts, Erts} end; +create(warnings_as_errors, Opts) -> + WarningsAsErrors = proplists:get_value(warnings_as_errors, Opts, false), + {warnings_as_errors, WarningsAsErrors}; create(_, _) -> []. diff --git a/src/rlx_config.erl b/src/rlx_config.erl index dfcb511..b5ef51b 100644 --- a/src/rlx_config.erl +++ b/src/rlx_config.erl @@ -269,6 +269,8 @@ load_terms({overlay_vars, OverlayVars}, {ok, State}) -> NewOverlayVars0 = list_of_overlay_vars_files(OverlayVars), NewOverlayVars1 = CurrentOverlayVars ++ NewOverlayVars0, {ok, rlx_state:put(State, overlay_vars, NewOverlayVars1)}; +load_terms({warnings_as_errors, WarningsAsErrors}, {ok, State}) -> + {ok, rlx_state:warnings_as_errors(State, WarningsAsErrors)}; load_terms({Name, Value}, {ok, State}) when erlang:is_atom(Name) -> {ok, rlx_state:put(State, Name, Value)}; diff --git a/src/rlx_prv_relup.erl b/src/rlx_prv_relup.erl index 9ac2135..1f8a950 100644 --- a/src/rlx_prv_relup.erl +++ b/src/rlx_prv_relup.erl @@ -65,6 +65,15 @@ format_error({relup_script_generation_error, {missing_sasl, _}}}) -> "Unfortunately, due to requirements in systools, you need to have the sasl application " "in both the current release and the release to upgrade from."; +format_error({relup_script_generation_warn, systools_relup, + [{erts_vsn_changed, _}, + {erts_vsn_changed, _}]}) -> + "It has been detected that the ERTS version changed while generating the relup between versions, " + "please be aware that an instruction that will automatically restart the VM will be inserted in " + "this case"; +format_error({relup_script_generation_warn, Module, Warnings}) -> + ["Warnings generating relup \n", + rlx_util:indent(2), Module:format_warning(Warnings)]; format_error({relup_script_generation_error, Module, Errors}) -> ["Errors generating relup \n", rlx_util:indent(2), Module:format_error(Errors)]. @@ -119,10 +128,20 @@ get_up_release(State, Release, Vsn) -> make_upfrom_script(State, Release, UpFrom) -> OutputDir = rlx_state:output_dir(State), + WarningsAsErrors = rlx_state:warnings_as_errors(State), Options = [{outdir, OutputDir}, {path, rlx_util:get_code_paths(Release, OutputDir) ++ rlx_util:get_code_paths(UpFrom, OutputDir)}, silent], + %% the following block can be uncommented + %% when systools:make_relup/4 returns + %% {error,Module,Errors} instead of error + %% when taking the warnings_as_errors option + %% ++ + %% case WarningsAsErrors of + %% true -> [warnings_as_errors]; + %% false -> [] + % end, CurrentRel = strip_rel(rlx_release:relfile(Release)), UpFromRel = strip_rel(rlx_release:relfile(UpFrom)), ec_cmd_log:debug(rlx_state:log(State), @@ -138,14 +157,26 @@ make_upfrom_script(State, Release, UpFrom) -> [UpFromRel, CurrentRel]), {ok, State}; error -> - ?RLX_ERROR({relup_script_generation_error, CurrentRel, UpFromRel}); + ?RLX_ERROR({relup_generation_error, CurrentRel, UpFromRel}); {ok, RelUp, _, []} -> write_relup_file(State, Release, RelUp), ec_cmd_log:info(rlx_state:log(State), "relup successfully created!"), {ok, State}; - {ok,_, Module,Warnings} -> - ?RLX_ERROR({relup_script_generation_warn, Module, Warnings}); + {ok, RelUp, Module,Warnings} -> + case WarningsAsErrors of + true -> + %% since we don't pass the warnings_as_errors option + %% the relup file gets generated anyway, we need to delete + %% it + file:delete(filename:join([OutputDir, "relup"])), + ?RLX_ERROR({relup_script_generation_warn, Module, Warnings}); + false -> + write_relup_file(State, Release, RelUp), + ec_cmd_log:warn(rlx_state:log(State), + format_error({relup_script_generation_warn, Module, Warnings})), + {ok, State} + end; {error,Module,Errors} -> ?RLX_ERROR({relup_script_generation_error, Module, Errors}) end. diff --git a/src/rlx_state.erl b/src/rlx_state.erl index 75a5cba..5032628 100644 --- a/src/rlx_state.erl +++ b/src/rlx_state.erl @@ -84,8 +84,9 @@ format/1, format/2, exclude_modules/1, - exclude_modules/2]). - + exclude_modules/2, + warnings_as_errors/1, + warnings_as_errors/2]). -export_type([t/0, releases/0, @@ -117,7 +118,8 @@ include_src=true :: boolean(), upfrom :: string() | binary() | undefined, config_values :: ec_dictionary:dictionary(Key::atom(), - Value::term())}). + Value::term()), + warnings_as_errors=false :: boolean()}). %%============================================================================ %% types @@ -454,6 +456,14 @@ hooks(_State=#state_t{providers=Providers}, Target) -> Provider = providers:get_provider(Target, Providers), providers:hooks(Provider). +-spec warnings_as_errors(t()) -> boolean(). +warnings_as_errors(#state_t{warnings_as_errors=WarningsAsErrors}) -> + WarningsAsErrors. + +-spec warnings_as_errors(t(), boolean()) -> t(). +warnings_as_errors(State, WarningsAsErrors) -> + State#state_t{warnings_as_errors=WarningsAsErrors}. + %% =================================================================== %% Internal functions %% =================================================================== |