aboutsummaryrefslogtreecommitdiffstats
path: root/src/rcl_prv_assembler.erl
diff options
context:
space:
mode:
authorEric <[email protected]>2012-12-10 15:02:31 -0500
committerEric <[email protected]>2012-12-10 15:07:24 -0500
commit4d21d2576afead307717d8f61a3904826f8df0e6 (patch)
tree83eb7f69f06746c0148835b5f84e651ade9d1011 /src/rcl_prv_assembler.erl
parent73c1e64c805376460fc2e26db810877cb89bc04b (diff)
downloadrelx-4d21d2576afead307717d8f61a3904826f8df0e6.tar.gz
relx-4d21d2576afead307717d8f61a3904826f8df0e6.tar.bz2
relx-4d21d2576afead307717d8f61a3904826f8df0e6.zip
assembler should create the output dir
Diffstat (limited to 'src/rcl_prv_assembler.erl')
-rw-r--r--src/rcl_prv_assembler.erl33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/rcl_prv_assembler.erl b/src/rcl_prv_assembler.erl
index c0f65c9..75a54ec 100644
--- a/src/rcl_prv_assembler.erl
+++ b/src/rcl_prv_assembler.erl
@@ -44,11 +44,16 @@ do(State) ->
{RelName, RelVsn} = rcl_state:default_release(State),
Release = rcl_state:get_release(State, RelName, RelVsn),
OutputDir = rcl_state:output_dir(State),
- case rcl_release:realized(Release) of
- true ->
- copy_app_directories_to_output(State, Release, OutputDir);
- false ->
- ?RCL_ERROR({unresolved_release, RelName, RelVsn})
+ case create_output_dir(OutputDir) of
+ ok ->
+ case rcl_release:realized(Release) of
+ true ->
+ copy_app_directories_to_output(State, Release, OutputDir);
+ false ->
+ ?RCL_ERROR({unresolved_release, RelName, RelVsn})
+ end;
+ Error ->
+ Error
end.
-spec format_error(ErrorDetail::term()) -> iolist().
@@ -69,6 +74,9 @@ format_error({release_script_generation_error, RelFile}) ->
format_error({release_script_generation_warning, Module, Warnings}) ->
["Warnings generating release \s",
rcl_util:indent(1), Module:format_warning(Warnings)];
+format_error({unable_to_create_output_dir, OutputDir}) ->
+ io_lib:format("Unable to create output directory (possible permissions issue): ~s",
+ [OutputDir]);
format_error({release_script_generation_error, Module, Errors}) ->
["Errors generating release \n",
rcl_util:indent(1), Module:format_error(Errors)].
@@ -76,6 +84,21 @@ format_error({release_script_generation_error, Module, Errors}) ->
%%%===================================================================
%%% Internal Functions
%%%===================================================================
+-spec create_output_dir(file:name()) ->
+ ok | {error, Reason::term()}.
+create_output_dir(OutputDir) ->
+ case filelib:is_dir(OutputDir) of
+ false ->
+ case rcl_util:mkdir_p(OutputDir) of
+ ok ->
+ ok;
+ {error, _} ->
+ ?RCL_ERROR({unable_to_create_output_dir, OutputDir})
+ end;
+ true ->
+ ok
+ end.
+
copy_app_directories_to_output(State, Release, OutputDir) ->
LibDir = filename:join([OutputDir, "lib"]),
ok = ec_file:mkdir_p(LibDir),