summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDave Smith <dizzyd@dizzyd.com>2010-06-21 15:08:30 -0600
committerDave Smith <dizzyd@dizzyd.com>2010-06-21 15:08:30 -0600
commit127483f32b0e6f0b7ae8901aa4f215cd070e1763 (patch)
treea0921bfe64928b868c3c1de3d610403e68ba7194 /src
parentf3039c7a87af03e7e5f8b71f82f22d8072f5b298 (diff)
Make sure to apply any file perms when doing a templated file
Diffstat (limited to 'src')
-rw-r--r--src/rebar_reltool.erl9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl
index 142c1d8..0f99009 100644
--- a/src/rebar_reltool.erl
+++ b/src/rebar_reltool.erl
@@ -261,11 +261,13 @@ execute_overlay([{copy, In, Out} | Rest], Vars, BaseDir, TargetDir) ->
rebar_utils:sh(?FMT("cp -R ~p ~p", [InFile, OutFile]), []),
execute_overlay(Rest, Vars, BaseDir, TargetDir);
execute_overlay([{template, In, Out} | Rest], Vars, BaseDir, TargetDir) ->
- {ok, InFileData} = file:read_file(render(filename:join(BaseDir, In), Vars)),
+ InFile = render(filename:join(BaseDir, In), Vars),
+ {ok, InFileData} = file:read_file(InFile),
OutFile = render(filename:join(TargetDir, Out), Vars),
ok = filelib:ensure_dir(OutFile),
case file:write_file(OutFile, render(InFileData, Vars)) of
ok ->
+ ok = apply_file_info(InFile, OutFile),
?DEBUG("Templated ~p\n", [OutFile]),
execute_overlay(Rest, Vars, BaseDir, TargetDir);
{error, Reason} ->
@@ -309,3 +311,8 @@ render(Bin, Context) ->
Str0 = re:replace(Bin, "\\\\", "\\\\\\", [global, {return, list}]),
Str1 = re:replace(Str0, "\"", "\\\\\"", [global, {return,list}]),
mustache:render(Str1, Context).
+
+
+apply_file_info(InFile, OutFile) ->
+ {ok, FileInfo} = file:read_file_info(InFile),
+ ok = file:write_file_info(OutFile, FileInfo).