diff options
Diffstat (limited to 'src/rlx_prv_assembler.erl')
-rw-r--r-- | src/rlx_prv_assembler.erl | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl index 282f050..cdbcea0 100644 --- a/src/rlx_prv_assembler.erl +++ b/src/rlx_prv_assembler.erl @@ -331,24 +331,26 @@ write_bin_file(State, Release, OutputDir, RelDir) -> ok = file:write_file(BareRel, StartFile), ok = file:change_mode(BareRel, 8#777) end, - copy_or_generate_vmargs_file(State, RelName, RelDir), + copy_or_generate_vmargs_file(State, Release, OutputDir, RelDir), copy_or_generate_sys_config_file(State, Release, OutputDir, RelDir). %% @doc copy vm.args or generate one to releases/VSN/vm.args --spec copy_or_generate_vmargs_file(rlx_state:t(), string(), file:name()) -> +-spec copy_or_generate_vmargs_file(rlx_state:t(), rlx_release:t(), file:name(), file:name()) -> {ok, rlx_state:t()} | relx:error(). -copy_or_generate_vmargs_file(State, RelName, RelDir) -> +copy_or_generate_vmargs_file(State, Release, OutputDir, RelDir) -> RelVmargsPath = filename:join([RelDir, "vm.args"]), case rlx_state:vm_args(State) of undefined -> + RelName = erlang:atom_to_list(rlx_release:name(Release)), unless_exists_write_default(RelVmargsPath, vm_args_file(RelName)); ArgsPath -> case filelib:is_regular(ArgsPath) of false -> ?RLX_ERROR({vmargs_does_not_exist, ArgsPath}); true -> - ec_file:copy(ArgsPath, RelVmargsPath) + copy_or_symlink_config_file(State, Release, OutputDir, RelDir, + ArgsPath, RelVmargsPath) end end. @@ -367,23 +369,24 @@ copy_or_generate_sys_config_file(State, Release, OutputDir, RelDir) -> false -> ?RLX_ERROR({config_does_not_exist, ConfigPath}); true -> - copy_or_symlink_sys_config_file(State, Release, OutputDir, RelDir, + copy_or_symlink_config_file(State, Release, OutputDir, RelDir, ConfigPath, RelSysConfPath) end end. %% @doc copy config/sys.config or generate one to releases/VSN/sys.config --spec copy_or_symlink_sys_config_file(rlx_state:t(), rlx_release:t(), - file:name(), file:name(), - file:name(), file:name()) -> - {ok, rlx_state:t()} | relx:error(). -copy_or_symlink_sys_config_file(State, Release, OutputDir, RelDir, - ConfigPath, RelSysConfPath) -> +-spec copy_or_symlink_config_file(rlx_state:t(), rlx_release:t(), + file:name(), file:name(), + file:name(), file:name()) -> + {ok, rlx_state:t()} | relx:error(). +copy_or_symlink_config_file(State, Release, OutputDir, RelDir, + ConfigPath, RelConfPath) -> + ensure_not_exist(RelConfPath), case rlx_state:dev_mode(State) of true -> - ok = file:make_symlink(ConfigPath, RelSysConfPath); + ok = file:make_symlink(ConfigPath, RelConfPath); _ -> - ok = ec_file:copy(ConfigPath, RelSysConfPath) + ok = ec_file:copy(ConfigPath, RelConfPath) end, include_erts(State, Release, OutputDir, RelDir). @@ -427,14 +430,14 @@ make_boot_script(State, Release, OutputDir, RelDir) -> systools:make_script(Name, CorrectedOptions) end) of ok -> - ec_cmd_log:error(rlx_state:log(State), + ec_cmd_log:info(rlx_state:log(State), "release successfully created!"), create_RELEASES(OutputDir, ReleaseFile), {ok, State}; error -> ?RLX_ERROR({release_script_generation_error, ReleaseFile}); {ok, _, []} -> - ec_cmd_log:error(rlx_state:log(State), + ec_cmd_log:info(rlx_state:log(State), "release successfully created!"), create_RELEASES(OutputDir, ReleaseFile), {ok, State}; @@ -637,6 +640,15 @@ unless_exists_write_default(Path, File) -> ok = file:write_file(Path, File) end. +-spec ensure_not_exist(file:name()) -> ok. +ensure_not_exist(RelConfPath) -> + case ec_file:exists(RelConfPath) of + false -> + ok; + _ -> + ec_file:remove(RelConfPath) + end. + erl_script(ErtsVsn) -> [<<"#!/bin/sh set -e @@ -938,8 +950,8 @@ case \"$1\" in # however, for debugging, sometimes start_clean.boot is useful. # For e.g. 'setup', one may even want to name another boot script. case \"$1\" in - console) [ -f $REL_DIR/$REL_NAME.boot ] && BOOTFILE=$REL_NAME || BOOTFILE=start ;; - console_clean) BOOTFILE=start_clean ;; + console) [ -f $REL_DIR/$REL_NAME.boot ] && BOOTFILE=$REL_DIR/$REL_NAME || BOOTFILE=$REL_DIR/start ;; + console_clean) BOOTFILE=$ROOTDIR/bin/start_clean ;; console_boot) shift BOOTFILE=\"$1\" @@ -949,7 +961,7 @@ case \"$1\" in # Setup beam-required vars EMU=beam PROGNAME=`echo $0 | sed 's/.*\\///'` - CMD=\"$BINDIR/erlexec -boot $REL_DIR/$BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH\" + CMD=\"$BINDIR/erlexec -boot $BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH\" export EMU export PROGNAME |