aboutsummaryrefslogtreecommitdiff
path: root/rel/reltool.config.script
blob: ac3f5c7cb43fb487e7919d3aa319428d8242d98b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
%%%-------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% @copyright (C) 2013-2022, Evgeniy Khramtsov
%%% @doc
%%%
%%% @end
%%% Created :  8 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%-------------------------------------------------------------------

TopDir = filename:join(filename:dirname(SCRIPT), ".."),

GetDeps = fun(Config, GetDepsFun) ->
                  case catch rebar_config:consult_file(Config) of
                      {ok, Data} ->
                          case lists:keyfind(deps, 1, Data) of
                              {deps, Deps} ->
                                  lists:map(fun({Dep, _, _}) ->
                                                    [Dep, GetDepsFun(filename:join([TopDir,
                                                                                    "deps",
                                                                                    Dep,
                                                                                    "rebar.config"]),
                                                                     GetDepsFun)]
                                            end, Deps);
                              _ ->
                                  []
                          end;
                      _ ->
                          []
                  end
          end,

Vars = case file:consult(filename:join([TopDir, "vars.config"])) of
           {ok, Terms} ->
               Terms;
           _Err ->
               []
       end,

RequiredOTPApps = [sasl, crypto, public_key, ssl,
                   mnesia, inets, compiler, asn1,
                   syntax_tools, os_mon, xmerl],

ConfiguredOTPApps = lists:flatmap(
                      fun({tools, true}) ->
                              [tools, runtime_tools];
                         ({odbc, true}) ->
                              [odbc];
                         (_) ->
                              []
                      end, Vars),

OTPApps = RequiredOTPApps ++ ConfiguredOTPApps,

DepApps = lists:usort(lists:flatten(GetDeps(filename:join(TopDir, "rebar.config"), GetDeps))),

Sys = [{lib_dirs, []},
       {erts, [{mod_cond, derived}, {app_file, strip}]},
       {app_file, strip},
       {rel, "ejabberd", proplists:get_value(vsn, Vars),
        [
         kernel,
         stdlib,
         ejabberd
        ] ++ OTPApps ++ DepApps},
       {rel, "start_clean", "",
        [
         kernel,
         stdlib
        ]},
       {boot_rel, "ejabberd"},
       {profile, embedded},
       {incl_cond, exclude},
       {excl_archive_filters, [".*"]}, %% Do not archive built libs
       {excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)",
                           "^erts.*/(doc|info|include|lib|man|src)"]},
       {excl_app_filters, ["\.gitignore"]},
       {app, stdlib, [{incl_cond, include}]},
       {app, kernel, [{incl_cond, include}]},
       {app, ejabberd, [{incl_cond, include}, {lib_dir, ".."}]}]
++ lists:map(
     fun(App) ->
             {app, App, [{incl_cond, include},
                         {lib_dir, "../deps/" ++ atom_to_list(App)}]}
     end, DepApps)
++ lists:map(
     fun(App) ->
             {app, App, [{incl_cond, include}]}
     end, OTPApps).

Overlay = [
           {mkdir, "logs"},
           {mkdir, "database"},
           {mkdir, "conf"},
           {mkdir, "doc"},
           {template, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
           {template, "../ejabberdctl.template", "bin/ejabberdctl"},
           {copy, "../ejabberdctl.cfg.example", "conf/ejabberdctl.cfg"},
           {copy, "../ejabberd.yml.example", "conf/ejabberd.yml"},
           {copy, "../inetrc", "conf/inetrc"},
           {copy, "files/install_upgrade.escript", "bin/install_upgrade.escript"}
          ],

Config = [{sys, Sys},
          {overlay_vars, "../vars.config"},
          {target_dir, "ejabberd"},
          {overlay, Overlay}],

%%io:format("ejabberd release:~n  ~p~n", [Config]),
Config.

%% Local Variables:
%% mode: erlang
%% End:
%% vim: set filetype=erlang tabstop=8: