aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/rlx_config.erl59
-rw-r--r--src/rlx_prv_release.erl6
-rw-r--r--src/rlx_release.erl14
3 files changed, 60 insertions, 19 deletions
diff --git a/src/rlx_config.erl b/src/rlx_config.erl
index b2de094..62a0cdb 100644
--- a/src/rlx_config.erl
+++ b/src/rlx_config.erl
@@ -27,6 +27,8 @@
-export([do/1,
format_error/1]).
+-export([load_terms/2]).
+
-include("relx.hrl").
%%%===================================================================
@@ -196,17 +198,21 @@ load_terms({release, {RelName, Vsn, {extend, RelName2}}, Applications}, {ok, Sta
{ok, Release1} ->
{ok, rlx_state:add_configured_release(State0, Release1)}
end;
-load_terms({release, {RelName, Vsn}, Applications}, {ok, State0}) ->
+load_terms({release, {RelName, Vsn, {extend, RelName2}}, Applications, Config}, {ok, State0}) ->
NewVsn = parse_vsn(Vsn),
Release0 = rlx_release:new(RelName, NewVsn),
- case rlx_release:goals(Release0, Applications) of
+ ExtendRelease = rlx_state:get_configured_release(State0, RelName2, NewVsn),
+ Applications1 = rlx_release:goals(ExtendRelease),
+ case rlx_release:goals(Release0,
+ lists:umerge(lists:usort(Applications),
+ lists:usort(Applications1))) of
E={error, _} ->
E;
{ok, Release1} ->
- {ok, rlx_state:add_configured_release(State0, Release1)}
+ Release2 = rlx_release:config(Release1, Config),
+ {ok, rlx_state:add_configured_release(State0, Release2)}
end;
-load_terms({release, {RelName, Vsn}, {erts, ErtsVsn},
- Applications}, {ok, State}) ->
+load_terms({release, {RelName, Vsn}, {erts, ErtsVsn}, Applications}, {ok, State}) ->
NewVsn = parse_vsn(Vsn),
Release0 = rlx_release:erts(rlx_release:new(RelName, NewVsn), ErtsVsn),
case rlx_release:goals(Release0, Applications) of
@@ -215,20 +221,39 @@ load_terms({release, {RelName, Vsn}, {erts, ErtsVsn},
{ok, Release1} ->
{ok, rlx_state:add_configured_release(State, Release1)}
end;
-load_terms({vm_args, VmArgs}, {ok, State}) ->
- case rlx_state:vm_args(State) of
- undefined ->
- {ok, rlx_state:vm_args(State, filename:absname(VmArgs))};
- _ ->
- {ok, State}
+load_terms({release, {RelName, Vsn}, {erts, ErtsVsn}, Applications, Config}, {ok, State}) ->
+ NewVsn = parse_vsn(Vsn),
+ Release0 = rlx_release:erts(rlx_release:new(RelName, NewVsn), ErtsVsn),
+ case rlx_release:goals(Release0, Applications) of
+ E={error, _} ->
+ E;
+ {ok, Release1} ->
+ Release2 = rlx_release:config(Release1, Config),
+ {ok, rlx_state:add_configured_release(State, Release2)}
end;
+load_terms({release, {RelName, Vsn}, Applications}, {ok, State0}) ->
+ NewVsn = parse_vsn(Vsn),
+ Release0 = rlx_release:new(RelName, NewVsn),
+ case rlx_release:goals(Release0, Applications) of
+ E={error, _} ->
+ E;
+ {ok, Release1} ->
+ {ok, rlx_state:add_configured_release(State0, Release1)}
+ end;
+load_terms({release, {RelName, Vsn}, Applications, Config}, {ok, State0}) ->
+ NewVsn = parse_vsn(Vsn),
+ Release0 = rlx_release:new(RelName, NewVsn),
+ case rlx_release:goals(Release0, Applications) of
+ E={error, _} ->
+ E;
+ {ok, Release1} ->
+ Release2 = rlx_release:config(Release1, Config),
+ {ok, rlx_state:add_configured_release(State0, Release2)}
+ end;
+load_terms({vm_args, VmArgs}, {ok, State}) ->
+ {ok, rlx_state:vm_args(State, filename:absname(VmArgs))};
load_terms({sys_config, SysConfig}, {ok, State}) ->
- case rlx_state:sys_config(State) of
- undefined ->
- {ok, rlx_state:sys_config(State, filename:absname(SysConfig))};
- _ ->
- {ok, State}
- end;
+ {ok, rlx_state:sys_config(State, filename:absname(SysConfig))};
load_terms({root_dir, Root}, {ok, State}) ->
{ok, rlx_state:root_dir(State, filename:absname(Root))};
load_terms({output_dir, OutputDir}, {ok, State}) ->
diff --git a/src/rlx_prv_release.erl b/src/rlx_prv_release.erl
index f83cce3..5feb798 100644
--- a/src/rlx_prv_release.erl
+++ b/src/rlx_prv_release.erl
@@ -164,6 +164,10 @@ solve_release(State0, DepGraph, RelName, RelVsn) ->
{ok, Release0} ->
rlx_release:relfile(rlx_state:get_configured_release(State0, RelName, RelVsn), rlx_release:relfile(Release0))
end,
+
+ %% get per release config values and override the State with them
+ Config = rlx_release:config(Release),
+ {ok, State1} = lists:foldl(fun rlx_config:load_terms/2, {ok, State0}, Config),
Goals = rlx_release:goals(Release),
case Goals of
[] ->
@@ -171,7 +175,7 @@ solve_release(State0, DepGraph, RelName, RelVsn) ->
_ ->
case rlx_depsolver:solve(DepGraph, Goals) of
{ok, Pkgs} ->
- set_resolved(State0, Release, Pkgs);
+ set_resolved(State1, Release, Pkgs);
{error, Error} ->
?RLX_ERROR({failed_solve, Error})
end
diff --git a/src/rlx_release.erl b/src/rlx_release.erl
index 97187a6..bf14a9e 100644
--- a/src/rlx_release.erl
+++ b/src/rlx_release.erl
@@ -40,6 +40,8 @@
metadata/1,
start_clean_metadata/1,
canonical_name/1,
+ config/1,
+ config/2,
format/1,
format/2,
format_error/1]).
@@ -63,7 +65,8 @@
annotations = undefined :: annotations(),
applications = [] :: [application_spec()],
relfile :: undefined | string(),
- app_detail = [] :: [rlx_app_info:t()]}).
+ app_detail = [] :: [rlx_app_info:t()],
+ config = []}).
%%============================================================================
%% types
@@ -201,6 +204,15 @@ canonical_name(#release_t{name=Name, vsn=Vsn}) ->
erlang:binary_to_list(erlang:iolist_to_binary([erlang:atom_to_list(Name), "-",
Vsn])).
+
+-spec config(t(), list()) -> t().
+config(Release, Config) ->
+ Release#release_t{config=Config}.
+
+-spec config(t()) -> list().
+config(#release_t{config=Config}) ->
+ Config.
+
-spec format(t()) -> iolist().
format(Release) ->
format(0, Release).