diff options
author | Luis Rascão <[email protected]> | 2017-11-11 02:01:51 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2017-11-11 02:01:51 +0000 |
commit | 1d051663982502620dbdd2b372aee52894981568 (patch) | |
tree | 5859cfa77aeca68f30c03ceec8ee31cd2d3e943c /src/rlx_prv_assembler.erl | |
parent | fb91587091ad8a9da7c22598e962d0f21dcc17ee (diff) | |
parent | 2868d7a7ae79829c740ff9a49e22e2ccf9e6296c (diff) | |
download | relx-1d051663982502620dbdd2b372aee52894981568.tar.gz relx-1d051663982502620dbdd2b372aee52894981568.tar.bz2 relx-1d051663982502620dbdd2b372aee52894981568.zip |
Merge pull request #618 from ferd/otp-20-unicode-support
OTP-20 unicode support and OTP-21 readiness
Diffstat (limited to 'src/rlx_prv_assembler.erl')
-rw-r--r-- | src/rlx_prv_assembler.erl | 79 |
1 files changed, 46 insertions, 33 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl index a6bf5f8..65975e5 100644 --- a/src/rlx_prv_assembler.erl +++ b/src/rlx_prv_assembler.erl @@ -111,12 +111,12 @@ 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, rlx_util:indent(2), file:format_error(Reason)]); -format_error(start_clean_script_generation_error) -> +format_error(boot_script_generation_error) -> "Unknown internal release error generating start_clean.boot"; -format_error({start_clean_script_generation_warning, Module, Warnings}) -> +format_error({boot_script_generation_warning, Module, Warnings}) -> ["Warnings generating start_clean.boot \s", rlx_util:indent(2), Module:format_warning(Warnings)]; -format_error({start_clean_script_generation_error, Module, Errors}) -> +format_error({boot_script_generation_error, Module, Errors}) -> ["Errors generating start_clean.boot \n", rlx_util:indent(2), Module:format_error(Errors)]; format_error({strip_release, Reason}) -> @@ -354,17 +354,22 @@ create_release_info(State0, Release0, OutputDir) -> ReleaseDir = rlx_util:release_output_dir(State0, Release0), ReleaseFile = filename:join([ReleaseDir, RelName ++ ".rel"]), StartCleanFile = filename:join([ReleaseDir, "start_clean.rel"]), + NoDotErlFile = filename:join([ReleaseDir, "no_dot_erlang.rel"]), ok = ec_file:mkdir_p(ReleaseDir), Release1 = rlx_release:relfile(Release0, ReleaseFile), State1 = rlx_state:update_realized_release(State0, Release1), case rlx_release:metadata(Release1) of {ok, Meta} -> - case rlx_release:start_clean_metadata(Release1) of - {ok, StartCleanMeta} -> + case {rlx_release:start_clean_metadata(Release1), + rlx_release:no_dot_erlang_metadata(Release1)} of + {{ok, StartCleanMeta}, {ok, NoDotErlMeta}} -> ok = ec_file:write_term(ReleaseFile, Meta), ok = ec_file:write_term(StartCleanFile, StartCleanMeta), + ok = ec_file:write_term(NoDotErlFile, NoDotErlMeta), write_bin_file(State1, Release1, OutputDir, ReleaseDir); - E -> + {{ok, _}, E} -> + E; + {_, E} -> E end; E -> @@ -416,13 +421,13 @@ write_bin_file(State, Release, OutputDir, RelDir) -> _ -> VsnRelStartFile = case OsFamily of unix -> VsnRel; - win32 -> string:concat(VsnRel, ".cmd") + win32 -> rlx_string:concat(VsnRel, ".cmd") end, ok = file:write_file(VsnRelStartFile, StartFile), ok = file:change_mode(VsnRelStartFile, 8#777), BareRelStartFile = case OsFamily of unix -> BareRel; - win32 -> string:concat(BareRel, ".cmd") + win32 -> rlx_string:concat(BareRel, ".cmd") end, ok = file:write_file(BareRelStartFile, StartFile), ok = file:change_mode(BareRelStartFile, 8#777) @@ -494,15 +499,15 @@ hook_filename(builtin_status) -> "hooks/builtin/status". hook_invocation({custom, CustomScript}) -> CustomScript; %% the pid builtin hook with no arguments writes to pid file %% at /var/run/{{ rel_name }}.pid -hook_invocation(pid) -> string:join(["hooks/builtin/pid", +hook_invocation(pid) -> rlx_string:join(["hooks/builtin/pid", "/var/run/$REL_NAME.pid"], "|"); -hook_invocation({pid, PidFile}) -> string:join(["hooks/builtin/pid", +hook_invocation({pid, PidFile}) -> rlx_string:join(["hooks/builtin/pid", PidFile], "|"); hook_invocation(wait_for_vm_start) -> "hooks/builtin/wait_for_vm_start"; hook_invocation({wait_for_process, Name}) -> %% wait_for_process takes an atom as argument %% which is the process name to wait for - string:join(["hooks/builtin/wait_for_process", + rlx_string:join(["hooks/builtin/wait_for_process", atom_to_list(Name)], "|"); hook_invocation(builtin_status) -> "hooks/builtin/status". @@ -692,6 +697,7 @@ make_boot_script(State, Release, OutputDir, RelDir) -> ec_cmd_log:info(rlx_state:log(State), "release successfully created!"), create_RELEASES(OutputDir, ReleaseFile), + create_no_dot_erlang(RelDir, OutputDir, Options, State), create_start_clean(RelDir, OutputDir, Options, State); error -> ?RLX_ERROR({release_script_generation_error, ReleaseFile}); @@ -699,6 +705,7 @@ make_boot_script(State, Release, OutputDir, RelDir) -> ec_cmd_log:info(rlx_state:log(State), "release successfully created!"), create_RELEASES(OutputDir, ReleaseFile), + create_no_dot_erlang(RelDir, OutputDir, Options, State), create_start_clean(RelDir, OutputDir, Options, State); {ok,Module,Warnings} -> ?RLX_ERROR({release_script_generation_warn, Module, Warnings}); @@ -728,29 +735,35 @@ make_boot_script_variables(State) -> [{"ERTS_LIB_DIR", code:lib_dir()}] end. +create_no_dot_erlang(RelDir, OutputDir, Options, State) -> + create_boot_file(RelDir, OutputDir, Options, State, "no_dot_erlang"). + create_start_clean(RelDir, OutputDir, Options, State) -> + create_boot_file(RelDir, OutputDir, Options, State, "start_clean"). + +create_boot_file(RelDir, OutputDir, Options, State, Name) -> case rlx_util:make_script(Options, fun(CorrectedOptions) -> - systools:make_script("start_clean", CorrectedOptions) + systools:make_script(Name, CorrectedOptions) end) of ok -> - ok = ec_file:copy(filename:join([RelDir, "start_clean.boot"]), - filename:join([OutputDir, "bin", "start_clean.boot"])), - ec_file:remove(filename:join([RelDir, "start_clean.rel"])), - ec_file:remove(filename:join([RelDir, "start_clean.script"])), + ok = ec_file:copy(filename:join([RelDir, Name++".boot"]), + filename:join([OutputDir, "bin", Name++".boot"])), + ec_file:remove(filename:join([RelDir, Name++".rel"])), + ec_file:remove(filename:join([RelDir, Name++".script"])), {ok, State}; error -> - ?RLX_ERROR(start_clean_script_generation_error); + ?RLX_ERROR(boot_script_generation_error); {ok, _, []} -> - ok = ec_file:copy(filename:join([RelDir, "start_clean.boot"]), - filename:join([OutputDir, "bin", "start_clean.boot"])), - ec_file:remove(filename:join([RelDir, "start_clean.rel"])), - ec_file:remove(filename:join([RelDir, "start_clean.script"])), + ok = ec_file:copy(filename:join([RelDir, Name++".boot"]), + filename:join([OutputDir, "bin", Name++".boot"])), + ec_file:remove(filename:join([RelDir, Name++".rel"])), + ec_file:remove(filename:join([RelDir, Name++".script"])), {ok, State}; {ok,Module,Warnings} -> - ?RLX_ERROR({start_clean_script_generation_warn, Module, Warnings}); + ?RLX_ERROR({boot_script_generation_warn, Module, Warnings}); {error,Module,Error} -> - ?RLX_ERROR({start_clean_script_generation_error, Module, Error}) + ?RLX_ERROR({boot_script_generation_error, Module, Error}) end. create_RELEASES(OutputDir, ReleaseFile) -> @@ -796,15 +809,15 @@ extended_bin_file_contents(OsFamily, RelName, RelVsn, ErtsVsn, ErlOpts, Hooks, E win32 -> extended_bin_windows end, %% turn all the hook lists into space separated strings - PreStartHooks = string:join(proplists:get_value(pre_start, Hooks, []), " "), - PostStartHooks = string:join(proplists:get_value(post_start, Hooks, []), " "), - PreStopHooks = string:join(proplists:get_value(pre_stop, Hooks, []), " "), - PostStopHooks = string:join(proplists:get_value(post_stop, Hooks, []), " "), - PreInstallUpgradeHooks = string:join(proplists:get_value(pre_install_upgrade, + PreStartHooks = rlx_string:join(proplists:get_value(pre_start, Hooks, []), " "), + PostStartHooks = rlx_string:join(proplists:get_value(post_start, Hooks, []), " "), + PreStopHooks = rlx_string:join(proplists:get_value(pre_stop, Hooks, []), " "), + PostStopHooks = rlx_string:join(proplists:get_value(post_stop, Hooks, []), " "), + PreInstallUpgradeHooks = rlx_string:join(proplists:get_value(pre_install_upgrade, Hooks, []), " "), - PostInstallUpgradeHooks = string:join(proplists:get_value(post_install_upgrade, + PostInstallUpgradeHooks = rlx_string:join(proplists:get_value(post_install_upgrade, Hooks, []), " "), - StatusHook = string:join(proplists:get_value(status, Hooks, []), " "), + StatusHook = rlx_string:join(proplists:get_value(status, Hooks, []), " "), {ExtensionsList1, ExtensionDeclarations1} = lists:foldl(fun({Name, Script}, {ExtensionsList0, ExtensionDeclarations0}) -> @@ -816,10 +829,10 @@ extended_bin_file_contents(OsFamily, RelName, RelVsn, ErtsVsn, ErlOpts, Hooks, E end, {[], []}, Extensions), % pipe separated string of extensions, to show on the start script usage % (eg. foo|bar) - ExtensionsList = string:join(ExtensionsList1 ++ ["undefined"], "|"), + ExtensionsList = rlx_string:join(ExtensionsList1 ++ ["undefined"], "|"), % command separated string of extension script declarations % (eg. foo_extension="path/to/foo_script") - ExtensionDeclarations = string:join(ExtensionDeclarations1, ";"), + ExtensionDeclarations = rlx_string:join(ExtensionDeclarations1, ";"), render(Template, [{rel_name, RelName}, {rel_vsn, RelVsn}, {erts_vsn, ErtsVsn}, {erl_opts, ErlOpts}, {pre_start_hooks, PreStartHooks}, @@ -833,7 +846,7 @@ extended_bin_file_contents(OsFamily, RelName, RelVsn, ErtsVsn, ErlOpts, Hooks, E {extension_declarations, ExtensionDeclarations}]). erl_ini(OutputDir, ErtsVsn) -> - ErtsDirName = string:concat("erts-", ErtsVsn), + ErtsDirName = rlx_string:concat("erts-", ErtsVsn), BinDir = filename:join([OutputDir, ErtsDirName, bin]), render(erl_ini, [{bin_dir, BinDir}, {output_dir, OutputDir}]). |