mirror of
https://github.com/correl/rebar.git
synced 2024-11-15 11:09:33 +00:00
Add overlay command to run overlays only
required for building on a different machine to what your live config is kept on. This way you can build on one machine, distribute to new machine, then run overlays against a live config to prevent accidently running code against a live config in a development or ci environment.
This commit is contained in:
parent
4a5114b79f
commit
3c7a5804e9
2 changed files with 39 additions and 25 deletions
|
@ -232,6 +232,7 @@ delete-deps Delete fetched dependencies
|
||||||
list-deps List dependencies
|
list-deps List dependencies
|
||||||
|
|
||||||
generate [dump_spec=0/1] Build release with reltool
|
generate [dump_spec=0/1] Build release with reltool
|
||||||
|
overlay Run reltool overlays only
|
||||||
|
|
||||||
generate-upgrade previous_release=path Build an upgrade package
|
generate-upgrade previous_release=path Build an upgrade package
|
||||||
|
|
||||||
|
@ -289,7 +290,7 @@ command_names() ->
|
||||||
["check-deps", "clean", "compile", "create", "create-app", "create-node",
|
["check-deps", "clean", "compile", "create", "create-app", "create-node",
|
||||||
"ct", "delete-deps", "doc", "eunit", "generate", "generate-appups",
|
"ct", "delete-deps", "doc", "eunit", "generate", "generate-appups",
|
||||||
"generate-upgrade", "get-deps", "help", "list-deps", "list-templates",
|
"generate-upgrade", "get-deps", "help", "list-deps", "list-templates",
|
||||||
"update-deps", "version", "xref"].
|
"update-deps", "overlay", "version", "xref"].
|
||||||
|
|
||||||
unabbreviate_command_names([]) ->
|
unabbreviate_command_names([]) ->
|
||||||
[];
|
[];
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
-module(rebar_reltool).
|
-module(rebar_reltool).
|
||||||
|
|
||||||
-export([generate/2,
|
-export([generate/2,
|
||||||
|
overlay/2,
|
||||||
clean/2]).
|
clean/2]).
|
||||||
|
|
||||||
-include("rebar.hrl").
|
-include("rebar.hrl").
|
||||||
|
@ -64,6 +65,10 @@ generate(Config, ReltoolFile) ->
|
||||||
?FAIL
|
?FAIL
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
overlay(_Config, ReltoolFile) ->
|
||||||
|
%% Load the reltool configuration from the file
|
||||||
|
ReltoolConfig = rebar_rel_utils:load_config(ReltoolFile),
|
||||||
|
process_overlay(ReltoolConfig).
|
||||||
|
|
||||||
clean(_Config, ReltoolFile) ->
|
clean(_Config, ReltoolFile) ->
|
||||||
ReltoolConfig = rebar_rel_utils:load_config(ReltoolFile),
|
ReltoolConfig = rebar_rel_utils:load_config(ReltoolFile),
|
||||||
|
@ -93,6 +98,36 @@ check_vsn() ->
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
process_overlay(ReltoolConfig) ->
|
||||||
|
TargetDir = rebar_rel_utils:get_target_dir(ReltoolConfig),
|
||||||
|
|
||||||
|
{_BootRelName, BootRelVsn} =
|
||||||
|
rebar_rel_utils:get_reltool_release_info(ReltoolConfig),
|
||||||
|
|
||||||
|
%% Initialize overlay vars with some basics
|
||||||
|
%% (that can get overwritten)
|
||||||
|
OverlayVars0 =
|
||||||
|
dict:from_list([{erts_vsn, "erts-" ++ erlang:system_info(version)},
|
||||||
|
{rel_vsn, BootRelVsn},
|
||||||
|
{target_dir, TargetDir}]),
|
||||||
|
|
||||||
|
%% Load up any variables specified by overlay_vars
|
||||||
|
OverlayVars1 = overlay_vars(OverlayVars0, ReltoolConfig),
|
||||||
|
OverlayVars = rebar_templater:resolve_variables(dict:to_list(OverlayVars1),
|
||||||
|
OverlayVars1),
|
||||||
|
|
||||||
|
%% Finally, overlay the files specified by the overlay section
|
||||||
|
case lists:keyfind(overlay, 1, ReltoolConfig) of
|
||||||
|
{overlay, Overlay} when is_list(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", [])
|
||||||
|
end.
|
||||||
|
|
||||||
%%
|
%%
|
||||||
%% Look for overlay_vars file reference. If the user provides an overlay_vars on
|
%% Look for overlay_vars file reference. If the user provides an overlay_vars on
|
||||||
%% the command line (i.e. a global), the terms from that file OVERRIDE the one
|
%% the command line (i.e. a global), the terms from that file OVERRIDE the one
|
||||||
|
@ -178,29 +213,7 @@ run_reltool(Server, _Config, ReltoolConfig) ->
|
||||||
|
|
||||||
ok = create_RELEASES(TargetDir, BootRelName, BootRelVsn),
|
ok = create_RELEASES(TargetDir, BootRelName, BootRelVsn),
|
||||||
|
|
||||||
%% Initialize overlay vars with some basics
|
process_overlay(ReltoolConfig);
|
||||||
%% (that can get overwritten)
|
|
||||||
OverlayVars0 =
|
|
||||||
dict:from_list([{erts_vsn, "erts-" ++ erlang:system_info(version)},
|
|
||||||
{rel_vsn, BootRelVsn},
|
|
||||||
{target_dir, TargetDir}]),
|
|
||||||
|
|
||||||
%% Load up any variables specified by overlay_vars
|
|
||||||
OverlayVars1 = overlay_vars(OverlayVars0, ReltoolConfig),
|
|
||||||
OverlayVars = rebar_templater:resolve_variables(dict:to_list(OverlayVars1),
|
|
||||||
OverlayVars1),
|
|
||||||
|
|
||||||
%% Finally, overlay the files specified by the overlay section
|
|
||||||
case lists:keyfind(overlay, 1, ReltoolConfig) of
|
|
||||||
{overlay, Overlay} when is_list(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", [])
|
|
||||||
end;
|
|
||||||
|
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?ABORT("Unable to generate spec: ~s\n", [Reason])
|
?ABORT("Unable to generate spec: ~s\n", [Reason])
|
||||||
|
@ -330,4 +343,4 @@ create_RELEASES(TargetDir, RelName, RelVsn) ->
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?ABORT("Failed to create RELEASES file: ~p\n",
|
?ABORT("Failed to create RELEASES file: ~p\n",
|
||||||
[Reason])
|
[Reason])
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in a new issue