diff options
| author | Tim Watson <tim.watson@gmail.com> | 2012-05-21 14:04:39 +0100 |
|---|---|---|
| committer | Tim Watson <tim.watson@gmail.com> | 2012-05-21 14:04:39 +0100 |
| commit | 1b69cfee721ce2967cca47a54bfbafcada3453bb (patch) | |
| tree | 0b89b97614cf114103eb6f7b878a50fff8b94686 | |
| parent | d643df379f9ed7df3ff5e1b996f79e4d070fbb35 (diff) | |
| parent | 9faa9b7a56b16323deabfbca1bd1c023cce3abed (diff) | |
| download | rabbitmq-server-git-1b69cfee721ce2967cca47a54bfbafcada3453bb.tar.gz | |
merge 7dae0f4505ab manually
| -rwxr-xr-x | scripts/rabbitmq-plugins | 2 | ||||
| -rwxr-xr-x | scripts/rabbitmq-plugins.bat | 2 | ||||
| -rw-r--r-- | src/rabbit_plugins.erl | 245 | ||||
| -rw-r--r-- | src/rabbit_plugins_main.erl | 224 |
4 files changed, 261 insertions, 212 deletions
diff --git a/scripts/rabbitmq-plugins b/scripts/rabbitmq-plugins index 14a18d5794..97c747910f 100755 --- a/scripts/rabbitmq-plugins +++ b/scripts/rabbitmq-plugins @@ -31,7 +31,7 @@ exec erl \ -noinput \ -hidden \ -sname rabbitmq-plugins$$ \ - -s rabbit_plugins \ + -s rabbit_plugins_main \ -enabled_plugins_file "$RABBITMQ_ENABLED_PLUGINS_FILE" \ -plugins_dist_dir "$RABBITMQ_PLUGINS_DIR" \ -extra "$@" diff --git a/scripts/rabbitmq-plugins.bat b/scripts/rabbitmq-plugins.bat index 66a900a195..bc198393ec 100755 --- a/scripts/rabbitmq-plugins.bat +++ b/scripts/rabbitmq-plugins.bat @@ -45,7 +45,7 @@ if "!RABBITMQ_ENABLED_PLUGINS_FILE!"=="" ( set RABBITMQ_PLUGINS_DIR=!TDP0!..\plugins
-"!ERLANG_HOME!\bin\erl.exe" -pa "!TDP0!..\ebin" -noinput -hidden -sname rabbitmq-plugins!RANDOM! -s rabbit_plugins -enabled_plugins_file "!RABBITMQ_ENABLED_PLUGINS_FILE!" -plugins_dist_dir "!RABBITMQ_PLUGINS_DIR:\=/!" -extra !STAR!
+"!ERLANG_HOME!\bin\erl.exe" -pa "!TDP0!..\ebin" -noinput -hidden -sname rabbitmq-plugins!RANDOM! -s rabbit_plugins_main -enabled_plugins_file "!RABBITMQ_ENABLED_PLUGINS_FILE!" -plugins_dist_dir "!RABBITMQ_PLUGINS_DIR:\=/!" -extra !STAR!
endlocal
endlocal
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl new file mode 100644 index 0000000000..06773cdb54 --- /dev/null +++ b/src/rabbit_plugins.erl @@ -0,0 +1,245 @@ +%% The contents of this file are subject to the Mozilla Public License +%% Version 1.1 (the "License"); you may not use this file except in +%% compliance with the License. You may obtain a copy of the License +%% at http://www.mozilla.org/MPL/ +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and +%% limitations under the License. +%% +%% The Original Code is RabbitMQ. +%% +%% The Initial Developer of the Original Code is VMware, Inc. +%% Copyright (c) 2011-2012 VMware, Inc. All rights reserved. +%% + +-module(rabbit_plugins). +-include("rabbit.hrl"). + +-export([prepare_plugins/0, active_plugins/0, read_enabled_plugins/1, + find_plugins/1, calculate_plugin_dependencies/3]). + +%%---------------------------------------------------------------------------- + +-ifdef(use_specs). + +-spec(prepare_plugins/0 :: () -> [atom()]). +-spec(active_plugins/0 :: () -> [atom()]). +-spec(find_plugins/1 :: (string()) -> [#plugin{}]). +-spec(read_enabled_plugins/1 :: (file:filename()) -> [atom()]). +-spec(calculate_plugin_dependencies/3 :: + (boolean(), [atom()], [#plugin{}]) -> [atom()]). + +-endif. + +%%---------------------------------------------------------------------------- + +%% +%% @doc Prepares the file system and installs all enabled plugins. +%% +prepare_plugins() -> + {ok, PluginDir} = application:get_env(rabbit, plugins_dir), + {ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir), + {ok, EnabledPluginsFile} = application:get_env(rabbit, + enabled_plugins_file), + prepare_plugins(EnabledPluginsFile, PluginDir, ExpandDir), + [prepare_dir_plugin(PluginName) || + PluginName <- filelib:wildcard(ExpandDir ++ "/*/ebin/*.app")]. + +%% @doc Lists the plugins which are currently running. +active_plugins() -> + {ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir), + InstalledPlugins = [ P#plugin.name || P <- find_plugins(ExpandDir) ], + [App || {App, _, _} <- application:which_applications(), + lists:member(App, InstalledPlugins)]. + +%% @doc Get the list of plugins which are ready to be enabled. +find_plugins(PluginsDir) -> + EZs = [{ez, EZ} || EZ <- filelib:wildcard("*.ez", PluginsDir)], + FreeApps = [{app, App} || + App <- filelib:wildcard("*/ebin/*.app", PluginsDir)], + {Plugins, Problems} = + lists:foldl(fun ({error, EZ, Reason}, {Plugins1, Problems1}) -> + {Plugins1, [{EZ, Reason} | Problems1]}; + (Plugin = #plugin{}, {Plugins1, Problems1}) -> + {[Plugin|Plugins1], Problems1} + end, {[], []}, + [get_plugin_info(PluginsDir, Plug) || + Plug <- EZs ++ FreeApps]), + case Problems of + [] -> ok; + _ -> io:format("Warning: Problem reading some plugins: ~p~n", + [Problems]) + end, + Plugins. + +%% @doc Read the list of enabled plugins from the supplied term file. +read_enabled_plugins(PluginsFile) -> + case rabbit_file:read_term_file(PluginsFile) of + {ok, [Plugins]} -> Plugins; + {ok, []} -> []; + {ok, [_|_]} -> throw({error, {malformed_enabled_plugins_file, + PluginsFile}}); + {error, enoent} -> []; + {error, Reason} -> throw({error, {cannot_read_enabled_plugins_file, + PluginsFile, Reason}}) + end. + +%% +%% @doc Calculate the dependency graph from <i>Sources</i>. +%% When Reverse =:= true the bottom/leaf level applications are returned in +%% the resulting list, otherwise they're skipped. +%% +calculate_plugin_dependencies(Reverse, Sources, AllPlugins) -> + {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]), + Dests = case Reverse of + false -> digraph_utils:reachable(Sources, G); + true -> digraph_utils:reaching(Sources, G) + end, + true = digraph:delete(G), + Dests. + +%%---------------------------------------------------------------------------- + +prepare_plugins(EnabledPluginsFile, PluginsDistDir, DestDir) -> + AllPlugins = find_plugins(PluginsDistDir), + Enabled = read_enabled_plugins(EnabledPluginsFile), + ToUnpack = calculate_plugin_dependencies(false, Enabled, AllPlugins), + ToUnpackPlugins = lookup_plugins(ToUnpack, AllPlugins), + + Missing = Enabled -- plugin_names(ToUnpackPlugins), + case Missing of + [] -> ok; + _ -> io:format("Warning: the following enabled plugins were " + "not found: ~p~n", [Missing]) + end, + + %% Eliminate the contents of the destination directory + case delete_recursively(DestDir) of + ok -> ok; + {error, E} -> rabbit_misc:terminate("Could not delete dir ~s (~p)", + [DestDir, E]) + end, + case filelib:ensure_dir(DestDir ++ "/") of + ok -> ok; + {error, E2} -> rabbit_misc:terminate("Could not create dir ~s (~p)", + [DestDir, E2]) + end, + + [prepare_plugin(Plugin, DestDir) || Plugin <- ToUnpackPlugins]. + +prepare_dir_plugin(PluginAppDescFn) -> + %% Add the plugin ebin directory to the load path + PluginEBinDirN = filename:dirname(PluginAppDescFn), + code:add_path(PluginEBinDirN), + + %% We want the second-last token + NameTokens = string:tokens(PluginAppDescFn,"/."), + PluginNameString = lists:nth(length(NameTokens) - 1, NameTokens), + list_to_atom(PluginNameString). + +%%---------------------------------------------------------------------------- + +delete_recursively(Fn) -> + case rabbit_file:recursive_delete([Fn]) of + ok -> ok; + {error, {Path, E}} -> {error, {cannot_delete, Path, E}}; + Error -> Error + end. + +prepare_plugin(#plugin{type = ez, location = Location}, PluginDestDir) -> + zip:unzip(Location, [{cwd, PluginDestDir}]); +prepare_plugin(#plugin{type = dir, name = Name, location = Location}, + PluginsDestDir) -> + rabbit_file:recursive_copy(Location, + filename:join([PluginsDestDir, Name])). + +%% Get the #plugin{} from an .ez. +get_plugin_info(Base, {ez, EZ0}) -> + EZ = filename:join([Base, EZ0]), + case read_app_file(EZ) of + {application, Name, Props} -> mkplugin(Name, Props, ez, EZ); + {error, Reason} -> {error, EZ, Reason} + end; +%% Get the #plugin{} from an .app. +get_plugin_info(Base, {app, App0}) -> + App = filename:join([Base, App0]), + case rabbit_file:read_term_file(App) of + {ok, [{application, Name, Props}]} -> + mkplugin(Name, Props, dir, + filename:absname( + filename:dirname(filename:dirname(App)))); + {error, Reason} -> + {error, App, {invalid_app, Reason}} + end. + +mkplugin(Name, Props, Type, Location) -> + Version = proplists:get_value(vsn, Props, "0"), + Description = proplists:get_value(description, Props, ""), + Dependencies = + filter_applications(proplists:get_value(applications, Props, [])), + #plugin{name = Name, version = Version, description = Description, + dependencies = Dependencies, location = Location, type = Type}. + +%% Read the .app file from an ez. +read_app_file(EZ) -> + case zip:list_dir(EZ) of + {ok, [_|ZippedFiles]} -> + case find_app_files(ZippedFiles) of + [AppPath|_] -> + {ok, [{AppPath, AppFile}]} = + zip:extract(EZ, [{file_list, [AppPath]}, memory]), + parse_binary(AppFile); + [] -> + {error, no_app_file} + end; + {error, Reason} -> + {error, {invalid_ez, Reason}} + end. + +%% Return the path of the .app files in ebin/. +find_app_files(ZippedFiles) -> + {ok, RE} = re:compile("^.*/ebin/.*.app$"), + [Path || {zip_file, Path, _, _, _, _} <- ZippedFiles, + re:run(Path, RE, [{capture, none}]) =:= match]. + +%% Parse a binary into a term. +parse_binary(Bin) -> + try + {ok, Ts, _} = erl_scan:string(binary_to_list(Bin)), + {ok, Term} = erl_parse:parse_term(Ts), + Term + catch + Err -> {error, {invalid_app, Err}} + end. + +%% Filter out applications that can be loaded *right now*. +filter_applications(Applications) -> + [Application || Application <- Applications, + not is_available_app(Application)]. + +%% Return whether is application is already available (and hence +%% doesn't need enabling). +is_available_app(Application) -> + case application:load(Application) of + {error, {already_loaded, _}} -> true; + ok -> application:unload(Application), + true; + _ -> false + end. + +%% Return the names of the given plugins. +plugin_names(Plugins) -> + [Name || #plugin{name = Name} <- Plugins]. + +%% Find plugins by name in a list of plugins. +lookup_plugins(Names, AllPlugins) -> + [P || P = #plugin{name = Name} <- AllPlugins, lists:member(Name, Names)]. + + + diff --git a/src/rabbit_plugins_main.erl b/src/rabbit_plugins_main.erl index 8a8e7052db..a27ad9869b 100644 --- a/src/rabbit_plugins_main.erl +++ b/src/rabbit_plugins_main.erl @@ -14,10 +14,10 @@ %% Copyright (c) 2011-2012 VMware, Inc. All rights reserved. %% --module(rabbit_plugins). +-module(rabbit_plugins_main). -include("rabbit.hrl"). --export([start/0, stop/0, prepare_plugins/0, active_plugins/0]). +-export([start/0, stop/0]). -define(VERBOSE_OPT, "-v"). -define(MINIMAL_OPT, "-m"). @@ -30,8 +30,6 @@ -spec(start/0 :: () -> no_return()). -spec(stop/0 :: () -> 'ok'). --spec(prepare_plugins/0 :: () -> [atom()]). --spec(active_plugins/0 :: () -> [atom()]). -endif. @@ -80,60 +78,6 @@ start() -> stop() -> ok. -prepare_plugins() -> - {ok, PluginDir} = application:get_env(rabbit, plugins_dir), - {ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir), - {ok, EnabledPluginsFile} = application:get_env(rabbit, - enabled_plugins_file), - prepare_plugins(EnabledPluginsFile, PluginDir, ExpandDir), - [prepare_dir_plugin(PluginName) || - PluginName <- filelib:wildcard(ExpandDir ++ "/*/ebin/*.app")]. - -active_plugins() -> - {ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir), - InstalledPlugins = [ P#plugin.name || P <- find_plugins(ExpandDir) ], - [App || {App, _, _} <- application:which_applications(), - lists:member(App, InstalledPlugins)]. - -%%---------------------------------------------------------------------------- - -prepare_plugins(EnabledPluginsFile, PluginsDistDir, DestDir) -> - AllPlugins = find_plugins(PluginsDistDir), - Enabled = read_enabled_plugins(EnabledPluginsFile), - ToUnpack = calculate_required_plugins(Enabled, AllPlugins), - ToUnpackPlugins = lookup_plugins(ToUnpack, AllPlugins), - - Missing = Enabled -- plugin_names(ToUnpackPlugins), - case Missing of - [] -> ok; - _ -> io:format("Warning: the following enabled plugins were " - "not found: ~p~n", [Missing]) - end, - - %% Eliminate the contents of the destination directory - case delete_recursively(DestDir) of - ok -> ok; - {error, E} -> rabbit_misc:terminate("Could not delete dir ~s (~p)", - [DestDir, E]) - end, - case filelib:ensure_dir(DestDir ++ "/") of - ok -> ok; - {error, E2} -> rabbit_misc:terminate("Could not create dir ~s (~p)", - [DestDir, E2]) - end, - - [prepare_plugin(Plugin, DestDir) || Plugin <- ToUnpackPlugins]. - -prepare_dir_plugin(PluginAppDescFn) -> - %% Add the plugin ebin directory to the load path - PluginEBinDirN = filename:dirname(PluginAppDescFn), - code:add_path(PluginEBinDirN), - - %% We want the second-last token - NameTokens = string:tokens(PluginAppDescFn,"/."), - PluginNameString = lists:nth(length(NameTokens) - 1, NameTokens), - list_to_atom(PluginNameString). - %%---------------------------------------------------------------------------- action(list, [], Opts, PluginsFile, PluginsDir) -> @@ -146,9 +90,9 @@ action(enable, ToEnable0, _Opts, PluginsFile, PluginsDir) -> [] -> throw({error_string, "Not enough arguments for 'enable'"}); _ -> ok end, - AllPlugins = find_plugins(PluginsDir), - Enabled = read_enabled_plugins(PluginsFile), - ImplicitlyEnabled = calculate_required_plugins(Enabled, AllPlugins), + AllPlugins = rabbit_plugins:find_plugins(PluginsDir), + Enabled = rabbit_plugins:read_enabled_plugins(PluginsFile), + ImplicitlyEnabled = rabbit_plugins:calculate_plugin_dependencies(false, Enabled, AllPlugins), ToEnable = [list_to_atom(Name) || Name <- ToEnable0], Missing = ToEnable -- plugin_names(AllPlugins), case Missing of @@ -159,7 +103,7 @@ action(enable, ToEnable0, _Opts, PluginsFile, PluginsDir) -> end, NewEnabled = lists:usort(Enabled ++ ToEnable), write_enabled_plugins(PluginsFile, NewEnabled), - NewImplicitlyEnabled = calculate_required_plugins(NewEnabled, AllPlugins), + NewImplicitlyEnabled = rabbit_plugins:calculate_plugin_dependencies(false, NewEnabled, AllPlugins), maybe_warn_mochiweb(NewImplicitlyEnabled), case NewEnabled -- ImplicitlyEnabled of [] -> io:format("Plugin configuration unchanged.~n"); @@ -174,22 +118,22 @@ action(disable, ToDisable0, _Opts, PluginsFile, PluginsDir) -> _ -> ok end, ToDisable = [list_to_atom(Name) || Name <- ToDisable0], - Enabled = read_enabled_plugins(PluginsFile), - AllPlugins = find_plugins(PluginsDir), + Enabled = rabbit_plugins:read_enabled_plugins(PluginsFile), + AllPlugins = rabbit_plugins:find_plugins(PluginsDir), Missing = ToDisable -- plugin_names(AllPlugins), case Missing of [] -> ok; _ -> print_list("Warning: the following plugins could not be found:", Missing) end, - ToDisableDeps = calculate_dependencies(true, ToDisable, AllPlugins), + ToDisableDeps = rabbit_plugins:calculate_plugin_dependencies(true, ToDisable, AllPlugins), NewEnabled = Enabled -- ToDisableDeps, case length(Enabled) =:= length(NewEnabled) of true -> io:format("Plugin configuration unchanged.~n"); false -> ImplicitlyEnabled = - calculate_required_plugins(Enabled, AllPlugins), + rabbit_plugins:calculate_plugin_dependencies(false, Enabled, AllPlugins), NewImplicitlyEnabled = - calculate_required_plugins(NewEnabled, AllPlugins), + rabbit_plugins:calculate_plugin_dependencies(false, NewEnabled, AllPlugins), print_list("The following plugins have been disabled:", ImplicitlyEnabled -- NewImplicitlyEnabled), write_enabled_plugins(PluginsFile, NewEnabled), @@ -205,99 +149,6 @@ usage() -> io:format("~s", [rabbit_plugins_usage:usage()]), rabbit_misc:quit(1). -delete_recursively(Fn) -> - case rabbit_file:recursive_delete([Fn]) of - ok -> ok; - {error, {Path, E}} -> {error, {cannot_delete, Path, E}}; - Error -> Error - end. - -prepare_plugin(#plugin{type = ez, location = Location}, PluginDestDir) -> - zip:unzip(Location, [{cwd, PluginDestDir}]); -prepare_plugin(#plugin{type = dir, name = Name, location = Location}, - PluginsDestDir) -> - rabbit_file:recursive_copy(Location, - filename:join([PluginsDestDir, Name])). - -%% Get the #plugin{}s ready to be enabled. -find_plugins(PluginsDir) -> - EZs = [{ez, EZ} || EZ <- filelib:wildcard("*.ez", PluginsDir)], - FreeApps = [{app, App} || - App <- filelib:wildcard("*/ebin/*.app", PluginsDir)], - {Plugins, Problems} = - lists:foldl(fun ({error, EZ, Reason}, {Plugins1, Problems1}) -> - {Plugins1, [{EZ, Reason} | Problems1]}; - (Plugin = #plugin{}, {Plugins1, Problems1}) -> - {[Plugin|Plugins1], Problems1} - end, {[], []}, - [get_plugin_info(PluginsDir, Plug) || - Plug <- EZs ++ FreeApps]), - case Problems of - [] -> ok; - _ -> io:format("Warning: Problem reading some plugins: ~p~n", - [Problems]) - end, - Plugins. - -%% Get the #plugin{} from an .ez. -get_plugin_info(Base, {ez, EZ0}) -> - EZ = filename:join([Base, EZ0]), - case read_app_file(EZ) of - {application, Name, Props} -> mkplugin(Name, Props, ez, EZ); - {error, Reason} -> {error, EZ, Reason} - end; -%% Get the #plugin{} from an .app. -get_plugin_info(Base, {app, App0}) -> - App = filename:join([Base, App0]), - case rabbit_file:read_term_file(App) of - {ok, [{application, Name, Props}]} -> - mkplugin(Name, Props, dir, - filename:absname( - filename:dirname(filename:dirname(App)))); - {error, Reason} -> - {error, App, {invalid_app, Reason}} - end. - -mkplugin(Name, Props, Type, Location) -> - Version = proplists:get_value(vsn, Props, "0"), - Description = proplists:get_value(description, Props, ""), - Dependencies = - filter_applications(proplists:get_value(applications, Props, [])), - #plugin{name = Name, version = Version, description = Description, - dependencies = Dependencies, location = Location, type = Type}. - -%% Read the .app file from an ez. -read_app_file(EZ) -> - case zip:list_dir(EZ) of - {ok, [_|ZippedFiles]} -> - case find_app_files(ZippedFiles) of - [AppPath|_] -> - {ok, [{AppPath, AppFile}]} = - zip:extract(EZ, [{file_list, [AppPath]}, memory]), - parse_binary(AppFile); - [] -> - {error, no_app_file} - end; - {error, Reason} -> - {error, {invalid_ez, Reason}} - end. - -%% Return the path of the .app files in ebin/. -find_app_files(ZippedFiles) -> - {ok, RE} = re:compile("^.*/ebin/.*.app$"), - [Path || {zip_file, Path, _, _, _, _} <- ZippedFiles, - re:run(Path, RE, [{capture, none}]) =:= match]. - -%% Parse a binary into a term. -parse_binary(Bin) -> - try - {ok, Ts, _} = erl_scan:string(binary_to_list(Bin)), - {ok, Term} = erl_parse:parse_term(Ts), - Term - catch - Err -> {error, {invalid_app, Err}} - end. - %% Pretty print a list of plugins. format_plugins(Pattern, Opts, PluginsFile, PluginsDir) -> Verbose = proplists:get_bool(?VERBOSE_OPT, Opts), @@ -312,10 +163,10 @@ format_plugins(Pattern, Opts, PluginsFile, PluginsDir) -> OnlyEnabled = proplists:get_bool(?ENABLED_OPT, Opts), OnlyEnabledAll = proplists:get_bool(?ENABLED_ALL_OPT, Opts), - AvailablePlugins = find_plugins(PluginsDir), - EnabledExplicitly = read_enabled_plugins(PluginsFile), + AvailablePlugins = rabbit_plugins:find_plugins(PluginsDir), + EnabledExplicitly = rabbit_plugins:read_enabled_plugins(PluginsFile), EnabledImplicitly = - calculate_required_plugins(EnabledExplicitly, AvailablePlugins) -- + rabbit_plugins:calculate_plugin_dependencies(false, EnabledExplicitly, AvailablePlugins) -- EnabledExplicitly, {ok, RE} = re:compile(Pattern), Plugins = [ Plugin || @@ -374,41 +225,10 @@ plugins_cmp(#plugin{name = N1, version = V1}, #plugin{name = N2, version = V2}) -> {N1, V1} =< {N2, V2}. -%% Filter out applications that can be loaded *right now*. -filter_applications(Applications) -> - [Application || Application <- Applications, - not is_available_app(Application)]. - -%% Return whether is application is already available (and hence -%% doesn't need enabling). -is_available_app(Application) -> - case application:load(Application) of - {error, {already_loaded, _}} -> true; - ok -> application:unload(Application), - true; - _ -> false - end. - %% Return the names of the given plugins. plugin_names(Plugins) -> [Name || #plugin{name = Name} <- Plugins]. -%% Find plugins by name in a list of plugins. -lookup_plugins(Names, AllPlugins) -> - [P || P = #plugin{name = Name} <- AllPlugins, lists:member(Name, Names)]. - -%% Read the enabled plugin names from disk. -read_enabled_plugins(PluginsFile) -> - case rabbit_file:read_term_file(PluginsFile) of - {ok, [Plugins]} -> Plugins; - {ok, []} -> []; - {ok, [_|_]} -> throw({error, {malformed_enabled_plugins_file, - PluginsFile}}); - {error, enoent} -> []; - {error, Reason} -> throw({error, {cannot_read_enabled_plugins_file, - PluginsFile, Reason}}) - end. - %% Write the enabled plugin names on disk. write_enabled_plugins(PluginsFile, Plugins) -> case rabbit_file:write_term_file(PluginsFile, [Plugins]) of @@ -417,22 +237,6 @@ write_enabled_plugins(PluginsFile, Plugins) -> PluginsFile, Reason}}) end. -calculate_required_plugins(Sources, AllPlugins) -> - calculate_dependencies(false, Sources, AllPlugins). - -calculate_dependencies(Reverse, Sources, AllPlugins) -> - {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]), - Dests = case Reverse of - false -> digraph_utils:reachable(Sources, G); - true -> digraph_utils:reaching(Sources, G) - end, - true = digraph:delete(G), - Dests. - maybe_warn_mochiweb(Enabled) -> V = erlang:system_info(otp_release), case lists:member(mochiweb, Enabled) andalso V < "R13B01" of |
