aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <[email protected]>2017-02-01 17:43:33 -0800
committerGitHub <[email protected]>2017-02-01 17:43:33 -0800
commita4d7fa1914dd0ea6c53221c3a4056fc23a7bde9d (patch)
tree3cd678e1cc5a90545ba6745334f8853d03ef2b6b /src
parent2640387cf1ba24682690b5d6f488df3d8ded5501 (diff)
parenta69bd621770a8fa8d5a7cf65a11c97732bfed829 (diff)
downloadrelx-a4d7fa1914dd0ea6c53221c3a4056fc23a7bde9d.tar.gz
relx-a4d7fa1914dd0ea6c53221c3a4056fc23a7bde9d.tar.bz2
relx-a4d7fa1914dd0ea6c53221c3a4056fc23a7bde9d.zip
Merge pull request #565 from lrascao/feature/fix_read_only_include_erts
Don't rewrite app files if contents are the same
Diffstat (limited to 'src')
-rw-r--r--src/rlx_prv_assembler.erl20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl
index 450eec9..f40a0c2 100644
--- a/src/rlx_prv_assembler.erl
+++ b/src/rlx_prv_assembler.erl
@@ -121,7 +121,10 @@ format_error({start_clean_script_generation_error, Module, Errors}) ->
rlx_util:indent(2), Module:format_error(Errors)];
format_error({strip_release, Reason}) ->
io_lib:format("Stripping debug info from release beam files failed becuase ~s",
- [beam_lib:format_error(Reason)]).
+ [beam_lib:format_error(Reason)]);
+format_error({rewrite_app_file, AppFile, Error}) ->
+ io_lib:format("Unable to rewrite .app file ~s due to ~p",
+ [AppFile, Error]).
%%%===================================================================
%%% Internal Functions
@@ -255,13 +258,16 @@ rewrite_app_file(State, App, TargetDir) ->
,AppData2
,{modules, OldModules -- ExcludedModules})
end,
- Spec = io_lib:format("~p.\n", [{application, AppName, AppData3}]),
- write_file_if_contents_differ(AppFile, Spec).
+ Spec = [{application, AppName, AppData3}],
+ case write_file_if_contents_differ(AppFile, Spec) of
+ ok -> ok;
+ Error -> ?RLX_ERROR({rewrite_app_file, AppFile, Error})
+ end.
-write_file_if_contents_differ(Filename, Bytes) ->
- ToWrite = iolist_to_binary(Bytes),
- case file:read_file(Filename) of
- {ok, ToWrite} ->
+write_file_if_contents_differ(Filename, Spec) ->
+ ToWrite = io_lib:format("~p.\n", Spec),
+ case file:consult(Filename) of
+ {ok, Spec} ->
ok;
{ok, _} ->
file:write_file(Filename, ToWrite);