diff options
author | Tristan Sloughter <[email protected]> | 2013-09-18 19:35:38 -0500 |
---|---|---|
committer | Tristan Sloughter <[email protected]> | 2013-09-19 20:23:26 -0500 |
commit | daeae596b93605265273fd474407865211039204 (patch) | |
tree | 178eb73850c245c74a07c90c30a8eef1bced0530 /src/rlx_prv_assembler.erl | |
parent | a23fc9028f1914f7dc680a443e35cf47d347365d (diff) | |
download | relx-daeae596b93605265273fd474407865211039204.tar.gz relx-daeae596b93605265273fd474407865211039204.tar.bz2 relx-daeae596b93605265273fd474407865211039204.zip |
do not write default empty sys.config or vm.args if it exists already
Diffstat (limited to 'src/rlx_prv_assembler.erl')
-rw-r--r-- | src/rlx_prv_assembler.erl | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl index d47a850..08d7325 100644 --- a/src/rlx_prv_assembler.erl +++ b/src/rlx_prv_assembler.erl @@ -296,10 +296,9 @@ write_bin_file(State, Release, OutputDir, RelDir) -> copy_or_generate_vmargs_file(State, RelName, RelDir) -> RelVmargsPath = filename:join([RelDir, "vm.args"]), - case rlx_state:vm_args(State) of undefined -> - ok = file:write_file(RelVmargsPath, vm_args_file(RelName)); + unless_exists_write_default(RelVmargsPath, vm_args_file(RelName)); ArgsPath -> case filelib:is_regular(ArgsPath) of false -> @@ -317,7 +316,7 @@ copy_or_generate_sys_config_file(State, Release, OutputDir, RelDir) -> RelSysConfPath = filename:join([RelDir, "sys.config"]), case rlx_state:sys_config(State) of undefined -> - ok = generate_sys_config_file(RelSysConfPath), + unless_exists_write_default(RelSysConfPath, sys_config_file()), include_erts(State, Release, OutputDir, RelDir); ConfigPath -> case filelib:is_regular(ConfigPath) of @@ -329,22 +328,6 @@ copy_or_generate_sys_config_file(State, Release, OutputDir, RelDir) -> end end. -%% @doc write a generic sys.config to the path RelSysConfPath --spec generate_sys_config_file(string()) -> ok. -generate_sys_config_file(RelSysConfPath) -> - {ok, Fd} = file:open(RelSysConfPath, [write]), - io:format(Fd, - "%% Thanks to Ulf Wiger at Ericcson for these comments:~n" - "%%~n" - "%% This file is identified via the erl command line option -config File.~n" - "%% Note that File should have no extension, e.g.~n" - "%% erl -config .../sys (if this file is called sys.config)~n" - "%%~n" - "%% In this file, you can redefine application environment variables.~n" - "%% This way, you don't have to modify the .app files of e.g. OTP applications.~n" - "[].~n", []), - file:close(Fd). - %% @doc Optionally add erts directory to release, if defined. -spec include_erts(rlx_state:t(), rlx_release:t(), file:name(), file:name()) -> {ok, rlx_state:t()} | relx:error(). include_erts(State, Release, OutputDir, RelDir) -> @@ -529,7 +512,6 @@ strip_rel(Name) -> rlx_util:to_string(filename:join(filename:dirname(Name), filename:basename(Name, ".rel"))). - get_up_release(State, Release, Vsn) -> Name = rlx_release:name(Release), try @@ -578,6 +560,14 @@ get_code_paths(Release, OutDir) -> rlx_app_info:vsn_as_string(App), "ebin"]) || App <- rlx_release:application_details(Release)]. +unless_exists_write_default(Path, File) -> + case ec_file:exists(Path) of + true -> + ok; + false -> + ok = file:write_file(Path, File) + end. + erl_script(ErtsVsn) -> [<<"#!/bin/sh set -e @@ -1124,6 +1114,17 @@ consult(Cont, Str, Acc) -> consult(Cont1, eof, Acc) end.">>]. +sys_config_file() -> + [<<"%% Thanks to Ulf Wiger at Ericcson for these comments: +%% +%% This file is identified via the erl command line option -config File. +%% Note that File should have no extension, e.g. +%% erl -config .../sys (if this file is called sys.config) +%% +%% In this file, you can redefine application environment variables. +%% This way, you don't have to modify the .app files of e.g. OTP applications. +[].">>]. + vm_args_file(RelName) -> [<<"## Name of the node -name ">>, RelName, <<"@127.0.0.1 |