summaryrefslogtreecommitdiff
path: root/src/rebar_reltool.erl
diff options
context:
space:
mode:
authorAlexey Romanov <alexey.v.romanov@gmail.com>2011-02-21 12:41:20 +0300
committerAlexey Romanov <alexey.v.romanov@gmail.com>2011-02-21 12:41:20 +0300
commit7dc371d8a3b9a6e2ab9f814c0d2536cf638ceb99 (patch)
tree174193ae08d2824164ba99e63f696a6593ee63c6 /src/rebar_reltool.erl
parent2ceeb3272139b7569c8dabc215ca1e7063b0d385 (diff)
parent6056c63eed288736c912c82d6f36aa7dd055f9ca (diff)
Merge branch 'master' of https://github.com/basho/rebar
Diffstat (limited to 'src/rebar_reltool.erl')
-rw-r--r--src/rebar_reltool.erl60
1 files changed, 36 insertions, 24 deletions
diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl
index b8e1095..5cbd587 100644
--- a/src/rebar_reltool.erl
+++ b/src/rebar_reltool.erl
@@ -1,4 +1,4 @@
-%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 et
%% -------------------------------------------------------------------
%%
@@ -78,13 +78,14 @@ clean(_Config, ReltoolFile) ->
check_vsn() ->
case code:lib_dir(reltool) of
{error, bad_name} ->
- ?ABORT("Reltool support requires the reltool application to be installed!", []);
+ ?ABORT("Reltool support requires the reltool application "
+ "to be installed!", []);
Path ->
ReltoolVsn = filename:basename(Path),
case ReltoolVsn < "reltool-0.5.2" of
true ->
- ?ABORT("Reltool support requires at least reltool-0.5.2; this VM is using ~s\n",
- [ReltoolVsn]);
+ ?ABORT("Reltool support requires at least reltool-0.5.2; "
+ "this VM is using ~s\n", [ReltoolVsn]);
false ->
ok
end
@@ -98,12 +99,13 @@ load_config(ReltoolFile) ->
{ok, Terms} ->
Terms;
Other ->
- ?ABORT("Failed to load expected config from ~s: ~p\n", [ReltoolFile, Other])
+ ?ABORT("Failed to load expected config from ~s: ~p\n",
+ [ReltoolFile, Other])
end.
%%
-%% Look for the {sys, [...]} tuple in the reltool.config file. Without this present, we
-%% can't run reltool.
+%% Look for the {sys, [...]} tuple in the reltool.config file.
+%% Without this present, we can't run reltool.
%%
sys_tuple(ReltoolConfig) ->
case lists:keyfind(sys, 1, ReltoolConfig) of
@@ -160,15 +162,17 @@ validate_rel_apps(ReltoolServer, {sys, ReltoolConfig}) ->
false ->
ok;
{rel, _Name, _Vsn, Apps} ->
- %% Identify all the apps that do NOT exist, based on what's available
- %% from the reltool server
- Missing = lists:sort([App || App <- Apps,
- app_exists(App, ReltoolServer) == false]),
+ %% Identify all the apps that do NOT exist, based on
+ %% what's available from the reltool server
+ Missing = lists:sort(
+ [App || App <- Apps,
+ app_exists(App, ReltoolServer) == false]),
case Missing of
[] ->
ok;
_ ->
- ?ABORT("Apps in {rel, ...} section not found by reltool: ~p\n", [Missing])
+ ?ABORT("Apps in {rel, ...} section not found by "
+ "reltool: ~p\n", [Missing])
end;
Rel ->
%% Invalid release format!
@@ -201,10 +205,12 @@ run_reltool(Server, _Config, ReltoolConfig) ->
ok ->
ok;
{error, Reason} ->
- ?ABORT("Failed to generate target from spec: ~p\n", [Reason])
+ ?ABORT("Failed to generate target from spec: ~p\n",
+ [Reason])
end,
- %% Initialize overlay vars with some basics (that can get overwritten)
+ %% Initialize overlay vars with some basics
+ %% (that can get overwritten)
OverlayVars0 = [{erts_vsn, "erts-" ++ erlang:system_info(version)}],
%% Load up any variables specified by overlay_vars
@@ -216,19 +222,22 @@ run_reltool(Server, _Config, ReltoolConfig) ->
{ok, Terms} ->
dict:from_list(OverlayVars0 ++ Terms);
{error, Reason2} ->
- ?ABORT("Unable to load overlay_vars from ~s: ~p\n",
+ ?ABORT("Unable to load overlay_vars "
+ "from ~s: ~p\n",
[File, Reason2])
end
end,
%% Finally, overlay the files specified by the overlay section
- case lists:keysearch(overlay, 1, ReltoolConfig) of
- {value, {overlay, Overlay}} when is_list(Overlay) ->
- execute_overlay(Overlay, OverlayVars, rebar_utils:get_cwd(), TargetDir);
- {value, _} ->
- ?ABORT("{overlay, [...]} entry in reltool.config must be a list.\n", []);
+ 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", [])
+ ?INFO("No {overlay, [...]} found in reltool.config.\n", []);
+ _ ->
+ ?ABORT("{overlay, [...]} entry in reltool.config "
+ "must be a list.\n", [])
end;
{error, Reason} ->
@@ -247,7 +256,8 @@ mk_target_dir(TargetDir) ->
rebar_file_utils:rm_rf(TargetDir),
ok = file:make_dir(TargetDir);
_ ->
- ?ERROR("Release target directory ~p already exists!\n", [TargetDir]),
+ ?ERROR("Release target directory ~p already exists!\n",
+ [TargetDir]),
?FAIL
end
end.
@@ -308,12 +318,14 @@ execute_overlay([{create, Out, Contents} | Rest], Vars, BaseDir, TargetDir) ->
end;
execute_overlay([{replace, Out, Regex, Replacement} | Rest],
Vars, BaseDir, TargetDir) ->
- execute_overlay([{replace, Out, Regex, Replacement, []} | Rest], Vars, BaseDir, TargetDir);
+ execute_overlay([{replace, Out, Regex, Replacement, []} | Rest],
+ Vars, BaseDir, TargetDir);
execute_overlay([{replace, Out, Regex, Replacement, Opts} | Rest],
Vars, BaseDir, TargetDir) ->
Filename = render(filename:join(TargetDir, Out), Vars),
{ok, OrigData} = file:read_file(Filename),
- Data = re:replace(OrigData, Regex, Replacement, [global, {return, binary}] ++ Opts),
+ Data = re:replace(OrigData, Regex, Replacement,
+ [global, {return, binary}] ++ Opts),
case file:write_file(Filename, Data) of
ok ->
?DEBUG("Edited ~s: s/~s/~s/\n", [Filename, Regex, Replacement]),