summaryrefslogtreecommitdiff
path: root/lib/sasl
diff options
context:
space:
mode:
authorLukas Larsson <lukas@erlang.org>2020-04-22 15:40:21 +0200
committerLukas Larsson <lukas@erlang.org>2020-04-29 10:20:13 +0200
commit2731122ba304f823f6ba16fdf4c4a82017b7f159 (patch)
tree8a3ff9bdab23b61e7fabde8e2fbc20859e15590d /lib/sasl
parent88ffb804a6545e9626915c447b8647d58a0ec929 (diff)
downloaderlang-2731122ba304f823f6ba16fdf4c4a82017b7f159.tar.gz
sasl: Add erts binary filter to systools:make_tar/2
Diffstat (limited to 'lib/sasl')
-rw-r--r--lib/sasl/doc/specs/.gitignore1
-rw-r--r--lib/sasl/doc/src/Makefile2
-rw-r--r--lib/sasl/doc/src/specs.xml4
-rw-r--r--lib/sasl/doc/src/systools.xml28
-rw-r--r--lib/sasl/src/systools.erl24
-rw-r--r--lib/sasl/src/systools_make.erl36
-rw-r--r--lib/sasl/test/systools_SUITE.erl83
7 files changed, 146 insertions, 32 deletions
diff --git a/lib/sasl/doc/specs/.gitignore b/lib/sasl/doc/specs/.gitignore
new file mode 100644
index 0000000000..322eebcb06
--- /dev/null
+++ b/lib/sasl/doc/specs/.gitignore
@@ -0,0 +1 @@
+specs_*.xml
diff --git a/lib/sasl/doc/src/Makefile b/lib/sasl/doc/src/Makefile
index 684fd2b5e4..249b278f6b 100644
--- a/lib/sasl/doc/src/Makefile
+++ b/lib/sasl/doc/src/Makefile
@@ -53,6 +53,8 @@ XML_FILES = \
$(XML_PART_FILES) $(XML_REF3_FILES) $(XML_REF4_FILES) \
$(XML_REF6_FILES) $(XML_APPLICATION_FILES)
+TOP_SPECS_FILE = specs.xml
+
# ----------------------------------------------------
include $(ERL_TOP)/make/doc.mk
diff --git a/lib/sasl/doc/src/specs.xml b/lib/sasl/doc/src/specs.xml
new file mode 100644
index 0000000000..f64b7df114
--- /dev/null
+++ b/lib/sasl/doc/src/specs.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<specs xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xi:include href="../specs/specs_systools.xml"/>
+</specs>
diff --git a/lib/sasl/doc/src/systools.xml b/lib/sasl/doc/src/systools.xml
index 483445f954..13878d379a 100644
--- a/lib/sasl/doc/src/systools.xml
+++ b/lib/sasl/doc/src/systools.xml
@@ -251,8 +251,8 @@
warnings are issued for calls to undefined functions.</p>
<p>By default, errors and warnings are printed to tty and
the function returns <c>ok</c> or <c>error</c>. If option
- <c>silent</c> is specified, the function instead returns
<c>{ok,Module,Warnings}</c> or <c>{error,Module,Error}</c>.
+ <c>silent</c> is specified, the function instead returns
Warnings and errors can be converted to strings by calling
<c>Module:format_warning(Warnings)</c> or
<c>Module:format_error(Error)</c>.</p>
@@ -265,25 +265,9 @@
</func>
<func>
- <name since="">make_tar(Name) -> Result</name>
- <name since="">make_tar(Name, [Opt]) -> Result</name>
+ <name name="make_tar" arity="1" since=""/>
+ <name name="make_tar" arity="2" since=""/>
<fsummary>Creates a release package.</fsummary>
- <type>
- <v>Name = string()</v>
- <v>Opt = {dirs,[IncDir]} | {path,[Dir]} | {variables,[Var]} | {var_tar,VarTar} | {erts,Dir} | src_tests | exref | {exref,[App]} | silent | {outdir,Dir} | | no_warn_sasl | warnings_as_errors | {extra_files, ExtraFiles}</v>
- <v>&nbsp;Dir = string()</v>
- <v>&nbsp;IncDir = src | include | atom()</v>
- <v>&nbsp;Var = {VarName,PreFix}</v>
- <v>&nbsp;&nbsp;VarName = Prefix = string()</v>
- <v>&nbsp;VarTar = include | ownfile | omit</v>
- <v>&nbsp;Machine = atom()</v>
- <v>&nbsp;App = atom()</v>
- <v>Result = ok | error | {ok,Module,Warnings} | {error,Module,Error}</v>
- <v>&nbsp;Module = atom()</v>
- <v>&nbsp;Warning = Error = term()</v>
- <v>&nbsp;ExtraFiles = [{NameInArchive, file:filename_all()}]</v>
- <v>&nbsp;NameInArchive = string()</v>
- </type>
<desc>
<p>Creates a release package file <c>Name.tar.gz</c>.
This file must be uncompressed and unpacked on the target
@@ -364,8 +348,10 @@ myapp-1/ebin/myapp.app
specified using option <c>path</c>. In the case of <c>sys.config</c>
it is not included if <c>sys.config.src</c> is found.</p>
<p>If the release package is to contain a new Erlang runtime
- system, the <c>bin</c> directory of the specified runtime
- system <c>{erts,Dir}</c> is copied to <c>erts-ErtsVsn/bin</c>.</p>
+ system, the <c>erts-ErtsVsn/bin</c> directory of the specified runtime
+ system <c>{erts,Dir}</c> is copied to <c>erts-ErtsVsn/bin</c>. Some
+ erts executables are not copied by default, if you want to include all
+ executables you can give the <c>erts_all</c> option.</p>
<p>All checks with function
<seemfa marker="#make_script/1"><c>make_script</c></seemfa>
are performed before the release package is created.
diff --git a/lib/sasl/src/systools.erl b/lib/sasl/src/systools.erl
index 34eca6679f..a6aa4919ec 100644
--- a/lib/sasl/src/systools.erl
+++ b/lib/sasl/src/systools.erl
@@ -62,8 +62,32 @@ make_script(RelName, Opt) ->
%% release package and erts specifies that the erts-Vsn/bin directory
%% should be included in the release package and there it can be found.
%%-----------------------------------------------------------------
+-spec make_tar(Name) -> Result when
+ Name :: string(),
+ Result :: ok | error | {ok, Module :: module(), Warnings :: term()} |
+ {error, Module :: module(), Error :: term()}.
make_tar(RelName) -> make_tar(RelName, []).
+-spec make_tar(Name, Opts) -> Result when
+ Name :: string(),
+ Opts :: [Opt],
+ Opt :: {dirs,[IncDir]} | {path,[Dir]} |
+ {variables,[Var]} | {var_tar,VarTar} |
+ {erts,Dir} | erts_all | src_tests | exref |
+ {exref,[App]} | silent | {outdir,Dir} |
+ no_warn_sasl | warnings_as_errors |
+ {extra_files, ExtraFiles},
+ Dir :: file:filename_all(),
+ IncDir :: src | include | atom(),
+ Var :: {VarName,PreFix},
+ VarName :: string(),
+ PreFix :: string(),
+ VarTar :: include | ownfile | omit,
+ App :: atom(),
+ Result :: ok | error | {ok, Module :: module(), Warnings :: term()} |
+ {error, Module :: module(), Error :: term()},
+ ExtraFiles :: [{NameInArchive, file:filename_all()}],
+ NameInArchive :: string().
make_tar(RelName, Opt) ->
systools_make:make_tar(RelName, Opt).
diff --git a/lib/sasl/src/systools_make.erl b/lib/sasl/src/systools_make.erl
index 61a39884f3..dae089f215 100644
--- a/lib/sasl/src/systools_make.erl
+++ b/lib/sasl/src/systools_make.erl
@@ -1585,6 +1585,16 @@ preloaded() ->
prim_inet,prim_zip,zlib]).
%%______________________________________________________________________
+%% This is the erts binaries that should *not* be part of a systool:make_tar package
+
+erts_binary_filter() ->
+ Cmds = ["typer", "dialyzer", "ct_run", "yielding_c_fun", "erlc"],
+ case os:type() of
+ {unix,_} -> Cmds;
+ {win32,_} -> [ [Cmd, ".exe"] || Cmd <- Cmds]
+ end.
+
+%%______________________________________________________________________
%% Kernel processes; processes that are specially treated by the init
%% process. If a kernel process terminates the whole system terminates.
%% kernel_processes() -> [{Name, Mod, Func, Args}]
@@ -1973,18 +1983,26 @@ add_priv(ADir, ToDir, Tar) ->
end.
add_erts_bin(Tar, Release, Flags) ->
- case get_flag(erts,Flags) of
- {erts,ErtsDir} ->
- EVsn = Release#release.erts_vsn,
- FromDir = filename:join([to_list(ErtsDir),
- "erts-" ++ EVsn, "bin"]),
- dirp(FromDir),
- ToDir = filename:join("erts-" ++ EVsn, "bin"),
- add_to_tar(Tar, FromDir, ToDir);
+ case {get_flag(erts,Flags),member(erts_all,Flags)} of
+ {{erts,ErtsDir},true} ->
+ add_erts_bin(Tar, Release, ErtsDir, []);
+ {{erts,ErtsDir},false} ->
+ add_erts_bin(Tar, Release, ErtsDir, erts_binary_filter());
_ ->
ok
end.
+add_erts_bin(Tar, Release, ErtsDir, Filters) ->
+ FlattenedFilters = [filename:flatten(Filter) || Filter <- Filters],
+ EVsn = Release#release.erts_vsn,
+ FromDir = filename:join([to_list(ErtsDir),
+ "erts-" ++ EVsn, "bin"]),
+ ToDir = filename:join("erts-" ++ EVsn, "bin"),
+ {ok, Bins} = file:list_dir(FromDir),
+ [add_to_tar(Tar, filename:join(FromDir,Bin), filename:join(ToDir,Bin))
+ || Bin <- Bins, not lists:member(Bin, FlattenedFilters)],
+ ok.
+
%%______________________________________________________________________
%% Tar functions.
@@ -2247,6 +2265,8 @@ cat([{dirs, D} | Args], X) ->
%%% erts ---------------------------------------------------------------
cat([{erts, E} | Args], X) when is_list(E)->
cat(Args, X);
+cat([erts_all | Args], X) ->
+ cat(Args, X);
%%% src_tests ----------------------------------------------------
cat([src_tests | Args], X) ->
cat(Args, X);
diff --git a/lib/sasl/test/systools_SUITE.erl b/lib/sasl/test/systools_SUITE.erl
index fb1dc03dcd..3c60c0fa21 100644
--- a/lib/sasl/test/systools_SUITE.erl
+++ b/lib/sasl/test/systools_SUITE.erl
@@ -69,7 +69,7 @@ groups() ->
[tar_options, relname_tar, normal_tar, no_mod_vsn_tar, system_files_tar,
system_src_file_tar, invalid_system_files_tar, variable_tar,
src_tests_tar, var_tar, exref_tar, link_tar, no_sasl_tar,
- otp_9507_path_ebin, additional_files_tar]},
+ otp_9507_path_ebin, additional_files_tar, erts_tar]},
{relup, [],
[normal_relup, restart_relup, abnormal_relup, no_sasl_relup,
no_appup_relup, bad_appup_relup, app_start_type_relup, regexp_relup
@@ -1041,13 +1041,90 @@ additional_files_tar(Config) ->
ok.
-
system_files_tar(cleanup,Config) ->
Dir = ?privdir,
file:delete(filename:join(Dir,"sys.config")),
file:delete(filename:join(Dir,"relup")),
ok.
+erts_tar(Config) ->
+
+ {ok, OldDir} = file:get_cwd(),
+
+ {LatestDir, LatestName} = create_script(current_all,Config),
+
+ ERTS_VSN = erlang:system_info(version),
+ ERTS_DIR = fname(["erts-" ++ ERTS_VSN,bin]),
+
+ %% List of all expected executable files in erts/bin
+ %% This list needs to be kept up to date whenever a file is
+ %% added or removed.
+ {Default, Ignored} =
+ case os:type() of
+ {unix,_} ->
+ {["beam.smp","dyn_erl","epmd","erl","erl_call","erl_child_setup",
+ "erlexec","erl.src","escript","heart","inet_gethost","run_erl",
+ "start","start_erl.src","start.src","to_erl"],
+ ["ct_run","dialyzer","erlc","typer","yielding_c_fun"]};
+ {win32, _} ->
+ {["beam.smp.pdb","erl.exe",
+ "erl.pdb","erl_log.exe","erlexec.dll","erlsrv.exe","heart.exe",
+ "start_erl.exe","werl.exe","beam.smp.dll",
+ "epmd.exe","erl.ini","erl_call.exe",
+ "erlexec.pdb","escript.exe","inet_gethost.exe","werl.pdb"],
+ ["dialyzer.exe","erlc.exe","yielding_c_fun.exe","ct_run.exe","typer.exe"]}
+ end,
+
+ ErtsTarContent =
+ fun(TarName) ->
+ lists:sort(
+ [filename:basename(File)
+ || File <- tar_contents(TarName),
+ string:equal(filename:dirname(File),ERTS_DIR),
+ %% Filter out beam.*.smp.*
+ re:run(filename:basename(File), "beam\\.[^\\.]+\\.smp(\\.dll)?") == nomatch,
+ %% Filter out any erl_child_setup.*
+ re:run(filename:basename(File), "erl_child_setup\\..*") == nomatch
+ ])
+ end,
+
+ DataDir = filename:absname(?copydir),
+ LibDir = fname([DataDir, d_normal, lib]),
+ P = [fname([LibDir, 'db-2.1', ebin])],
+
+ ok = file:set_cwd(LatestDir),
+
+ {ok, _, []} = systools:make_script(LatestName, [silent, {path, P}, {script_name, "start"}]),
+ ok = systools:make_tar(LatestName, [{path, P}, {erts, code:root_dir()}]),
+ ErtsContent = ErtsTarContent(LatestName),
+
+ case lists:sort(Default) of
+ ErtsContent ->
+ ok;
+ Expected ->
+ ct:pal("Content: ~p",[ErtsContent]),
+ ct:pal("Expected: ~p",[Expected]),
+ ct:fail("Incorrect erts bin content")
+ end,
+
+ ok = systools:make_tar(LatestName, [{path, P},
+ {erts, code:root_dir()},
+ erts_all]),
+ ErtsAllContent = ErtsTarContent(LatestName),
+
+ case lists:sort(Default ++ Ignored) of
+ ErtsAllContent ->
+ ok;
+ ExpectedIgn ->
+ ct:pal("Content: ~p",[ErtsAllContent]),
+ ct:pal("Expected: ~p",[ExpectedIgn]),
+ ct:fail("Incorrect erts bin content")
+ end,
+
+ ok = file:set_cwd(OldDir),
+ ok.
+
+
%% make_tar: Check that sys.config.src and not sys.config is included
system_src_file_tar(Config) ->
{ok, OldDir} = file:get_cwd(),
@@ -2342,7 +2419,7 @@ delete_tree(Dir) ->
end.
tar_contents(Name) ->
- {ok, Cont} = erl_tar:table(Name ++ ".tar.gz", [compressed]),
+ {ok, Cont} = erl_tar:table(tar_name(Name), [compressed]),
Cont.
tar_name(Name) ->