aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <[email protected]>2015-01-10 19:42:49 -0600
committerTristan Sloughter <[email protected]>2015-01-10 21:46:33 -0600
commit05adf1f78a776406f19774de51ab42dfbd7da7ad (patch)
tree7e82f8c938fcba4c642490e38900cc6fbe6be5fb /src
parentc215312707728f0b50f4dd71e7ac9b4305850bad (diff)
downloadrelx-05adf1f78a776406f19774de51ab42dfbd7da7ad.tar.gz
relx-05adf1f78a776406f19774de51ab42dfbd7da7ad.tar.bz2
relx-05adf1f78a776406f19774de51ab42dfbd7da7ad.zip
remove system libs from tarball if set to false
Diffstat (limited to 'src')
-rw-r--r--src/rlx_cmd_args.erl12
-rw-r--r--src/rlx_config.erl5
-rw-r--r--src/rlx_prv_app_discover.erl4
-rw-r--r--src/rlx_prv_archive.erl25
-rw-r--r--src/rlx_state.erl2
5 files changed, 31 insertions, 17 deletions
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl
index 44fd226..20ea3a9 100644
--- a/src/rlx_cmd_args.erl
+++ b/src/rlx_cmd_args.erl
@@ -244,8 +244,16 @@ create(vm_args, Opts) ->
VmArgs = proplists:get_value(vm_args, Opts, undefined),
{vm_args, VmArgs};
create(system_libs, Opts) ->
- SystemLibs = proplists:get_value(system_libs, Opts, undefined),
- {system_libs, SystemLibs};
+ case proplists:get_value(system_libs, Opts, true) of
+ SystemLibs when SystemLibs =:= true
+ ; SystemLibs =:= "true" ->
+ {system_libs, true};
+ SystemLibs when SystemLibs =:= false
+ ; SystemLibs =:= "false" ->
+ {system_libs, false};
+ SystemLibsDir when is_list(SystemLibsDir) ->
+ {system_libs, SystemLibsDir}
+ end;
create(upfrom, Opts) ->
case proplists:get_value(upfrom, Opts, undefined) of
undefined ->
diff --git a/src/rlx_config.erl b/src/rlx_config.erl
index d23e3a0..dd416ee 100644
--- a/src/rlx_config.erl
+++ b/src/rlx_config.erl
@@ -131,11 +131,6 @@ load_terms({default_libs, DefaultLibs}, {ok, State}) ->
default_libs,
DefaultLibs),
{ok, State2};
-load_terms({system_libs, SystemLibs}, {ok, State}) ->
- State2 = rlx_state:put(State,
- system_libs,
- SystemLibs),
- {ok, State2};
load_terms({lib_dirs, Dirs}, {ok, State}) ->
State2 =
rlx_state:add_lib_dirs(State,
diff --git a/src/rlx_prv_app_discover.erl b/src/rlx_prv_app_discover.erl
index b5226ad..607ddd2 100644
--- a/src/rlx_prv_app_discover.erl
+++ b/src/rlx_prv_app_discover.erl
@@ -120,8 +120,8 @@ add_common_project_dirs(State) ->
-spec add_system_lib_dir(rlx_state:t()) -> [file:name()].
add_system_lib_dir(State) ->
ExcludeSystem = rlx_state:get(State, discover_exclude_system, false),
- case rlx_state:get(State, system_libs, undefined) of
- undefined ->
+ case rlx_state:get(State, system_libs, true) of
+ Atom when is_atom(Atom) ->
case ExcludeSystem of
true ->
[];
diff --git a/src/rlx_prv_archive.erl b/src/rlx_prv_archive.erl
index 0532dc5..5b4e8c1 100644
--- a/src/rlx_prv_archive.erl
+++ b/src/rlx_prv_archive.erl
@@ -72,7 +72,7 @@ make_tar(State, Release, OutputDir) ->
Vsn = rlx_release:vsn(Release),
ErtsVersion = rlx_release:erts(Release),
Opts = [{path, [filename:join([OutputDir, "lib", "*", "ebin"])]},
- {outdir, OutputDir} |
+ {outdir, OutputDir} |
case rlx_state:get(State, include_erts, true) of
true ->
Prefix = code:root_dir(),
@@ -104,6 +104,8 @@ make_tar(State, Release, OutputDir) ->
end.
update_tar(State, TempDir, OutputDir, Name, Vsn, ErtsVersion) ->
+ IncludeErts = rlx_state:get(State, include_erts, true),
+ SystemLibs = rlx_state:get(State, system_libs, true),
{RelName, RelVsn} = rlx_state:default_configured_release(State),
Release = rlx_state:get_realized_release(State, RelName, RelVsn),
TarFile = filename:join(OutputDir, Name++"-"++Vsn++".tar.gz"),
@@ -113,8 +115,7 @@ update_tar(State, TempDir, OutputDir, Name, Vsn, ErtsVersion) ->
OverlayFiles = overlay_files(OverlayVars, rlx_state:get(State, overlay, undefined), OutputDir),
ok =
erl_tar:create(TarFile,
- [{"lib", filename:join(TempDir, "lib")},
- {"releases", filename:join(TempDir, "releases")},
+ [{"releases", filename:join(TempDir, "releases")},
{filename:join(["releases", "start_erl.data"]),
filename:join([OutputDir, "releases", "start_erl.data"])},
{filename:join(["releases", "RELEASES"]),
@@ -122,14 +123,24 @@ update_tar(State, TempDir, OutputDir, Name, Vsn, ErtsVersion) ->
{filename:join(["releases", Vsn, "vm.args"]),
filename:join([OutputDir, "releases", Vsn, "vm.args"])},
{"bin", filename:join([OutputDir, "bin"])} |
- case rlx_state:get(State, include_erts, true) of
+ case IncludeErts of
false ->
- [];
+ %% Remove system libs from tarball
+ case SystemLibs of
+ false ->
+ Libs = filelib:wildcard("*", filename:join(TempDir, "lib")),
+ AllSystemLibs = filelib:wildcard("*", code:lib_dir()),
+ [{filename:join("lib", LibDir), filename:join([TempDir, "lib", LibDir])} ||
+ LibDir <- lists:subtract(Libs, AllSystemLibs)];
+ _ ->
+ [{"lib", filename:join(TempDir, "lib")}]
+ end;
_ ->
- [{"erts-"++ErtsVersion, filename:join(OutputDir, "erts-"++ErtsVersion)}]
+ [{"lib", filename:join(TempDir, "lib")},
+ {"erts-"++ErtsVersion, filename:join(OutputDir, "erts-"++ErtsVersion)}]
end]++OverlayFiles, [compressed]),
ec_cmd_log:info(rlx_state:log(State),
- "tarball ~s successfully created!~n", [TarFile]),
+ "tarball ~s successfully created!~n", [TarFile]),
ec_file:remove(TempDir, [recursive]),
{ok, State}.
diff --git a/src/rlx_state.erl b/src/rlx_state.erl
index a21c9a6..f21b682 100644
--- a/src/rlx_state.erl
+++ b/src/rlx_state.erl
@@ -157,7 +157,7 @@ new(Config, CommandLineConfig, Targets)
realized_releases=ec_dictionary:new(ec_dict),
config_values=ec_dictionary:new(ec_dict)},
State1 = rlx_state:put(State0, default_libs, true),
- State2 = rlx_state:put(State1, system_libs, undefined),
+ State2 = rlx_state:put(State1, system_libs, true),
State3 = rlx_state:put(State2, overlay_vars, []),
create_logic_providers(State3).