aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Sloughter <[email protected]>2014-01-18 10:34:36 -0600
committerTristan Sloughter <[email protected]>2014-01-21 21:43:13 -0600
commit18bb4dc9173afa281c5e164ac995aa5377426f4d (patch)
treeb206549ed5db8167ea48f36f6b8387654db03948
parentefecde83481e6603f2ccfd4a5e608c006296ffc4 (diff)
downloadrelx-18bb4dc9173afa281c5e164ac995aa5377426f4d.tar.gz
relx-18bb4dc9173afa281c5e164ac995aa5377426f4d.tar.bz2
relx-18bb4dc9173afa281c5e164ac995aa5377426f4d.zip
properly handle config files and switching on/off dev_mode
-rw-r--r--src/rlx_prv_assembler.erl38
-rw-r--r--test/rlx_release_SUITE.erl8
2 files changed, 32 insertions, 14 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl
index fba21ca..132ada4 100644
--- a/src/rlx_prv_assembler.erl
+++ b/src/rlx_prv_assembler.erl
@@ -315,24 +315,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.
@@ -351,23 +353,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).
@@ -636,6 +639,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
diff --git a/test/rlx_release_SUITE.erl b/test/rlx_release_SUITE.erl
index c2ed984..8f27050 100644
--- a/test/rlx_release_SUITE.erl
+++ b/test/rlx_release_SUITE.erl
@@ -900,10 +900,14 @@ make_dev_mode_release(Config) ->
SysConfig = filename:join([LibDir1, "config", "sys.config"]),
write_config(SysConfig, [{this_is_a_test, "yup it is"}]),
+ VmArgs = filename:join([LibDir1, "config", "vm.args"]),
+ ec_file:write(VmArgs, ""),
+
ConfigFile = filename:join([LibDir1, "relx.config"]),
write_config(ConfigFile,
[{dev_mode, true},
{sys_config, SysConfig},
+ {vm_args, VmArgs},
{release, {foo, "0.0.1"},
[goal_app_1,
goal_app_2]}]),
@@ -919,7 +923,9 @@ make_dev_mode_release(Config) ->
?assert(ec_file:is_symlink(filename:join([OutputDir, "lib", "goal_app_2-0.0.1"]))),
?assert(ec_file:is_symlink(filename:join([OutputDir, "lib", "lib_dep_1-0.0.1"]))),
?assert(ec_file:is_symlink(filename:join([OutputDir, "releases", "0.0.1",
- "sys.config"]))).
+ "sys.config"]))),
+ ?assert(ec_file:is_symlink(filename:join([OutputDir, "releases", "0.0.1",
+ "vm.args"]))).
%%%===================================================================