aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJordan Wilberding <[email protected]>2015-01-31 16:24:06 -0800
committerJordan Wilberding <[email protected]>2015-01-31 16:24:06 -0800
commit5a0d655eb52b45a8d382d6b75b1061e3025614ed (patch)
tree6b5e7e30af04d482490f564024e8027cec99b88f /src
parent3a6b64302bd05441b942da56f5f5deed9b0c58b0 (diff)
parent292eea4c105adb03e0745468db6bb4948e6df98d (diff)
downloadrelx-5a0d655eb52b45a8d382d6b75b1061e3025614ed.tar.gz
relx-5a0d655eb52b45a8d382d6b75b1061e3025614ed.tar.bz2
relx-5a0d655eb52b45a8d382d6b75b1061e3025614ed.zip
Merge pull request #307 from tsloughter/master
Mainly exclude_apps
Diffstat (limited to 'src')
-rw-r--r--src/rlx_app_discovery.erl11
-rw-r--r--src/rlx_config.erl2
-rw-r--r--src/rlx_prv_assembler.erl44
-rw-r--r--src/rlx_state.erl12
4 files changed, 65 insertions, 4 deletions
diff --git a/src/rlx_app_discovery.erl b/src/rlx_app_discovery.erl
index 6ac8d11..3d58185 100644
--- a/src/rlx_app_discovery.erl
+++ b/src/rlx_app_discovery.erl
@@ -118,8 +118,10 @@ resolve_app_metadata(State, LibDirs) ->
end] of
[] ->
SkipApps = rlx_state:skip_apps(State),
- AppMeta1 = [App || {ok, App} <- setup_overrides(State, AppMeta0),
- not lists:keymember(rlx_app_info:name(App), 1, SkipApps)],
+ ExcludeApps = rlx_state:exclude_apps(State),
+ AppMeta1 = [rm_exclude_apps(App, ExcludeApps) ||
+ {ok, App} <- setup_overrides(State, AppMeta0),
+ not lists:keymember(rlx_app_info:name(App), 1, SkipApps++ExcludeApps)],
ec_cmd_log:debug(rlx_state:log(State),
fun() ->
["Resolved the following OTP Applications from the system: \n",
@@ -129,6 +131,11 @@ resolve_app_metadata(State, LibDirs) ->
Errors ->
?RLX_ERROR(Errors)
end.
+%% Apps listed in {exclude_apps, [...]} must be removed from applications lists
+rm_exclude_apps(App, ExcludeApps) ->
+ ActiveApps = lists:subtract(rlx_app_info:active_deps(App), ExcludeApps),
+ LibraryApps = lists:subtract(rlx_app_info:library_deps(App), ExcludeApps),
+ rlx_app_info:library_deps(rlx_app_info:active_deps(App, ActiveApps), LibraryApps).
app_name({warning, _}) ->
undefined;
diff --git a/src/rlx_config.erl b/src/rlx_config.erl
index 045bf33..df08342 100644
--- a/src/rlx_config.erl
+++ b/src/rlx_config.erl
@@ -182,6 +182,8 @@ load_terms({add_providers, Providers0}, {ok, State0}) ->
end;
load_terms({skip_apps, SkipApps0}, {ok, State0}) ->
{ok, rlx_state:skip_apps(State0, SkipApps0)};
+load_terms({exclude_apps, ExcludeApps0}, {ok, State0}) ->
+ {ok, rlx_state:exclude_apps(State0, ExcludeApps0)};
load_terms({debug_info, DebugInfo}, {ok, State0}) ->
{ok, rlx_state:debug_info(State0, DebugInfo)};
load_terms({overrides, Overrides0}, {ok, State0}) ->
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl
index ee81631..9799204 100644
--- a/src/rlx_prv_assembler.erl
+++ b/src/rlx_prv_assembler.erl
@@ -203,9 +203,49 @@ copy_app_(App, AppDir, TargetDir, IncludeSrc) ->
remove_symlink_or_directory(TargetDir),
case rlx_app_info:link(App) of
true ->
- link_directory(AppDir, TargetDir);
+ link_directory(AppDir, TargetDir),
+ rewrite_app_file(App, AppDir);
false ->
- copy_directory(AppDir, TargetDir, IncludeSrc)
+ copy_directory(AppDir, TargetDir, IncludeSrc),
+ rewrite_app_file(App, TargetDir)
+ end.
+
+%% If excluded apps exist in this App's applications list we must write a new .app
+rewrite_app_file(App, TargetDir) ->
+ Name = rlx_app_info:name(App),
+ ActiveDeps = rlx_app_info:active_deps(App),
+ IncludedDeps = rlx_app_info:library_deps(App),
+ AppFile = filename:join([TargetDir, "ebin", ec_cnv:to_list(Name) ++ ".app"]),
+
+ {ok, [{application, AppName, AppData}]} = file:consult(AppFile),
+ OldActiveDeps = proplists:get_value(applications, AppData, []),
+ OldIncludedDeps = proplists:get_value(included_applications, AppData, []),
+
+ case {OldActiveDeps, OldIncludedDeps} of
+ {ActiveDeps, IncludedDeps} ->
+ ok;
+ _ ->
+ AppData1 = lists:keyreplace(applications
+ ,1
+ ,AppData
+ ,{applications, ActiveDeps}),
+ AppData2 = lists:keyreplace(included_applications
+ ,1
+ ,AppData1
+ ,{included_applications, IncludedDeps}),
+ Spec = io_lib:format("~p.\n", [{application, AppName, AppData2}]),
+ write_file_if_contents_differ(AppFile, Spec)
+ end.
+
+write_file_if_contents_differ(Filename, Bytes) ->
+ ToWrite = iolist_to_binary(Bytes),
+ case file:read_file(Filename) of
+ {ok, ToWrite} ->
+ ok;
+ {ok, _} ->
+ file:write_file(Filename, ToWrite);
+ {error, _} ->
+ file:write_file(Filename, ToWrite)
end.
remove_symlink_or_directory(TargetDir) ->
diff --git a/src/rlx_state.erl b/src/rlx_state.erl
index f21b682..3bd818a 100644
--- a/src/rlx_state.erl
+++ b/src/rlx_state.erl
@@ -36,6 +36,8 @@
overrides/2,
skip_apps/1,
skip_apps/2,
+ exclude_apps/1,
+ exclude_apps/2,
debug_info/1,
debug_info/2,
goals/1,
@@ -104,6 +106,7 @@
sys_config :: file:filename() | undefined,
overrides=[] :: [{AppName::atom(), Directory::file:filename()}],
skip_apps=[] :: [AppName::atom()],
+ exclude_apps=[] :: [AppName::atom()],
debug_info=keep :: keep | strip,
configured_releases :: releases(),
realized_releases :: releases(),
@@ -186,6 +189,15 @@ skip_apps(#state_t{skip_apps=Apps}) ->
skip_apps(State, SkipApps) ->
State#state_t{skip_apps=SkipApps}.
+-spec exclude_apps(t()) -> [AppName::atom()].
+exclude_apps(#state_t{exclude_apps=Apps}) ->
+ Apps.
+
+%% @doc the application overrides for the system
+-spec exclude_apps(t(), [AppName::atom()]) -> t().
+exclude_apps(State, SkipApps) ->
+ State#state_t{exclude_apps=SkipApps}.
+
-spec debug_info(t()) -> keep | strip.
debug_info(#state_t{debug_info=DebugInfo}) ->
DebugInfo.