aboutsummaryrefslogtreecommitdiffstats
path: root/src/rcl_prv_assembler.erl
diff options
context:
space:
mode:
authorEric <[email protected]>2012-12-18 09:59:34 -0500
committerEric <[email protected]>2012-12-18 09:59:34 -0500
commit3102f456473f42b170b0c1a47786831b712b1b08 (patch)
treecb77018df7bb650675e9c943925c32635571ddfe /src/rcl_prv_assembler.erl
parentc3e728afb67101480d0c7b52c51bc522f08fb08f (diff)
downloadrelx-3102f456473f42b170b0c1a47786831b712b1b08.tar.gz
relx-3102f456473f42b170b0c1a47786831b712b1b08.tar.bz2
relx-3102f456473f42b170b0c1a47786831b712b1b08.zip
fix a bug in the ability to rebuild releases
Diffstat (limited to 'src/rcl_prv_assembler.erl')
-rw-r--r--src/rcl_prv_assembler.erl24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/rcl_prv_assembler.erl b/src/rcl_prv_assembler.erl
index 75a54ec..1ba31f8 100644
--- a/src/rcl_prv_assembler.erl
+++ b/src/rcl_prv_assembler.erl
@@ -79,7 +79,11 @@ format_error({unable_to_create_output_dir, OutputDir}) ->
[OutputDir]);
format_error({release_script_generation_error, Module, Errors}) ->
["Errors generating release \n",
- rcl_util:indent(1), Module:format_error(Errors)].
+ rcl_util:indent(1), Module:format_error(Errors)];
+format_error({unable_to_make_symlink, AppDir, TargetDir, Reason}) ->
+ io_lib:format("Unable to symlink directory ~s to ~s because \n~s~s",
+ [AppDir, TargetDir, rcl_util:indent(1),
+ file:format_error(Reason)]).
%%%===================================================================
%%% Internal Functions
@@ -125,7 +129,7 @@ copy_app(LibDir, App) ->
TargetDir = filename:join([LibDir, AppName ++ "-" ++ AppVsn]),
case rcl_app_info:link(App) of
true ->
- file:make_symlink(AppDir, TargetDir);
+ link_directory(AppDir, TargetDir);
false ->
ec_plists:map(fun(SubDir) ->
copy_dir(AppDir, TargetDir, SubDir)
@@ -138,6 +142,20 @@ copy_app(LibDir, App) ->
"LICENSE"])
end.
+link_directory(AppDir, TargetDir) ->
+ case ec_file:exists(TargetDir) of
+ true ->
+ ec_file:remove(TargetDir);
+ false ->
+ ok
+ end,
+ case file:make_symlink(AppDir, TargetDir) of
+ {error, Reason} ->
+ ?RCL_ERROR({unable_to_make_symlink, AppDir, TargetDir, Reason});
+ ok ->
+ ok
+ end.
+
copy_dir(AppDir, TargetDir, SubDir) ->
SubSource = filename:join(AppDir, SubDir),
SubTarget = filename:join(TargetDir, SubDir),
@@ -167,7 +185,7 @@ create_release_info(State, Release, OutputDir) ->
rcl_release:vsn(Release)]),
ReleaseFile = filename:join([ReleaseDir, RelName ++ ".rel"]),
ok = ec_file:mkdir_p(ReleaseDir),
- case rcl_release:metadata(Release) of
+ case rcl_release:metadata(Release) of
{ok, Meta} ->
ok = ec_file:write_term(ReleaseFile, Meta),
write_bin_file(State, Release, OutputDir, ReleaseDir);