aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/rlx_prv_release.erl61
1 files changed, 39 insertions, 22 deletions
diff --git a/src/rlx_prv_release.erl b/src/rlx_prv_release.erl
index 95a31e8..a6d9fef 100644
--- a/src/rlx_prv_release.erl
+++ b/src/rlx_prv_release.erl
@@ -57,14 +57,16 @@ do(State) ->
-spec format_error(ErrorDetail::term()) -> iolist().
format_error(no_goals_specified) ->
"No goals specified for this release ~n";
+format_error({release_erts_error, Dir}) ->
+ io_lib:format("Unable to find erts in ~s~n", [Dir]);
format_error({no_release_name, Vsn}) ->
io_lib:format("A target release version was specified (~s) but no name", [Vsn]);
format_error({invalid_release_info, Info}) ->
io_lib:format("Target release information is in an invalid format ~p", [Info]);
format_error({multiple_release_names, RelA, RelB}) ->
io_lib:format("No default release name was specified and there are multiple "
- "releases in the config: ~s, ~s",
- [RelA, RelB]);
+ "releases in the config: ~s, ~s",
+ [RelA, RelB]);
format_error(no_releases_in_system) ->
"No releases have been specified in the system!";
format_error({no_releases_for, RelName}) ->
@@ -73,7 +75,10 @@ format_error({release_not_found, {RelName, RelVsn}}) ->
io_lib:format("No releases exist in the system for ~p:~s!", [RelName, RelVsn]);
format_error({failed_solve, Error}) ->
io_lib:format("Failed to solve release:\n ~s",
- [rlx_depsolver:format_error({error, Error})]).
+ [rlx_depsolver:format_error({error, Error})]);
+format_error({release_error, Error}) ->
+ io_lib:format("Failed to resolve release:\n ~p~n", [Error]).
+
%%%===================================================================
%%% Internal Functions
@@ -88,9 +93,9 @@ create_dep_graph(State) ->
Deps = rlx_app_info:active_deps(App) ++
rlx_app_info:library_deps(App),
rlx_depsolver:add_package_version(Graph1,
- AppName,
- AppVsn,
- Deps)
+ AppName,
+ AppVsn,
+ Deps)
end, Graph0, Apps).
@@ -154,8 +159,8 @@ release_sort({{RelA, _}, _}, {{RelB, _}, _}) ->
solve_release(State0, DepGraph, RelName, RelVsn) ->
ec_cmd_log:debug(rlx_state:log(State0),
- "Solving Release ~p-~s~n",
- [RelName, RelVsn]),
+ "Solving Release ~p-~s~n",
+ [RelName, RelVsn]),
try
Release =
case get_realized_release(State0, RelName, RelVsn) of
@@ -182,20 +187,32 @@ solve_release(State0, DepGraph, RelName, RelVsn) ->
end.
set_resolved(State, Release0, Pkgs) ->
- case rlx_release:realize(Release0, Pkgs, rlx_state:available_apps(State)) of
- {ok, Release1} ->
- ec_cmd_log:info(rlx_state:log(State),
- "Resolved ~p-~s~n",
- [rlx_release:name(Release1),
- rlx_release:vsn(Release1)]),
- ec_cmd_log:debug(rlx_state:log(State),
- fun() ->
- rlx_release:format(0, Release1)
- end),
- {ok, rlx_state:add_realized_release(State, Release1)};
- {error, E} ->
- ?RLX_ERROR({release_error, E})
- end.
+ case rlx_release:realize(Release0, Pkgs, rlx_state:available_apps(State)) of
+ {ok, Release1} ->
+ ec_cmd_log:info(rlx_state:log(State),
+ "Resolved ~p-~s~n",
+ [rlx_release:name(Release1),
+ rlx_release:vsn(Release1)]),
+ ec_cmd_log:debug(rlx_state:log(State),
+ fun() ->
+ rlx_release:format(0, Release1)
+ end),
+ case rlx_state:get(State, include_erts, undefined) of
+ IncludeErts when is_atom(IncludeErts) ->
+ {ok, rlx_state:add_realized_release(State, Release1)};
+ ErtsDir ->
+ try
+ [Erts | _] = filelib:wildcard(filename:join(ErtsDir, "erts-*")),
+ [_, ErtsVsn] = string:tokens(filename:basename(Erts), "-"),
+ {ok, rlx_state:add_realized_release(State, rlx_release:erts(Release1, ErtsVsn))}
+ catch
+ _:_ ->
+ ?RLX_ERROR({release_erts_error, ErtsDir})
+ end
+ end;
+ {error, E} ->
+ ?RLX_ERROR({release_error, E})
+ end.
get_realized_release(State, RelName, RelVsn) ->
try