Add slim marker file as automatic overlay

This commit is contained in:
Shunichi Shinohara 2012-10-20 15:33:22 +09:00
parent 12af16eb70
commit 2575bb24da
2 changed files with 33 additions and 8 deletions

View file

@ -37,6 +37,7 @@
get_rel_file_path/2,
load_config/2,
get_sys_tuple/1,
get_excl_lib_tuple/1,
get_target_dir/2,
get_root_dir/2,
get_target_parent_dir/2]).
@ -143,6 +144,13 @@ get_sys_tuple(ReltoolConfig) ->
?ABORT("Failed to find {sys, [...]} tuple in reltool.config.", [])
end.
%%
%% Look for the {excl_lib, ...} tuple in sys tuple of the reltool.config file.
%% Without this present, return false.
%%
get_excl_lib_tuple(ReltoolConfig) ->
lists:keyfind(excl_lib, 1, element(2, get_sys_tuple(ReltoolConfig))).
%%
%% Look for {target_dir, TargetDir} in the reltool config file; if none is
%% found, use the name of the release as the default target directory.

View file

@ -147,15 +147,12 @@ process_overlay(Config, ReltoolConfig) ->
OverlayVars1),
%% Finally, overlay the files specified by the overlay section
case lists:keyfind(overlay, 1, ReltoolConfig) of
{overlay, Overlay} when is_list(Overlay) ->
case overlay_files(ReltoolConfig) of
[] ->
ok;
Overlay ->
execute_overlay(Overlay, OverlayVars, rebar_utils:get_cwd(),
TargetDir);
false ->
?INFO("No {overlay, [...]} found in reltool.config.\n", []);
_ ->
?ABORT("{overlay, [...]} entry in reltool.config "
"must be a list.\n", [])
TargetDir)
end.
%%
@ -292,6 +289,26 @@ dump_spec(Config, Spec) ->
end.
overlay_files(ReltoolConfig) ->
Original = case lists:keyfind(overlay, 1, ReltoolConfig) of
{overlay, Overlay} when is_list(Overlay) ->
Overlay;
false ->
?INFO("No {overlay, [...]} found in reltool.config.\n", []),
[];
_ ->
?ABORT("{overlay, [...]} entry in reltool.config "
"must be a list.\n", [])
end,
SlimAddition = case rebar_rel_utils:get_excl_lib_tuple(ReltoolConfig) of
{excl_lib, otp_root} ->
[{create, "releases/{{rel_vsn}}/runner_script.data",
"slim\n"}];
false ->
[]
end,
Original ++ SlimAddition.
%% TODO: Merge functionality here with rebar_templater
execute_overlay([], _Vars, _BaseDir, _TargetDir) ->