summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGerhard Lazu <gerhard@rabbitmq.com>2016-12-20 17:22:12 +0000
committerJean-Sébastien Pedron <jean-sebastien@rabbitmq.com>2016-12-20 17:22:12 +0000
commitcbbcc3e32f97b6047b4f82f0776717dd3e85430c (patch)
treee200bdda2a3cd9a6a07ae7b5c2a9f12a99a7161c /src
parentbc1011d0ea93591bb01faf105a58d05cdc1bea76 (diff)
downloadrabbitmq-server-git-cbbcc3e32f97b6047b4f82f0776717dd3e85430c.tar.gz
Ignore indirect dependencies of rabbit in rabbit_plugins
The goal of maybe_keep_required_deps() is still the same: we don't want to list applications from $RABBITMQ_PLUGINS_DIR the rabbit application depends on. Now, the function handles indirect dependencies. Signed-off-by: Jean-Sébastien Pedron <jean-sebastien@rabbitmq.com> [#136346167]
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_plugins.erl25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl
index 40dbf91cfd..171448b05c 100644
--- a/src/rabbit_plugins.erl
+++ b/src/rabbit_plugins.erl
@@ -608,11 +608,7 @@ remove_duplicate_plugins([Plugin|Rest], {Plugins0, Problems0}) ->
maybe_keep_required_deps(true, Plugins) ->
Plugins;
maybe_keep_required_deps(false, Plugins) ->
- %% We load the "rabbit" application to be sure we can get the
- %% "applications" key. This is required for rabbitmq-plugins for
- %% instance.
- application:load(rabbit),
- {ok, RabbitDeps} = application:get_key(rabbit, applications),
+ RabbitDeps = list_all_deps([rabbit]),
lists:filter(fun
(#plugin{name = Name}) ->
not lists:member(Name, RabbitDeps);
@@ -621,6 +617,25 @@ maybe_keep_required_deps(false, Plugins) ->
end,
Plugins).
+list_all_deps(Applications) ->
+ list_all_deps(Applications, []).
+
+list_all_deps([Application | Applications], Deps) ->
+ %% We load the application to be sure we can get the "applications" key.
+ %% This is required for rabbitmq-plugins for instance.
+ application:load(Application),
+ NewDeps = [Application | Deps],
+ case application:get_key(Application, applications) of
+ {ok, ApplicationDeps} ->
+ RemainingApplications0 = ApplicationDeps ++ Applications,
+ RemainingApplications = RemainingApplications0 -- NewDeps,
+ list_all_deps(RemainingApplications, NewDeps);
+ undefined ->
+ list_all_deps(Applications, NewDeps)
+ end;
+list_all_deps([], Deps) ->
+ Deps.
+
remove_otp_overrideable_plugins(Plugins) ->
lists:filter(fun(P) -> not plugin_provided_by_otp(P) end,
Plugins).