aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJordan Wilberding <[email protected]>2014-11-24 07:38:03 -0800
committerJordan Wilberding <[email protected]>2014-11-24 07:38:03 -0800
commitdb8e61e4fc30565c09ee9d348287cc4e825ef983 (patch)
tree6e25253e9b9db2ef73075d4753b060c2b9d7b854
parent2c192466f54a7b8ffaa56fc6f9df7057c630a2bb (diff)
parentf89df2f4d693c8522fc9b911a6fc5bef31f338fc (diff)
downloadrelx-db8e61e4fc30565c09ee9d348287cc4e825ef983.tar.gz
relx-db8e61e4fc30565c09ee9d348287cc4e825ef983.tar.bz2
relx-db8e61e4fc30565c09ee9d348287cc4e825ef983.zip
Merge pull request #272 from tsloughter/exclude_erts_libs
if include_erts is false, do not include stdlibs
-rwxr-xr-xpriv/templates/bin.dtl3
-rw-r--r--priv/templates/extended_bin.dtl4
-rw-r--r--src/rlx_prv_assembler.erl23
3 files changed, 25 insertions, 5 deletions
diff --git a/priv/templates/bin.dtl b/priv/templates/bin.dtl
index bb83434..434cbd4 100755
--- a/priv/templates/bin.dtl
+++ b/priv/templates/bin.dtl
@@ -47,6 +47,7 @@ export BINDIR="$ERTS_DIR/bin"
export EMU="beam"
export PROGNAME="erl"
export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH"
+ERTS_LIB_DIR="$ERTS_DIR/../lib"
cd "$ROOTDIR"
@@ -57,7 +58,7 @@ ARGS="$@"
set -- "$ERL_OPTS"
[ "$SYS_CONFIG" ] && set -- "$@" -config "$SYS_CONFIG"
[ "$VM_ARGS" ] && set -- "$@" -args_file "$VM_ARGS"
-set -- "$@" -boot "$REL_DIR/$REL_NAME" "$ARGS"
+set -- "$@" -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" -boot "$REL_DIR/$REL_NAME" "$ARGS"
# Boot the release
$BINDIR/erlexec $@
diff --git a/priv/templates/extended_bin.dtl b/priv/templates/extended_bin.dtl
index fa77a4a..bd1e981 100644
--- a/priv/templates/extended_bin.dtl
+++ b/priv/templates/extended_bin.dtl
@@ -36,6 +36,7 @@ relx_rem_sh() {
# Setup remote shell command to control node
exec "$BINDIR/erl" "$NAME_TYPE" "$id" -remsh "$NAME" -boot start_clean \
+ -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
-setcookie "$COOKIE" -kernel net_ticktime $TICKTIME
}
@@ -146,6 +147,7 @@ export BINDIR="$ERTS_DIR/bin"
export EMU="beam"
export PROGNAME="erl"
export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH"
+ERTS_LIB_DIR="$ERTS_DIR/../lib"
cd "$ROOTDIR"
@@ -321,6 +323,7 @@ case "$1" in
# Build an array of arguments to pass to exec later on
# Build it here because this command will be used for logging.
set -- "$BINDIR/erlexec" -boot "$BOOTFILE" \
+ -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
-env ERL_LIBS "$REL_DIR/lib" -config "$CONFIG_PATH" \
-args_file "$VMARGS_PATH"
@@ -357,6 +360,7 @@ case "$1" in
# Build it here because this command will be used for logging.
set -- "$BINDIR/erlexec" $FOREGROUNDOPTIONS \
-boot "$REL_DIR/$BOOTFILE" -mode embedded -config "$CONFIG_PATH" \
+ -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
-args_file "$VMARGS_PATH"
# Dump environment info for logging purposes
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl
index 9972988..ee81631 100644
--- a/src/rlx_prv_assembler.erl
+++ b/src/rlx_prv_assembler.erl
@@ -147,6 +147,7 @@ copy_app_directories_to_output(State, Release, OutputDir) ->
LibDir = filename:join([OutputDir, "lib"]),
ok = ec_file:mkdir_p(LibDir),
IncludeSrc = rlx_state:include_src(State),
+ IncludeErts = rlx_state:get(State, include_erts, true),
Apps = prepare_applications(State, rlx_release:application_details(Release)),
Result = lists:filter(fun({error, _}) ->
true;
@@ -154,7 +155,7 @@ copy_app_directories_to_output(State, Release, OutputDir) ->
false
end,
lists:flatten(ec_plists:map(fun(App) ->
- copy_app(LibDir, App, IncludeSrc)
+ copy_app(LibDir, App, IncludeSrc, IncludeErts)
end, Apps))),
case Result of
[E | _] ->
@@ -171,7 +172,7 @@ prepare_applications(State, Apps) ->
Apps
end.
-copy_app(LibDir, App, IncludeSrc) ->
+copy_app(LibDir, App, IncludeSrc, IncludeErts) ->
AppName = erlang:atom_to_list(rlx_app_info:name(App)),
AppVsn = rlx_app_info:original_vsn(App),
AppDir = rlx_app_info:dir(App),
@@ -182,10 +183,23 @@ copy_app(LibDir, App, IncludeSrc) ->
%% a release dir
ok;
true ->
- copy_app(App, AppDir, TargetDir, IncludeSrc)
+ case IncludeErts of
+ false ->
+ case is_erts_lib(AppDir) of
+ true ->
+ [];
+ false ->
+ copy_app_(App, AppDir, TargetDir, IncludeSrc)
+ end;
+ _ ->
+ copy_app_(App, AppDir, TargetDir, IncludeSrc)
+ end
end.
-copy_app(App, AppDir, TargetDir, IncludeSrc) ->
+is_erts_lib(Dir) ->
+ lists:prefix(filename:split(list_to_binary(code:lib_dir())), filename:split(Dir)).
+
+copy_app_(App, AppDir, TargetDir, IncludeSrc) ->
remove_symlink_or_directory(TargetDir),
case rlx_app_info:link(App) of
true ->
@@ -443,6 +457,7 @@ include_erts(State, Release, OutputDir, RelDir) ->
make_boot_script(State, Release, OutputDir, RelDir) ->
Options = [{path, [RelDir | rlx_util:get_code_paths(Release, OutputDir)]},
{outdir, RelDir},
+ {variables, [{"ERTS_LIB_DIR", code:lib_dir()}]},
no_module_tests, silent],
Name = erlang:atom_to_list(rlx_release:name(Release)),
ReleaseFile = filename:join([RelDir, Name ++ ".rel"]),