diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-09-09 17:30:41 +0100 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-09-09 17:30:41 +0100 |
| commit | 6a8e57f0de0aaac677ddd0ed65e599905d7afc3e (patch) | |
| tree | ef7f64b250a61575753eca1597b36e6faf894ff4 | |
| parent | b6f9070d915df799b3ad4342a8b73fda28133fd6 (diff) | |
| download | rabbitmq-server-git-6a8e57f0de0aaac677ddd0ed65e599905d7afc3e.tar.gz | |
find plugin dependencies
| -rw-r--r-- | src/rabbit_plugin.erl | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/rabbit_plugin.erl b/src/rabbit_plugin.erl index 9dc7d96f89..d5a6ee3f50 100644 --- a/src/rabbit_plugin.erl +++ b/src/rabbit_plugin.erl @@ -83,9 +83,9 @@ action(enable, ToInstall, _Opts, PluginsDir, PluginsDistDir) -> AllPlugins = usort_plugins(find_plugins(PluginsDir) ++ find_plugins(PluginsDistDir)), ToInstall1 = [list_to_atom(Name) || Name <- ToInstall], - {Found, Missing} = lists:foldl(fun (P = #plugin{name = Name}, {Fs, Ms}) -> + {Found, Missing} = lists:foldl(fun (#plugin{name = Name}, {Fs, Ms}) -> case lists:member(Name, Ms) of - true -> {[P|Fs], Ms -- [Name]}; + true -> {[Name|Fs], Ms -- [Name]}; false -> {Fs, Ms} end end, {[], ToInstall1}, AllPlugins), @@ -94,7 +94,14 @@ action(enable, ToInstall, _Opts, PluginsDir, PluginsDistDir) -> _ -> io:format("Warning: the following plugins could not be found: ~p~n", [Missing]) end, - io:format("Marked for installation: ~p~n", [Found]). + {ok, G} = rabbit_misc:build_acyclic_graph( + fun (App, _Deps) -> [{App, App}] end, + fun (App, Deps) -> [{App, Dep} || Dep <- Deps] end, + [{Name, Deps} + || #plugin{name = Name, dependencies = Deps} <- AllPlugins]), + InstallOrder = digraph_utils:reachable(Found, G), + true = digraph:delete(G), + io:format("Marked for installation: ~p~n", [InstallOrder]). %%---------------------------------------------------------------------------- |
