diff options
-rw-r--r-- | src/rcl_app_discovery.erl | 4 | ||||
-rw-r--r-- | src/rcl_prv_config.erl | 2 | ||||
-rw-r--r-- | src/rcl_state.erl | 13 | ||||
-rw-r--r-- | test/rclt_release_SUITE.erl | 56 |
4 files changed, 73 insertions, 2 deletions
diff --git a/src/rcl_app_discovery.erl b/src/rcl_app_discovery.erl index 1f1ecc8..7b04b19 100644 --- a/src/rcl_app_discovery.erl +++ b/src/rcl_app_discovery.erl @@ -66,7 +66,9 @@ resolve_app_metadata(State, LibDirs) -> false end] of [] -> - AppMeta1 = [App || {ok, App} <- setup_overrides(State, AppMeta0)], + SkipApps = rcl_state:skip_apps(State), + AppMeta1 = [App || {ok, App} <- setup_overrides(State, AppMeta0), + not lists:keymember(rcl_app_info:name(App), 1, SkipApps)], rcl_log:debug(rcl_state:log(State), fun() -> ["Resolved the following OTP Applications from the system: \n", diff --git a/src/rcl_prv_config.erl b/src/rcl_prv_config.erl index 4d1c119..dfbc321 100644 --- a/src/rcl_prv_config.erl +++ b/src/rcl_prv_config.erl @@ -144,6 +144,8 @@ load_terms({add_providers, Providers0}, {ok, State0}) -> ExistingProviders = rcl_state:providers(State1), {ok, rcl_state:providers(State1, ExistingProviders ++ Providers3)} end; +load_terms({skip_apps, SkipApps0}, {ok, State0}) -> + {ok, rcl_state:skip_apps(State0, SkipApps0)}; load_terms({overrides, Overrides0}, {ok, State0}) -> {ok, rcl_state:overrides(State0, Overrides0)}; load_terms({release, {RelName, Vsn}, Applications}, {ok, State0}) -> diff --git a/src/rcl_state.erl b/src/rcl_state.erl index 7247818..4b21bbe 100644 --- a/src/rcl_state.erl +++ b/src/rcl_state.erl @@ -29,6 +29,8 @@ lib_dirs/1, overrides/1, overrides/2, + skip_apps/1, + skip_apps/2, goals/1, config_file/1, config_file/2, @@ -74,6 +76,7 @@ default_release :: {rcl_release:name(), rcl_release:vsn()}, sys_config :: file:filename() | undefined, overrides :: [{AppName::atom(), Directory::file:filename()}], + skip_apps = [] :: [AppName::atom()], releases :: releases(), discovered_releases :: releases(), config_values :: ec_dictionary:dictionary(Key::atom(), @@ -129,6 +132,16 @@ overrides(#state_t{overrides=Overrides}) -> overrides(State, Overrides) -> State#state_t{overrides=Overrides}. + +-spec skip_apps(t()) -> [AppName::atom()]. +skip_apps(#state_t{skip_apps=Apps}) -> + Apps. + +%% @doc the application overrides for the system +-spec skip_apps(t(), [AppName::atom()]) -> t(). +skip_apps(State, SkipApps) -> + State#state_t{skip_apps=SkipApps}. + %% @doc get the current log state for the system -spec log(t()) -> rcl_log:t(). log(#state_t{log=LogState}) -> diff --git a/test/rclt_release_SUITE.erl b/test/rclt_release_SUITE.erl index d4f9aac..f0446d6 100644 --- a/test/rclt_release_SUITE.erl +++ b/test/rclt_release_SUITE.erl @@ -27,6 +27,7 @@ make_release/1, make_scriptless_release/1, make_overridden_release/1, + make_skip_app_release/1, make_rerun_overridden_release/1, make_implicit_config_release/1, overlay_release/1, @@ -60,6 +61,7 @@ init_per_testcase(_, Config) -> all() -> [make_release, make_scriptless_release, make_overridden_release, + make_skip_app_release, make_implicit_config_release, make_rerun_overridden_release, overlay_release, make_goalless_release, make_depfree_release, make_invalid_config_release, make_relup_release, @@ -202,7 +204,7 @@ make_overridden_release(Config) -> create_random_name("relcool-output")]), {ok, Cwd} = file:get_cwd(), {ok, State} = relcool:do(Cwd, undefined, undefined, [], [LibDir1], 2, - OutputDir, [{OverrideAppName, OverrideAppDir}], + OutputDir, [{OverrideAppName, OverrideAppDir}], ConfigFile), [{{foo, "0.0.1"}, Release}] = ec_dictionary:to_list(rcl_state:releases(State)), AppSpecs = rcl_release:applications(Release), @@ -218,6 +220,52 @@ make_overridden_release(Config) -> OverrideApp ++ "-" ++ OverrideVsn])), ?assertMatch(OverrideAppDir, Real). +make_skip_app_release(Config) -> + DataDir = proplists:get_value(data_dir, Config), + SkipAppDir1 = filename:join([DataDir, create_random_name("skip_app_dir_")]), + LibDir1 = proplists:get_value(lib1, Config), + [(fun({Name, Vsn}) -> + create_app(LibDir1, Name, Vsn, [kernel, stdlib], []) + end)(App) + || + App <- + [{create_random_name("lib_app1_"), create_random_vsn()} + || _ <- lists:seq(1, 100)]], + SkipAppApp = create_random_name("skip_app_app"), + SkipAppVsn = create_random_vsn(), + SkipAppAppName = erlang:list_to_atom(SkipAppApp), + + create_app(LibDir1, "goal_app_1", "0.0.1", [stdlib,kernel,non_goal_1], []), + create_app(LibDir1, "lib_dep_1", "0.0.1", [stdlib,kernel], []), + create_app(LibDir1, "goal_app_2", "0.0.1", [stdlib,kernel,goal_app_1,non_goal_2], []), + create_app(LibDir1, "non_goal_1", "0.0.1", [stdlib,kernel], [lib_dep_1]), + create_app(LibDir1, "non_goal_2", "0.0.1", [stdlib,kernel], []), + + create_empty_app(SkipAppDir1, SkipAppApp, SkipAppVsn, [stdlib,kernel], []), + + ConfigFile = filename:join([LibDir1, "relcool.config"]), + write_config(ConfigFile, + [{release, {foo, "0.0.1"}, + [goal_app_1, + goal_app_2]}, + {skip_apps, [erlang:list_to_atom(SkipAppApp)]}]), + OutputDir = filename:join([proplists:get_value(data_dir, Config), + create_random_name("relcool-output")]), + {ok, Cwd} = file:get_cwd(), + {ok, State} = relcool:do(Cwd, undefined, undefined, [], [LibDir1], 2, + OutputDir, [], + ConfigFile), + [{{foo, "0.0.1"}, Release}] = ec_dictionary:to_list(rcl_state:releases(State)), + AppSpecs = rcl_release:applications(Release), + ?assert(lists:keymember(stdlib, 1, AppSpecs)), + ?assert(lists:keymember(kernel, 1, AppSpecs)), + ?assert(lists:member({non_goal_1, "0.0.1"}, AppSpecs)), + ?assert(lists:member({non_goal_2, "0.0.1"}, AppSpecs)), + ?assert(lists:member({goal_app_1, "0.0.1"}, AppSpecs)), + ?assert(lists:member({goal_app_2, "0.0.1"}, AppSpecs)), + ?assertNot(lists:member({SkipAppAppName, SkipAppVsn}, AppSpecs)), + ?assert(lists:member({lib_dep_1, "0.0.1", load}, AppSpecs)). + make_implicit_config_release(Config) -> LibDir1 = proplists:get_value(lib1, Config), FooRoot = filename:join([LibDir1, "foodir1", "foodir2"]), @@ -601,6 +649,12 @@ create_app(Dir, Name, Vsn, Deps, LibDeps) -> rcl_app_info:new(erlang:list_to_atom(Name), Vsn, AppDir, Deps, []). +create_empty_app(Dir, Name, Vsn, Deps, LibDeps) -> + AppDir = filename:join([Dir, Name ++ "-" ++ Vsn]), + write_app_file(AppDir, Name, Vsn, Deps, LibDeps), + rcl_app_info:new(erlang:list_to_atom(Name), Vsn, AppDir, + Deps, []). + write_beam_file(Dir, Name) -> Beam = filename:join([Dir, "ebin", "not_a_real_beam" ++ Name ++ ".beam"]), ok = filelib:ensure_dir(Beam), |