aboutsummaryrefslogtreecommitdiff
path: root/rel
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2013-04-08 11:12:54 +0200
committerChristophe Romain <christophe.romain@process-one.net>2013-06-13 11:11:02 +0200
commit4d8f7706240a1603468968f47fc7b150b788d62f (patch)
tree92d55d789cc7ac979b3c9e161ffb7f908eba043a /rel
parentFix Guide: ejabberd_service expects a shaper_rule, not a shaper (diff)
Switch to rebar build tool
Use dynamic Rebar configuration Make iconv dependency optional Disable transient_supervisors compile option Add hipe compilation support Only compile ibrowse and lhttpc when needed Make it possible to generate an OTP application release Add --enable-debug compile option Add --enable-all compiler option Add --enable-tools configure option Add --with-erlang configure option. Add --enable-erlang-version-check configure option. Add lager support Improve the test suite
Diffstat (limited to 'rel')
-rwxr-xr-xrel/files/erl34
-rw-r--r--rel/files/install_upgrade.escript44
-rw-r--r--rel/reltool.config.script104
3 files changed, 182 insertions, 0 deletions
diff --git a/rel/files/erl b/rel/files/erl
new file mode 100755
index 000000000..6f65e3fc9
--- /dev/null
+++ b/rel/files/erl
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+## This script replaces the default "erl" in erts-VSN/bin. This is necessary
+## as escript depends on erl and in turn, erl depends on having access to a
+## bootscript (start.boot). Note that this script is ONLY invoked as a side-effect
+## of running escript -- the embedded node bypasses erl and uses erlexec directly
+## (as it should).
+##
+## Note that this script makes the assumption that there is a start_clean.boot
+## file available in $ROOTDIR/release/VSN.
+
+# Determine the abspath of where this script is executing from.
+ERTS_BIN_DIR=$(cd ${0%/*} && pwd)
+
+# Now determine the root directory -- this script runs from erts-VSN/bin,
+# so we simply need to strip off two dirs from the end of the ERTS_BIN_DIR
+# path.
+ROOTDIR=${ERTS_BIN_DIR%/*/*}
+
+# Parse out release and erts info
+START_ERL=`cat $ROOTDIR/releases/start_erl.data`
+ERTS_VSN=${START_ERL% *}
+APP_VSN=${START_ERL#* }
+
+BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
+EMU=beam
+PROGNAME=`echo $0 | sed 's/.*\\///'`
+CMD="$BINDIR/erlexec"
+export EMU
+export ROOTDIR
+export BINDIR
+export PROGNAME
+
+exec $CMD -boot $ROOTDIR/releases/$APP_VSN/start_clean ${1+"$@"}
diff --git a/rel/files/install_upgrade.escript b/rel/files/install_upgrade.escript
new file mode 100644
index 000000000..56cea1963
--- /dev/null
+++ b/rel/files/install_upgrade.escript
@@ -0,0 +1,44 @@
+#!/usr/bin/env escript
+%%! -noshell -noinput
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ft=erlang ts=4 sw=4 et
+
+-define(TIMEOUT, 60000).
+-define(INFO(Fmt,Args), io:format(Fmt,Args)).
+
+main([NodeName, Cookie, ReleasePackage]) ->
+ TargetNode = start_distribution(NodeName, Cookie),
+ {ok, Vsn} = rpc:call(TargetNode, release_handler, unpack_release,
+ [ReleasePackage], ?TIMEOUT),
+ ?INFO("Unpacked Release ~p~n", [Vsn]),
+ {ok, OtherVsn, Desc} = rpc:call(TargetNode, release_handler,
+ check_install_release, [Vsn], ?TIMEOUT),
+ {ok, OtherVsn, Desc} = rpc:call(TargetNode, release_handler,
+ install_release, [Vsn], ?TIMEOUT),
+ ?INFO("Installed Release ~p~n", [Vsn]),
+ ok = rpc:call(TargetNode, release_handler, make_permanent, [Vsn], ?TIMEOUT),
+ ?INFO("Made Release ~p Permanent~n", [Vsn]);
+main(_) ->
+ init:stop(1).
+
+start_distribution(NodeName, Cookie) ->
+ MyNode = make_script_node(NodeName),
+ {ok, _Pid} = net_kernel:start([MyNode, shortnames]),
+ erlang:set_cookie(node(), list_to_atom(Cookie)),
+ TargetNode = make_target_node(NodeName),
+ case {net_kernel:hidden_connect_node(TargetNode),
+ net_adm:ping(TargetNode)} of
+ {true, pong} ->
+ ok;
+ {_, pang} ->
+ io:format("Node ~p not responding to pings.\n", [TargetNode]),
+ init:stop(1)
+ end,
+ TargetNode.
+
+make_target_node(Node) ->
+ [_, Host] = string:tokens(atom_to_list(node()), "@"),
+ list_to_atom(lists:concat([Node, "@", Host])).
+
+make_script_node(Node) ->
+ list_to_atom(lists:concat([Node, "_upgrader_", os:getpid()])).
diff --git a/rel/reltool.config.script b/rel/reltool.config.script
new file mode 100644
index 000000000..a52df7b0a
--- /dev/null
+++ b/rel/reltool.config.script
@@ -0,0 +1,104 @@
+%%%-------------------------------------------------------------------
+%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
+%%% @copyright (C) 2013, Evgeniy Khramtsov
+%%% @doc
+%%%
+%%% @end
+%%% Created : 8 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
+%%%-------------------------------------------------------------------
+Vars = case file:consult(filename:join(["..", "vars.config"])) of
+ {ok, Terms} ->
+ Terms;
+ _Err ->
+ []
+ end,
+
+RequiredOTPApps = [sasl, crypto, public_key, ssl,
+ mnesia, inets, compiler],
+
+ConfiguredOTPApps = lists:flatmap(
+ fun({tools, true}) ->
+ [tools, runtime_tools];
+ (_) ->
+ []
+ end, Vars),
+
+OTPApps = RequiredOTPApps ++ ConfiguredOTPApps,
+
+DepRequiredApps = [p1_logger, p1_cache_tab, p1_tls, p1_stringprep, p1_xml, xmlrpc],
+
+DepConfiguredApps = lists:flatmap(
+ fun({mysql, true}) -> [p1_mysql];
+ ({pgsql, true}) -> [p1_pgsql];
+ ({pam, true}) -> [p1_pam];
+ ({zlib, true}) -> [p1_zlib];
+ ({stun, true}) -> [p1_stun];
+ ({json, true}) -> [jiffy];
+ ({iconv, true}) -> [p1_iconv];
+ ({http, true}) -> [ibrowse, lhttpc];
+ ({odbc, true}) -> [odbc];
+ (_) -> []
+ end, Vars),
+
+DepApps = DepRequiredApps ++ DepConfiguredApps,
+
+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, "var/log/ejabberd"},
+ {mkdir, "var/lock"},
+ {mkdir, "var/lib/ejabberd"},
+ {mkdir, "etc/ejabberd"},
+ {mkdir, "doc"},
+ {template, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
+ {template, "../ejabberdctl.template", "bin/ejabberdctl"},
+ {copy, "../ejabberdctl.cfg.example", "etc/ejabberd/ejabberdctl.cfg"},
+ {copy, "../ejabberd.cfg.example", "etc/ejabberd/ejabberd.cfg"},
+ {copy, "../inetrc", "etc/ejabberd/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: