2ade9c496d9af2d0b13eb3226b0912aab29fa119
[sip-router] / pkg / ser / gentoo / sip-router-3.1.4.ebuild
1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 inherit eutils flag-o-matic toolchain-funcs multilib
6
7 DESCRIPTION="Sip-Router (Kamailio/SER) is an Open Source SIP Server"
8 HOMEPAGE="http://sip-router.org/"
9 MY_P="${P/sip-router/kamailio}"
10 MY_PN="${PN/-/}"
11 SRC_URI="http://www.kamailio.org/pub/kamailio/${PV}/src/${MY_P}_src.tar.gz"
12 S=${WORKDIR}/${MY_P}
13
14 SLOT="0"
15 LICENSE="GPL-2"
16 KEYWORDS="~amd64 ~x86"
17
18 #Documentation can be found here: http://www.kamailio.org/docs/modules/3.1.x/
19 IUSE="flavour_kamailio flavour_ser debug ipv6 sctp
20 group_standard group_standard_dep group_mysql group_radius group_postgres group_presence group_stable group_experimental
21 acc acc_radius alias_db app_lua app_python auth auth_identity auth_db auth_diameter auth_radius avpops
22 benchmark blst
23 call_control carrierroute cfg_db cfg_rpc cfgutils counters cpl-c ctl
24 db_berkeley db_flatstore db_mysql db_oracle db_postgres db_text db_unixodbc
25 debugger dialog dialplan dispatcher diversion domain domainpolicy drouting
26 enum exec
27 geoip group
28 h350 htable imc iptrtpproxy jabber kex
29 lcr ldap
30 matrix maxfwd mediaproxy memcached misc_radius mi_datagram mi_fifo mi_rpc mi_xmlrpc mqueue msilo mtree
31 nathelper nat_traversal
32 osp
33 path pdb pdt peering perl perlvdb permissions pike pipelimit prefix_route
34 presence presence_conference presence_dialoginfo presence_mwi presence_xml
35 pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp purple pv
36 qos
37 ratelimit regex registrar rls rtimer rr rtpproxy
38 sanity seas siptrace siputils sl sms snmpstats speeddial sqlops statistics sst
39 textops textopsx tls tm tmx topoh
40 uac uac_redirect uri_db userblacklist usrloc utils
41 xcap_client xcap_server xhttp xlog xmlops xmlrpc xmpp"
42
43 #osp? ( net-libs/osptoolkit )
44 #pdb? ( pdb-server )
45 #seas? ( www.wesip.eu )
46
47 RDEPEND="
48         >=sys-libs/ncurses-5.7
49         >=sys-libs/readline-6.1_p2
50         group_mysql? ( >=dev-db/mysql-5.1.50 sys-libs/zlib )
51         group_radius? ( >=net-dialup/radiusclient-ng-0.5.0 )
52         group_presence? ( dev-libs/libxml2 net-misc/curl )
53         group_postgres? ( dev-db/postgresql-base )
54         group_standard? ( dev-libs/libxml2 dev-libs/openssl net-misc/curl )
55         acc_radius? ( net-dialup/radiusclient-ng )
56         app_lua? ( dev-lang/lua )
57         app_python? ( dev-lang/python )
58         auth_identity? ( dev-libs/openssl net-misc/curl )
59         carrierroute? ( dev-libs/confuse )
60         cpl-c? ( dev-libs/libxml2 )
61         db_berkeley? ( >=sys-libs/db-4.6 )
62         db_mysql? ( >=dev-db/mysql-5.1.50 )
63         db_oracle? ( dev-db/oracle-instantclient-basic )
64         db_postgres? ( dev-db/postgresql-base )
65         db_unixodbc? ( dev-db/unixODBC )
66         dialplan? ( dev-libs/libpcre )
67         geoip? ( dev-libs/geoip )
68         h350? ( net-nds/openldap )
69         jabber? ( dev-libs/expat )
70         lcr? ( dev-libs/libpcre )
71         ldap? ( net-nds/openldap )
72         memcached? ( dev-libs/libmemcache net-misc/memcached )
73         mi_xmlrpc? ( dev-libs/libxml2 dev-libs/xmlrpc-c )
74         peering? ( net-dialup/radiusclient-ng )
75         perl? ( dev-lang/perl dev-perl/perl-ldap )
76         presence? ( dev-libs/libxml2 )
77         presence_conference? ( dev-libs/libxml2 )
78         presence_xml? ( dev-libs/libxml2 )
79         pua? ( dev-libs/libxml2 )
80         pua_bla? ( dev-libs/libxml2 )
81         pua_dialoginfo? ( dev-libs/libxml2 )
82         pua_usrloc? ( dev-libs/libxml2 )
83         pua_xmpp? ( dev-libs/libxml2 )
84         purple? ( net-im/pidgin )
85         regex? ( dev-libs/libpcre )
86         rls? ( dev-libs/libxml2 )
87         snmpstats? ( net-analyzer/net-snmp sys-apps/lm_sensors )
88         tls? (
89                 sys-libs/zlib
90                 >=dev-libs/openssl-1.0.0a-r1
91         )
92         utils? ( net-misc/curl )
93         xcap_client? ( dev-libs/libxml2 net-misc/curl )
94         xcap_server? ( dev-libs/libxml2 )
95         xmlops? ( dev-libs/libxml2 )
96         xmpp? ( dev-libs/expat )
97 "
98 DEPEND="${RDEPEND}
99         >=sys-devel/bison-1.35
100         >=sys-devel/flex-2.5.4a
101         app-text/docbook2X"
102
103 src_unpack() {
104         unpack ${A}
105         cd "${S}"
106
107         use ipv6 || \
108                 sed -i -e "s/-DUSE_IPV6//g" Makefile.defs || die
109 }
110
111 src_compile() {
112         #iptrtpproxy broken as the needed netfilter module is not supported
113         #local mod_exc="iptrtpproxy"
114         local mod_exc=""
115         local group_inc=""
116         use group_standard && group_inc="${group_inc} standard"
117         use group_standard_dep && group_inc="${group_inc} standard_dep"
118         use group_mysql && group_inc="${group_inc} mysql"
119         use group_radius && group_inc="${group_inc} radius"
120         use group_postgres && group_inc="${group_inc} postgres"
121         use group_presence && group_inc="${group_inc} presence"
122         use group_stable && group_inc="${group_inc} stable"
123         use group_experimental && group_inc="${group_inc} experimental"
124         # TODO: add kamailio specific groups (kstandard, kradius, kxml, etc)
125         # TODO: skip_modules?
126
127         local mod_inc=""
128         # FIXME: some IUSE flags must not be included here in mod_inc
129         # e.g.: flavour_kamailio, flavour_ser, debug, sctp, ipv6
130         for i in ${IUSE[@]}; do
131                 for j in ${i[@]}; do
132                         [[ ! "${i}" =~ "flavour_" ]] && \
133                                 [ ! "${i}" == "debug" ] && \
134                                 [ ! "${i}" == "ipv6" ] && \
135                                 [ ! "${i}" == "sctp" ] && \
136                                 [[ ! "${i}" =~ "group_" ]] && \
137                         use "${i}" && mod_inc="${mod_inc} ${i}"
138                 done
139         done
140
141         if use tls; then
142                 tls_hooks=1
143         else
144                 tls_hooks=0
145         fi
146
147         if use debug; then
148                 mode=debug
149         else
150                 mode=release
151         fi
152
153         if use flavour_kamailio; then
154                 flavour=kamailio
155         elif use flavour_ser; then
156                 flavour=ser # SER compatibility names
157         else
158                 flavour=sip-router # defaults: Siprouter compatibility names
159         fi
160
161         if use sctp; then
162                 sctp=1
163         else
164                 sctp=0
165         fi
166
167         emake \
168                 CC="$(tc-getCC)" \
169                 CPU_TYPE="$(get-flag march)" \
170                 SCTP="${sctp}" \
171                 CC_EXTRA_OPTS=-I/usr/gnu/include \
172                 mode="${mode}" \
173                 TLS_HOOKS="${tls_hooks}" \
174                 FLAVOUR="${flavour}" \
175                 group_include="${group_inc}" \
176                 include_modules="${mod_inc}" \
177                 exclude_modules="${mod_exc}" \
178                 prefix="/" \
179                 all || die "emake all failed"
180 }
181
182 src_install() {
183         emake -j1 \
184                 BASEDIR="${D}" \
185                 FLAVOUR="${flavour}" \
186                 prefix="/" \
187                 bin_dir=/usr/sbin/ \
188                 cfg_dir=/etc/${MY_PN}/ \
189                 lib_dir=/usr/$(get_libdir)/${MY_PN}/ \
190                 modules_dir="/usr/$(get_libdir)/${MY_PN}/" \
191                 man_dir="/usr/share/man/" \
192                 doc_dir="/usr/share/doc/${P}/" \
193                 install || die "emake install failed"
194
195         [ "${flavour}" == "sip-router" ] || \
196                 sed -e "s/siprouter/${flavour}/g" \
197                         ${FILESDIR}/${MY_PN}.init > ${flavour}.init || die
198
199         newinitd "${flavour}".init "${flavour}"
200         newconfd "${FILESDIR}/${MY_PN}".confd "${flavour}"
201
202
203 }
204
205 pkg_preinst() {
206         if [[ -z "$(egetent passwd ${MY_PN})" ]]; then
207                 einfo "Adding ${MY_PN} user and group"
208                 enewgroup "${MY_PN}"
209                 enewuser  "${MY_PN}" -1 -1 /dev/null "${MY_PN}"
210         fi
211
212         chown -R root:"${MY_PN}"  "${D}/etc/${MY_PN}"
213         chmod -R u=rwX,g=rX,o= "${D}/etc/${MY_PN}"
214
215         has_version "${CATEGORY}/ser"
216         previous_installed_version=$?
217 }
218
219 pkg_postinst() {
220         if [[ $previous_installed_version = 1 ]] ; then
221                 einfo "You have a previous version of SER on ${ROOT}etc/ser"
222                 einfo "Consider or verify to remove it"
223                 einfo
224                 einfo "Now you've installed Sip-Router ON ${ROOT}etc/${MY_PN}"
225         fi
226         if [ use mediaproxy ]; then
227                 echo "You have enabled mediaproxy support. In order to use it, you have
228                 to run it somewhere."
229         fi
230         if [ use rtpproxy ]; then
231                 "You have enabled rtpproxy support. In order to use it, you have to run
232                 it somewhere."
233         fi
234 }
235
236 pkg_prerm () {
237         /etc/init.d/"${MY_PN}" stop >/dev/null
238 }