summaryrefslogtreecommitdiff
path: root/net-im
diff options
context:
space:
mode:
authorChristian Faulhammer <fauli@gentoo.org>2009-06-03 06:07:20 +0000
committerChristian Faulhammer <fauli@gentoo.org>2009-06-03 06:07:20 +0000
commitf93759e61790dadb926a45564ec426157e7d46bb (patch)
tree27b60c051693792da09c12df9539277963d214d7 /net-im
parentRequire newer sandbox #258684. (diff)
downloadhistorical-f93759e61790dadb926a45564ec426157e7d46bb.tar.gz
historical-f93759e61790dadb926a45564ec426157e7d46bb.tar.bz2
historical-f93759e61790dadb926a45564ec426157e7d46bb.zip
revision bump to fix runtime failures with Erlang 13, as reported and fixed by Karl-Johan Karlsson <creideiki+gentoo-bugzilla AT lysator DOT liu DOT se> in bug 267524
Package-Manager: portage-2.1.6.11/cvs/Linux i686
Diffstat (limited to 'net-im')
-rw-r--r--net-im/ejabberd/ChangeLog10
-rw-r--r--net-im/ejabberd/Manifest14
-rw-r--r--net-im/ejabberd/ejabberd-2.0.5-r3.ebuild159
-rw-r--r--net-im/ejabberd/files/ejabberd-2.0.5-erlang-13.patch361
4 files changed, 542 insertions, 2 deletions
diff --git a/net-im/ejabberd/ChangeLog b/net-im/ejabberd/ChangeLog
index 85c05e3c8956..b071b738e5a4 100644
--- a/net-im/ejabberd/ChangeLog
+++ b/net-im/ejabberd/ChangeLog
@@ -1,6 +1,14 @@
# ChangeLog for net-im/ejabberd
# Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-im/ejabberd/ChangeLog,v 1.62 2009/05/20 22:42:16 caleb Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-im/ejabberd/ChangeLog,v 1.63 2009/06/03 06:07:17 fauli Exp $
+
+*ejabberd-2.0.5-r3 (03 Jun 2009)
+
+ 03 Jun 2009; Christian Faulhammer <fauli@gentoo.org>
+ +files/ejabberd-2.0.5-erlang-13.patch, +ejabberd-2.0.5-r3.ebuild:
+ revision bump to fix runtime failures with Erlang 13, as reported and fixed
+ by Karl-Johan Karlsson <creideiki+gentoo-bugzilla AT lysator DOT liu DOT se>
+ in bug 267524
20 May 2009; Caleb Tennis <caleb@gentoo.org> ejabberd-2.0.4.ebuild:
Add erlang 13 dep to the stable build as well
diff --git a/net-im/ejabberd/Manifest b/net-im/ejabberd/Manifest
index 20963e5f8bf9..dc2b89ed60fe 100644
--- a/net-im/ejabberd/Manifest
+++ b/net-im/ejabberd/Manifest
@@ -1,3 +1,6 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
AUX 1.1.4-missing-declaration.patch 411 RMD160 f314900dd00fd23c9043cb5a60982448c39d2fa9 SHA1 687066247c9ad74c4e9ec869a9f4f0d9e80bae6d SHA256 1c32a57f4f187d55b28b240820875fcd3e731f6d91cd9429d14c318222f07e7b
AUX 2.0.0-ejab-542-mod_proxy65.patch 598 RMD160 bfe11518b5dbfcfb64c7bb04be965d2e383c2d90 SHA1 9161450bf883209f4c2ff2c061f94ef401e4fa51 SHA256 80ce546763de423430efcb60376ff2fda1fcd15ab7b80003ef5d7380a1a4caa3
AUX 2.0.0-erlang12-s2s-in.patch 1164 RMD160 5bcb04354c02749cdec302dc30354a49872ef2f5 SHA1 c27402b062b58ecf74c9e8c0cf2e879dbe600656 SHA256 ebc66c2a507e39f7f794b32f91148ea5e8c34e46ad41b4b876983da4aa9c1342
@@ -8,6 +11,7 @@ AUX ejabberd-1.1.4-erlang-12.patch 3746 RMD160 17e6dc9ded6f598c27cf2cda098d2804e
AUX ejabberd-1.1.4.confd 736 RMD160 100b2b7957766380b0267d6fc91b3fe8a0f827fc SHA1 7c7283615eddafe24f7d331b76b598ad3f10699c SHA256 8c3f96ebaa0bf200ef145dbc6ebea82451cfaceec9ff7802fdc0ef48bf507715
AUX ejabberd-1.1.4.initd 1437 RMD160 96d9d35de36585a9e735f124b7be1618949541aa SHA1 623713cfb28a247f16a14f6b2ca6a8555609bd35 SHA256 59f983e32f7b530b66b5242ac6f06405b7440a112b2f980abe602508459d923e
AUX ejabberd-2.0.4-fix-EJAB-890.patch 5259 RMD160 72fe6630ab6ca84b90a4947b95ac24b689a86bd7 SHA1 ab61f5335177a4344a61830e39ada84f6688f2b4 SHA256 be38a6a278f3ad4da3fd9dfd56623a271677d8897cf4fd04b31994ed5d6f7959
+AUX ejabberd-2.0.5-erlang-13.patch 16877 RMD160 4b8924f5b37de85823dec539523e7800c394bc7c SHA1 663ffc03f29613d695589c199222bc0382a24c76 SHA256 3d5cb7c163647580e1776a4e31ca3f8e03b1b411288b8273c861d17db5fa1e4a
AUX ejabberd-2.confd 834 RMD160 7beb5337d15b33d4b1d802edb03995cddb73e162 SHA1 53e754dcbd03edb27f9982f51323e355dafd1f73 SHA256 c48f5cb90c409bde333d5d7a6159995bbf02e265c9d06528c1ec35b764ca9f21
AUX ejabberd-2.initd 1126 RMD160 8c696768e686efdc9865446ce5a3fbb2ae7302f6 SHA1 27c6b2fd8e1ff6b74d83688d9d68e8721aa0580e SHA256 9b6f076c452a8db149b689db12082fade95e1975a76e52a67a942220ee99aa2f
AUX ejabberd-wrapper-2.template 1243 RMD160 989700850578dd86fe6cefeb465a1c84ba49df48 SHA1 115d10f04dd92ca090e853013dde3e5ffa3d6904 SHA256 1d3abfbb1b4dd79ba9fed74a5c86c97af70dc11927d8fa109a1486999d5f7a96
@@ -25,5 +29,13 @@ EBUILD ejabberd-1.1.4-r1.ebuild 3456 RMD160 2f1ad83dd3d4773dd10de489f71939bb3b35
EBUILD ejabberd-1.1.4-r2.ebuild 3479 RMD160 d6bfed9a9127bc8246d315b16c184bf7a94bccde SHA1 b2815db38d8d76d7697d82505f8bdf9cb7401195 SHA256 9898cff52c3d8948bddb16dcb5392c2a7cd8eafb48c69e9b5e6d74884023575d
EBUILD ejabberd-2.0.4.ebuild 4837 RMD160 c10c9cbbada5b2ea1248f3a71303f69e9b01c582 SHA1 326bc8da6365817e6de94aaf77a1941b79e769e1 SHA256 63d967db168f8ab4f9593267a0c78948349ca0b9d31b67ef2c7c65a240c92b50
EBUILD ejabberd-2.0.5-r2.ebuild 4791 RMD160 ab86cf43e37f45a24e50d29804176d4daf8f77af SHA1 81c55701cf8f32e1afabc34a2b3877168bc900fb SHA256 361fcfaa8ef40f34619fd63f616bbedbdc9da958cd6c31dbb99b69fde232f6fb
-MISC ChangeLog 13294 RMD160 9cc79620d96538b010217a31c084394d7b0fcdb8 SHA1 aac00174fb5fe7823eef900cffb8b54c3a62d5af SHA256 561d4eb6a6799bf3228e16ca47450379c1f65592a0c5d003e166f83987957687
+EBUILD ejabberd-2.0.5-r3.ebuild 4891 RMD160 1469f0ea5a5e9faa1ae8416f4bfdb0c4ef495256 SHA1 324a8119752aef53fc703e9996975b0c86fa69a0 SHA256 a76c52ef35d946febfa2b8e899369de9a8a6cf87ae74c126fc7a4a881a964e44
+MISC ChangeLog 13625 RMD160 20eeb1bc9e3205c0b3aea25d8c48c924b98bd41f SHA1 2894cc8234a9424066752682f1143602ef4a46a8 SHA256 b026260edbd8915da3bf8800058f87e20b66ac3861967e25c7bde9e445df76d7
MISC metadata.xml 619 RMD160 ca6e7f018d370ce36a3b93eb960254537260949c SHA1 404f3d0d31036ed1cfeb8aeee2264559c1d1c8d9 SHA256 843e1bbd5fdc082763e71322094170cde5b90d0f5d9320011c4b9872cd6589f4
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v2.0.11 (GNU/Linux)
+
+iEYEARECAAYFAkomEzUACgkQNQqtfCuFneOO8QCbB9PtWCRw/B3iZpJkxIKfaFet
+IZYAn3EafrurzX0mrmeiVGIfpUvkPUTz
+=m890
+-----END PGP SIGNATURE-----
diff --git a/net-im/ejabberd/ejabberd-2.0.5-r3.ebuild b/net-im/ejabberd/ejabberd-2.0.5-r3.ebuild
new file mode 100644
index 000000000000..3936141be7a8
--- /dev/null
+++ b/net-im/ejabberd/ejabberd-2.0.5-r3.ebuild
@@ -0,0 +1,159 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-im/ejabberd/ejabberd-2.0.5-r3.ebuild,v 1.1 2009/06/03 06:07:17 fauli Exp $
+
+inherit eutils multilib
+
+JABBER_ETC="/etc/jabber"
+JABBER_RUN="/var/run/jabber"
+JABBER_SPOOL="/var/spool/jabber"
+JABBER_LOG="/var/log/jabber"
+
+MY_PV=${PV}
+MY_P=${PN}-${MY_PV}
+
+DESCRIPTION="The Erlang Jabber Daemon"
+HOMEPAGE="http://www.ejabberd.im/"
+SRC_URI="http://www.process-one.net/downloads/ejabberd/${PV}/${MY_P}.tar.gz"
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~ppc ~x86"
+IUSE="debug mod_irc mod_muc mod_pubsub ldap odbc pam ssl web zlib"
+
+DEPEND=">=net-im/jabber-base-0.01
+ >=dev-libs/expat-1.95
+ >=dev-lang/erlang-11.2.5
+ odbc? ( dev-db/unixODBC )
+ ldap? ( =net-nds/openldap-2* )
+ ssl? ( >=dev-libs/openssl-0.9.8e )
+ zlib? ( sys-libs/zlib )"
+RDEPEND="${DEPEND}"
+
+PROVIDE="virtual/jabber-server"
+
+S=${WORKDIR}/${MY_P}/src
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+
+ # make ejabberd working with erlang-13
+ rm ram_file_io_server.erl
+ epatch "${FILESDIR}/ejabberd-2.0.5-erlang-13.patch"
+
+ # get rid of the prefix
+ sed -i -e "s/\\@prefix\\@//" "${S}/Makefile.in" \
+ || die "cannot sed Makefile.in"
+ # we want ejabberdctl in /usr/sbin not /sbin !!!
+ sed -i -e "s/\\/sbin/\\/usr\\/sbin/" "${S}/Makefile.in" \
+ || die "cannot sed Makefile.in"
+}
+
+src_compile() {
+ econf --prefix=/ \
+ $(use_enable mod_irc) \
+ $(use_enable ldap eldap) \
+ $(use_enable mod_muc) \
+ $(use_enable mod_pubsub) \
+ $(use_enable ssl tls) \
+ $(use_enable web) \
+ $(use_enable odbc) \
+ $(use_enable zlib ejabberd_zlib) \
+ $(use_enable pam) \
+ || die "econf failed"
+
+ if useq debug; then
+ emake ejabberd_debug=true || die "compiling ejabberd core failed"
+ else
+ emake || die "compiling ejabberd core failed"
+ fi
+}
+
+src_install() {
+ make \
+ DESTDIR="${D}" \
+ EJABBERDDIR="${D}/usr/$(get_libdir)/erlang/lib/${P}" \
+ ETCDIR="${D}${JABBER_ETC}" \
+ LOGDIR="${D}${JABBER_LOG}" \
+ install || die "install failed"
+
+ # remove the default ejabberdctl as we use our own
+ rm "${D}/sbin/ejabberdctl"
+
+ insinto ${JABBER_ETC}
+
+ fowners -R jabber:jabber ${JABBER_ETC}
+ fowners -R jabber:jabber ${JABBER_LOG}
+ fowners -R jabber:jabber /usr/$(get_libdir)/erlang/lib/${P}
+
+ if useq ssl; then
+ doins "${FILESDIR}/ssl.cnf"
+ newins "${FILESDIR}/self-cert-v2.sh" self-cert.sh
+ fi
+
+ # Pam helper module permissions
+ # http://www.process-one.net/docs/ejabberd/guide_en.html
+ if useq pam; then
+ fowners root:jabber /usr/$(get_libdir)/erlang/lib/${P}/priv/bin/epam
+ fperms 4750 /usr/$(get_libdir)/erlang/lib/${P}/priv/bin/epam
+ fi
+
+ cd "${WORKDIR}/${MY_P}/doc"
+ dodoc "release_notes_${MY_PV}.txt"
+ dohtml *.{html,png}
+
+ # set up /usr/sbin/ejabberd wrapper
+ cat "${FILESDIR}/ejabberd-wrapper-2.template" \
+ | sed -e "s/\@libdir\@/$(get_libdir)/g" -e "s/\@version\@/${PV}/g" \
+ > "${T}/ejabberd"
+ exeinto /usr/sbin
+ doexe "${T}/ejabberd" || die
+
+ # set up /usr/sbin/ejabberdctl wrapper
+ cat "${FILESDIR}/ejabberdctl-wrapper-3.template" \
+ | sed -e "s:\@libdir\@:$(get_libdir):g" -e "s:\@version\@:${PV}:g" \
+ > "${T}/ejabberdctl"
+ doexe "${T}/ejabberdctl"
+
+ dodir /var/lib/ejabberd
+ newinitd "${FILESDIR}/${PN}-2.initd" ${PN} || die
+ newconfd "${FILESDIR}/${PN}-2.confd" ${PN} || die
+
+ # fix up the ssl cert paths in /etc/jabber/ejabberd.cfg to use the cert
+ # that would be generated by /etc/jabber/self-cert.sh
+ sed -i -e "s/\/path\/to\/ssl.pem/\/etc\/jabber\/ssl.pem/g" \
+ "${D}${JABBER_ETC}/ejabberd.cfg" || die "Cannot sed ejabberd.cfg"
+
+ # if mod_irc is not enabled, comment out the mod_irc in the default
+ # ejabberd.cfg
+ if ! use mod_irc; then
+ sed -i -e "s/{mod_irc,/%{mod_irc,/" \
+ "${D}${JABBER_ETC}/ejabberd.cfg" || die "Cannot sed ejabberd.cfg"
+ fi
+}
+
+pkg_postinst() {
+ elog "For configuration instructions, please see"
+ elog "/usr/share/doc/${PF}/html/guide.html, or the online version at"
+ elog "http://www.process-one.net/en/projects/ejabberd/docs/guide_en.html"
+ if useq ssl ; then
+ if [ ! -e /etc/jabber/ssl.pem ]; then
+ elog "Please edit ${JABBER_ETC}/ssl.cnf and run ${JABBER_ETC}/self-cert.sh"
+ elog "Ejabberd may refuse to start without an SSL certificate"
+ fi
+ fi
+ if ! useq web ; then
+ elog "The web USE flag is off, this has disabled the web admin interface."
+ fi
+ elog "===================================================================="
+ elog 'Quick Start Guide:'
+ elog '1) Add output of `hostname -f` to /etc/jabber/ejabberd.cfg line 89'
+ elog ' {hosts, ["localhost", "thehost"]}.'
+ elog '2) Add an admin user to /etc/jabber/ejabberd.cfg line 324'
+ elog ' {acl, admin, {user, "theadmin", "thehost"}}.'
+ elog '3) Start the server'
+ elog ' # /etc/init.d/ejabberd start'
+ elog '4) Register the admin user'
+ elog ' # /usr/sbin/ejabberdctl register theadmin thehost thepassword'
+ elog '5) Log in with your favourite jabber client or using the web admin'
+}
diff --git a/net-im/ejabberd/files/ejabberd-2.0.5-erlang-13.patch b/net-im/ejabberd/files/ejabberd-2.0.5-erlang-13.patch
new file mode 100644
index 000000000000..d52777ba3150
--- /dev/null
+++ b/net-im/ejabberd/files/ejabberd-2.0.5-erlang-13.patch
@@ -0,0 +1,361 @@
+diff --git a/src/dynamic_compile.erl b/src/dynamic_compile.erl
+new file mode 100644
+index 0000000..1fe2dca
+--- /dev/null
++++ dynamic_compile.erl
+@@ -0,0 +1,268 @@
++%% Copyright (c) 2007
++%% Mats Cronqvist <mats.cronqvist@ericsson.com>
++%% Chris Newcombe <chris.newcombe@gmail.com>
++%% Jacob Vorreuter <jacob.vorreuter@gmail.com>
++%%
++%% Permission is hereby granted, free of charge, to any person
++%% obtaining a copy of this software and associated documentation
++%% files (the "Software"), to deal in the Software without
++%% restriction, including without limitation the rights to use,
++%% copy, modify, merge, publish, distribute, sublicense, and/or sell
++%% copies of the Software, and to permit persons to whom the
++%% Software is furnished to do so, subject to the following
++%% conditions:
++%%
++%% The above copyright notice and this permission notice shall be
++%% included in all copies or substantial portions of the Software.
++%%
++%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++%% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++%% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++%% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++%% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++%% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++%% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++%% OTHER DEALINGS IN THE SOFTWARE.
++
++%%%-------------------------------------------------------------------
++%%% File : dynamic_compile.erl
++%%% Description :
++%%% Authors : Mats Cronqvist <mats.cronqvist@ericsson.com>
++%%% Chris Newcombe <chris.newcombe@gmail.com>
++%%% Jacob Vorreuter <jacob.vorreuter@gmail.com>
++%%% TODO :
++%%% - add support for limit include-file depth (and prevent circular references)
++%%% prevent circular macro expansion set FILE correctly when -module() is found
++%%% -include_lib support $ENVVAR in include filenames
++%%% substitute-stringize (??MACRO)
++%%% -undef/-ifdef/-ifndef/-else/-endif
++%%% -file(File, Line)
++%%%-------------------------------------------------------------------
++-module(dynamic_compile).
++
++%% API
++-export([from_string/1, from_string/2]).
++
++-import(lists, [reverse/1, keyreplace/4]).
++
++%%====================================================================
++%% API
++%%====================================================================
++%%--------------------------------------------------------------------
++%% Function:
++%% Description:
++%% Returns a binary that can be used with
++%% code:load_binary(Module, ModuleFilenameForInternalRecords, Binary).
++%%--------------------------------------------------------------------
++from_string(CodeStr) ->
++ from_string(CodeStr, []).
++
++% takes Options as for compile:forms/2
++from_string(CodeStr, CompileFormsOptions) ->
++ %% Initialise the macro dictionary with the default predefined macros,
++ %% (adapted from epp.erl:predef_macros/1
++ Filename = "compiled_from_string",
++ %%Machine = list_to_atom(erlang:system_info(machine)),
++ Ms0 = dict:new(),
++ % Ms1 = dict:store('FILE', {[], "compiled_from_string"}, Ms0),
++ % Ms2 = dict:store('LINE', {[], 1}, Ms1), % actually we might add special code for this
++ % Ms3 = dict:store('MODULE', {[], undefined}, Ms2),
++ % Ms4 = dict:store('MODULE_STRING', {[], undefined}, Ms3),
++ % Ms5 = dict:store('MACHINE', {[], Machine}, Ms4),
++ % InitMD = dict:store(Machine, {[], true}, Ms5),
++ InitMD = Ms0,
++
++ %% From the docs for compile:forms:
++ %% When encountering an -include or -include_dir directive, the compiler searches for header files in the following directories:
++ %% 1. ".", the current working directory of the file server;
++ %% 2. the base name of the compiled file;
++ %% 3. the directories specified using the i option. The directory specified last is searched first.
++ %% In this case, #2 is meaningless.
++ IncludeSearchPath = ["." | reverse([Dir || {i, Dir} <- CompileFormsOptions])],
++ {RevForms, _OutMacroDict} = scan_and_parse(CodeStr, Filename, 1, [], InitMD, IncludeSearchPath),
++ Forms = reverse(RevForms),
++
++ %% note: 'binary' is forced as an implicit option, whether it is provided or not.
++ case compile:forms(Forms, CompileFormsOptions) of
++ {ok, ModuleName, CompiledCodeBinary} when is_binary(CompiledCodeBinary) ->
++ {ModuleName, CompiledCodeBinary};
++ {ok, ModuleName, CompiledCodeBinary, []} when is_binary(CompiledCodeBinary) -> % empty warnings list
++ {ModuleName, CompiledCodeBinary};
++ {ok, _ModuleName, _CompiledCodeBinary, Warnings} ->
++ throw({?MODULE, warnings, Warnings});
++ Other ->
++ throw({?MODULE, compile_forms, Other})
++ end.
++
++%%====================================================================
++%% Internal functions
++%%====================================================================
++%%% Code from Mats Cronqvist
++%%% See http://www.erlang.org/pipermail/erlang-questions/2007-March/025507.html
++%%%## 'scan_and_parse'
++%%%
++%%% basically we call the OTP scanner and parser (erl_scan and
++%%% erl_parse) line-by-line, but check each scanned line for (or
++%%% definitions of) macros before parsing.
++%% returns {ReverseForms, FinalMacroDict}
++scan_and_parse([], _CurrFilename, _CurrLine, RevForms, MacroDict, _IncludeSearchPath) ->
++ {RevForms, MacroDict};
++
++scan_and_parse(RemainingText, CurrFilename, CurrLine, RevForms, MacroDict, IncludeSearchPath) ->
++ case scanner(RemainingText, CurrLine, MacroDict) of
++ {tokens, NLine, NRemainingText, Toks} ->
++ {ok, Form} = erl_parse:parse_form(Toks),
++ scan_and_parse(NRemainingText, CurrFilename, NLine, [Form | RevForms], MacroDict, IncludeSearchPath);
++ {macro, NLine, NRemainingText, NMacroDict} ->
++ scan_and_parse(NRemainingText, CurrFilename, NLine, RevForms,NMacroDict, IncludeSearchPath);
++ {include, NLine, NRemainingText, IncludeFilename} ->
++ IncludeFileRemainingTextents = read_include_file(IncludeFilename, IncludeSearchPath),
++ %%io:format("include file ~p contents: ~n~p~nRemainingText = ~p~n", [IncludeFilename,IncludeFileRemainingTextents, RemainingText]),
++ %% Modify the FILE macro to reflect the filename
++ %%IncludeMacroDict = dict:store('FILE', {[],IncludeFilename}, MacroDict),
++ IncludeMacroDict = MacroDict,
++
++ %% Process the header file (inc. any nested header files)
++ {RevIncludeForms, IncludedMacroDict} = scan_and_parse(IncludeFileRemainingTextents, IncludeFilename, 1, [], IncludeMacroDict, IncludeSearchPath),
++ %io:format("include file results = ~p~n", [R]),
++ %% Restore the FILE macro in the NEW MacroDict (so we keep any macros defined in the header file)
++ %%NMacroDict = dict:store('FILE', {[],CurrFilename}, IncludedMacroDict),
++ NMacroDict = IncludedMacroDict,
++
++ %% Continue with the original file
++ scan_and_parse(NRemainingText, CurrFilename, NLine, RevIncludeForms ++ RevForms, NMacroDict, IncludeSearchPath);
++ done ->
++ scan_and_parse([], CurrFilename, CurrLine, RevForms, MacroDict, IncludeSearchPath)
++ end.
++
++scanner(Text, Line, MacroDict) ->
++ case erl_scan:tokens([],Text,Line) of
++ {done, {ok,Toks,NLine}, LeftOverChars} ->
++ case pre_proc(Toks, MacroDict) of
++ {tokens, NToks} -> {tokens, NLine, LeftOverChars, NToks};
++ {macro, NMacroDict} -> {macro, NLine, LeftOverChars, NMacroDict};
++ {include, Filename} -> {include, NLine, LeftOverChars, Filename}
++ end;
++ {more, _Continuation} ->
++ %% This is supposed to mean "term is not yet complete" (i.e. a '.' has
++ %% not been reached yet).
++ %% However, for some bizarre reason we also get this if there is a comment after the final '.' in a file.
++ %% So we check to see if Text only consists of comments.
++ case is_only_comments(Text) of
++ true ->
++ done;
++ false ->
++ throw({incomplete_term, Text, Line})
++ end
++ end.
++
++is_only_comments(Text) -> is_only_comments(Text, not_in_comment).
++
++is_only_comments([], _) -> true;
++is_only_comments([$ |T], not_in_comment) -> is_only_comments(T, not_in_comment); % skipping whitspace outside of comment
++is_only_comments([$\t |T], not_in_comment) -> is_only_comments(T, not_in_comment); % skipping whitspace outside of comment
++is_only_comments([$\n |T], not_in_comment) -> is_only_comments(T, not_in_comment); % skipping whitspace outside of comment
++is_only_comments([$% |T], not_in_comment) -> is_only_comments(T, in_comment); % found start of a comment
++is_only_comments(_, not_in_comment) -> false;
++% found any significant char NOT in a comment
++is_only_comments([$\n |T], in_comment) -> is_only_comments(T, not_in_comment); % found end of a comment
++is_only_comments([_ |T], in_comment) -> is_only_comments(T, in_comment). % skipping over in-comment chars
++
++%%%## 'pre-proc'
++%%%
++%%% have to implement a subset of the pre-processor, since epp insists
++%%% on running on a file.
++%%% only handles 2 cases;
++%% -define(MACRO, something).
++%% -define(MACRO(VAR1,VARN),{stuff,VAR1,more,stuff,VARN,extra,stuff}).
++pre_proc([{'-',_},{atom,_,define},{'(',_},{_,_,Name}|DefToks],MacroDict) ->
++ false = dict:is_key(Name, MacroDict),
++ case DefToks of
++ [{',',_} | Macro] ->
++ {macro, dict:store(Name, {[], macro_body_def(Macro, [])}, MacroDict)};
++ [{'(',_} | Macro] ->
++ {macro, dict:store(Name, macro_params_body_def(Macro, []), MacroDict)}
++ end;
++
++pre_proc([{'-',_}, {atom,_,include}, {'(',_}, {string,_,Filename}, {')',_}, {dot,_}], _MacroDict) ->
++ {include, Filename};
++
++pre_proc(Toks,MacroDict) ->
++ {tokens, subst_macros(Toks, MacroDict)}.
++
++macro_params_body_def([{')',_},{',',_} | Toks], RevParams) ->
++ {reverse(RevParams), macro_body_def(Toks, [])};
++macro_params_body_def([{var,_,Param} | Toks], RevParams) ->
++ macro_params_body_def(Toks, [Param | RevParams]);
++macro_params_body_def([{',',_}, {var,_,Param} | Toks], RevParams) ->
++ macro_params_body_def(Toks, [Param | RevParams]).
++
++macro_body_def([{')',_}, {dot,_}], RevMacroBodyToks) ->
++ reverse(RevMacroBodyToks);
++macro_body_def([Tok|Toks], RevMacroBodyToks) ->
++ macro_body_def(Toks, [Tok | RevMacroBodyToks]).
++
++subst_macros(Toks, MacroDict) ->
++ reverse(subst_macros_rev(Toks, MacroDict, [])).
++
++%% returns a reversed list of tokes
++subst_macros_rev([{'?',_}, {_,LineNum,'LINE'} | Toks], MacroDict, RevOutToks) ->
++ %% special-case for ?LINE, to avoid creating a new MacroDict for every line in the source file
++ subst_macros_rev(Toks, MacroDict, [{integer,LineNum,LineNum}] ++ RevOutToks);
++
++subst_macros_rev([{'?',_}, {_,_,Name}, {'(',_} = Paren | Toks], MacroDict, RevOutToks) ->
++ case dict:fetch(Name, MacroDict) of
++ {[], MacroValue} ->
++ %% This macro does not have any vars, so ignore the fact that the invocation is followed by "(...stuff"
++ %% Recursively expand any macro calls inside this macro's value
++ %% TODO: avoid infinite expansion due to circular references (even indirect ones)
++ RevExpandedOtherMacrosToks = subst_macros_rev(MacroValue, MacroDict, []),
++ subst_macros_rev([Paren|Toks], MacroDict, RevExpandedOtherMacrosToks ++ RevOutToks);
++ ParamsAndBody ->
++ %% This macro does have vars.
++ %% Collect all of the passe arguments, in an ordered list
++ {NToks, Arguments} = subst_macros_get_args(Toks, []),
++ %% Expand the varibles
++ ExpandedParamsToks = subst_macros_subst_args_for_vars(ParamsAndBody, Arguments),
++ %% Recursively expand any macro calls inside this macro's value
++ %% TODO: avoid infinite expansion due to circular references (even indirect ones)
++ RevExpandedOtherMacrosToks = subst_macros_rev(ExpandedParamsToks, MacroDict, []),
++ subst_macros_rev(NToks, MacroDict, RevExpandedOtherMacrosToks ++ RevOutToks)
++ end;
++
++subst_macros_rev([{'?',_}, {_,_,Name} | Toks], MacroDict, RevOutToks) ->
++ %% This macro invocation does not have arguments.
++ %% Therefore the definition should not have parameters
++ {[], MacroValue} = dict:fetch(Name, MacroDict),
++
++ %% Recursively expand any macro calls inside this macro's value
++ %% TODO: avoid infinite expansion due to circular references (even indirect ones)
++ RevExpandedOtherMacrosToks = subst_macros_rev(MacroValue, MacroDict, []),
++ subst_macros_rev(Toks, MacroDict, RevExpandedOtherMacrosToks ++ RevOutToks);
++
++subst_macros_rev([Tok|Toks], MacroDict, RevOutToks) ->
++subst_macros_rev(Toks, MacroDict, [Tok|RevOutToks]);
++subst_macros_rev([], _MacroDict, RevOutToks) -> RevOutToks.
++
++subst_macros_get_args([{')',_} | Toks], RevArgs) ->
++ {Toks, reverse(RevArgs)};
++subst_macros_get_args([{',',_}, {var,_,ArgName} | Toks], RevArgs) ->
++ subst_macros_get_args(Toks, [ArgName| RevArgs]);
++subst_macros_get_args([{var,_,ArgName} | Toks], RevArgs) ->
++ subst_macros_get_args(Toks, [ArgName | RevArgs]).
++
++subst_macros_subst_args_for_vars({[], BodyToks}, []) ->
++ BodyToks;
++subst_macros_subst_args_for_vars({[Param | Params], BodyToks}, [Arg|Args]) ->
++ NBodyToks = keyreplace(Param, 3, BodyToks, {var,1,Arg}),
++ subst_macros_subst_args_for_vars({Params, NBodyToks}, Args).
++
++read_include_file(Filename, IncludeSearchPath) ->
++ case file:path_open(IncludeSearchPath, Filename, [read, raw, binary]) of
++ {ok, IoDevice, FullName} ->
++ {ok, Data} = file:read(IoDevice, filelib:file_size(FullName)),
++ file:close(IoDevice),
++ binary_to_list(Data);
++ {error, Reason} ->
++ throw({failed_to_read_include_file, Reason, Filename, IncludeSearchPath})
++ end.
+\ No newline at end of file
+diff --git a/src/ejabberd.app b/src/ejabberd.app
+index 1ff41ec..7f0948f 100644
+--- ejabberd.app
++++ ejabberd.app
+@@ -115,7 +115,6 @@
+ nodetree_virtual,
+ p1_fsm,
+ p1_mnesia,
+- ram_file_io_server,
+ randoms,
+ sha,
+ shaper,
+diff --git a/src/ejabberd_loglevel.erl b/src/ejabberd_loglevel.erl
+index 3134d4d..2a34060 100644
+--- ejabberd_loglevel.erl
++++ ejabberd_loglevel.erl
+@@ -38,51 +38,30 @@
+ -define(LOGMODULE, "error_logger").
+
+ %% Error levels:
+-%% 0 -> No log
+-%% 1 -> Critical
+-%% 2 -> Error
+-%% 3 -> Warning
+-%% 4 -> Info
+-%% 5 -> Debug
++-define(LOG_LEVELS,[ {0, no_log, "No log"}
++ ,{1, critical, "Critical"}
++ ,{2, error, "Error"}
++ ,{3, warning, "Warning"}
++ ,{4, info, "Info"}
++ ,{5, debug, "Debug"}
++ ]).
++
++set(LogLevel) when is_atom(LogLevel) ->
++ set(level_to_integer(LogLevel));
+ set(Loglevel) when is_integer(Loglevel) ->
+- Forms = compile_string(?LOGMODULE, ejabberd_logger_src(Loglevel)),
+- load_logger(Forms, ?LOGMODULE, Loglevel);
++ try
++ {Mod,Code} = dynamic_compile:from_string(ejabberd_logger_src(Loglevel)),
++ code:load_binary(Mod, ?LOGMODULE ++ ".erl", Code)
++ catch
++ Type:Error -> ?CRITICAL_MSG("Error compiling logger (~p): ~p~n", [Type, Error])
++ end;
+ set(_) ->
+ exit("Loglevel must be an integer").
+-
+-%% --------------------------------------------------------------
+-%% Compile a string into a module and returns the binary
+-compile_string(Mod, Str) ->
+- Fname = Mod ++ ".erl",
+- {ok, Fd} = open_ram_file(Fname),
+- file:write(Fd, Str),
+- file:position(Fd, 0),
+- case epp_dodger:parse(Fd) of
+- {ok, Tree} ->
+- Forms = revert_tree(Tree),
+- close_ram_file(Fd),
+- Forms;
+- Error ->
+- close_ram_file(Fd),
+- Error
+- end.
+-
+-open_ram_file(Fname) ->
+- ram_file_io_server:start(self(), Fname, [read,write]).
+-
+-close_ram_file(Fd) ->
+- file:close(Fd).
+-
+-revert_tree(Tree) ->
+- [erl_syntax:revert(T) || T <- Tree].
+
+-load_logger(Forms, Mod, Loglevel) ->
+- Fname = Mod ++ ".erl",
+- case compile:forms(Forms, [binary, {d,'LOGLEVEL',Loglevel}]) of
+- {ok, M, Bin} ->
+- code:load_binary(M, Fname, Bin);
+- Error ->
+- ?CRITICAL_MSG("Error ~p~n", [Error])
++level_to_integer(Level) ->
++ case lists:keyfind(Level, 2, ?LOG_LEVELS) of
++ {Int, Level, _Desc} -> Int;
++ _ -> erlang:error({no_such_loglevel, Level})
+ end.