1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 1996-2019. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20-module(systools). 21 22%% Usage: 23%% systools:make_script("RelName") 24%% Make a boot file from RelName.rel. 25%% Generates RelName.{script,boot} 26%% systools:make_tar("RelName") 27%% Make a release package from RelName.rel. 28%% Generates RelName.tar,Z 29%% systools:script2boot(File) 30%% File.script -> File.boot 31%% systools:mk_relup("Target", ["UpFromRel"...], ["DownToRel"...], Opts) 32%% Gather all relup scripts to the relup file 33%% 34 35-export([script2boot/1, script2boot/3, compile_rel/3, 36 make_script/1, make_script/2, 37 make_tar/1, make_tar/2, 38 make_relup/3, make_relup/4]). 39 40-include("erl_compile.hrl"). 41 42%%% The behaviour_info functions have been moved to erl_internal in stdlib. 43 44%%----------------------------------------------------------------- 45%% Options is a list of {path, Path} | silent | local where path sets 46%% the search path, silent supresses error message printing on console, 47%% local generates a script with references to the directories there 48%% the applications are found. 49%%----------------------------------------------------------------- 50make_script([RelName|Opts]) when is_atom(RelName) -> 51 make_script([RelName], Opts); 52make_script(RelName) -> make_script(RelName, []). 53 54make_script(RelName, Opt) -> 55 systools_make:make_script(RelName, Opt). 56 57%%----------------------------------------------------------------- 58%% Options is a list of {path, Path} | silent | 59%% {dirs, [src,include,examples,..]} | {erts, ErtsDir} where path 60%% sets the search path, silent supresses error message printing on console, 61%% dirs includes the specified directories (per application) in the 62%% release package and erts specifies that the erts-Vsn/bin directory 63%% should be included in the release package and there it can be found. 64%%----------------------------------------------------------------- 65make_tar(RelName) -> make_tar(RelName, []). 66 67make_tar(RelName, Opt) -> 68 systools_make:make_tar(RelName, Opt). 69 70%%----------------------------------------------------------------- 71%% Create a binary form of a boot script. 72%%----------------------------------------------------------------- 73script2boot(File) -> 74 case systools_lib:file_term2binary(File ++ ".script", File ++ ".boot") of 75 {error,Error} -> 76 io:format("~ts", [systools_make:format_error(Error)]), 77 error; 78 _ -> 79 ok 80 end. 81 82script2boot(File, Output0, _Opt) -> 83 Input = File++".script", 84 Output = Output0++".boot", 85 case systools_lib:file_term2binary(Input, Output) of 86 {error,Error} -> 87 io:format("~ts", [systools_make:format_error(Error)]), 88 error; 89 _ -> 90 ok 91 end. 92 93%%----------------------------------------------------------------- 94%% Options is a list of {path, Path} | silent | noexec where path sets 95%% search path, silent supresses error message printing on console, 96%% noexec supresses writing the output "relup" file 97%%----------------------------------------------------------------- 98make_relup(ReleaseName, UpNameList, DownNameList) -> 99 systools_relup:mk_relup(ReleaseName, UpNameList, DownNameList, []). 100make_relup(ReleaseName, UpNameList, DownNameList, Opts) -> 101 systools_relup:mk_relup(ReleaseName, UpNameList, DownNameList, Opts). 102 103%%----------------------------------------------------------------- 104%% Interface for erl_compile to compile .rel files. 105%%----------------------------------------------------------------- 106compile_rel(Input, Output, Options) -> 107 systools_make:make_script(Input, Output, translate_options(Options)). 108 109translate_options(Opts) -> 110 [{path, Opts#options.includes}|Opts#options.specific]. 111