Fri, 07 Oct 2011 16:33:56 +0200
Correct redundantly copied source.
1 ##
2 ## kamailio.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2011 Michael Schloh von Bennewitz <michael@schloh.com>
4 ##
5 ## Permission to use, copy, modify, and distribute this software for
6 ## any purpose with or without fee is hereby granted, provided that
7 ## the above copyright notice and this permission notice appear in all
8 ## copies.
9 ##
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21 ## SUCH DAMAGE.
22 ##
24 # package information
25 Name: kamailio
26 Summary: Open Source SIP Server
27 URL: http://www.kamailio.org/
28 Vendor: IPTelorg GmbH, Fraunhofer FOKUS, SIP Router Project
29 Packager: Michael Schloh von Bennewitz
30 Distribution: Europalab Networks Production
31 Class: PLUS
32 Group: VoIP
33 License: GPL
34 Version: 3.1.5
35 Release: 20111000
37 # package options
38 %option with_cons yes
39 %option with_fsl yes
40 %option with_ssl yes
41 %option with_sctp no
42 %option with_croute no
43 %option with_ldap no
44 %option with_memcached no
45 %option with_radius no
46 %option with_snmp no
47 %option with_bdb no
48 %option with_mysql no
49 %option with_osp no
50 %option with_pgsql no
51 %option with_odbc no
52 %option with_geoip no
53 %option with_lua no
54 %option with_python no
56 # list of sources
57 Source0: http://www.kamailio.org/pub/kamailio/%{version}/src/kamailio-%{version}_src.tar.gz
58 Source2: rc.kamailio
59 Source3: fsl.kamailio
61 # build information
62 Prefix: %{l_prefix}
63 BuildRoot: %{l_buildroot}
64 BuildPreReq: OpenPKG, openpkg >= 20060823
65 PreReq: OpenPKG, openpkg >= 20060823
66 BuildPreReq: libxml, expat, curl, readline
67 PreReq: libxml, expat, curl, readline
68 BuildPreReq: make, gcc, flex, bison, sed, pkgconfig
69 PreReq: bash
70 %if "%{with_cons}" == "yes"
71 PreReq: perl-dbi, perl-term
72 %endif
73 %if "%{with_fsl}" == "yes"
74 BuildPreReq: fsl
75 PreReq: fsl
76 %endif
77 %if "%{with_ssl}" == "yes"
78 BuildPreReq: openssl
79 PreReq: openssl
80 %endif
81 %if "%{with_croute}" == "yes"
82 BuildPreReq: confuse
83 PreReq: confuse
84 %endif
85 %if "%{with_ldap}" == "yes"
86 BuildPreReq: openldap
87 PreReq: openldap
88 %endif
89 %if "%{with_memcached}" == "yes"
90 BuildPreReq: memcached
91 PreReq: memcached
92 %endif
93 %if "%{with_osp}" == "yes"
94 BuildPreReq: osptoolkit
95 PreReq: osptoolkit
96 %endif
97 %if "%{with_radius}" == "yes"
98 BuildPreReq: radiusclient
99 PreReq: radiusclient
100 %endif
101 %if "%{with_snmp}" == "yes"
102 BuildPreReq: snmp
103 PreReq: snmp
104 %endif
105 %if "%{with_bdb}" == "yes"
106 BuildPreReq: db
107 PreReq: db
108 %endif
109 %if "%{with_mysql}" == "yes"
110 BuildPreReq: mysql
111 PreReq: mysql
112 %endif
113 %if "%{with_pgsql}" == "yes"
114 BuildPreReq: postgresql
115 PreReq: postgresql
116 %endif
117 %if "%{with_odbc}" == "yes"
118 BuildPreReq: unixodbc
119 PreReq: unixodbc
120 %endif
121 %if "%{with_geoip}" == "yes"
122 BuildPreReq: geoip
123 PreReq: geoip
124 %endif
125 %if "%{with_lua}" == "yes"
126 BuildPreReq: lua
127 PreReq: lua
128 %endif
129 %if "%{with_python}" == "yes"
130 BuildPreReq: python
131 PreReq: python
132 %endif
133 AutoReq: no
134 AutoReqProv: no
136 %description
137 Kamailio is (beside Opensips) a successor to OpenSER, which in
138 turn was spawned from FhG FOKUS's SIP Express Router (SER). It
139 provides SIP (RFC3621) registrar, proxy and routing functionality.
140 A C shell like scripting language provides for control over the
141 server's behaviour. It's modular architecture allows for fine
142 grained loading of required functionality.
144 Kamailio can be used as a: Kamailio fits in scenarios:
146 Registrar server SIP trunking
147 Router, proxy SIP load balancing
148 Redirect server SIP front end termination
149 Presence agent Residential providers
150 Back to back user agent white label solutions
151 Instant messaging server Enterprise services
152 SIP to SMS gateway LCR for multi gateways
153 SIP to XMPP gateway
154 Load balancer or dispatcher
155 Front end for asterisk
156 NAT traversal unit
157 Application server
159 %track
160 prog kamailio = {
161 version = %{version}
162 url = http://www.kamailio.org/pub/kamailio/
163 regex = (\d+\.\d+\.\d+)/
164 url = http://www.kamailio.org/pub/kamailio/__NEWVER__/src/
165 regex = kamailio-(__VER__)_src\.tar\.gz
166 }
168 %prep
169 %setup -q
170 %{l_shtool} subst \
171 -e 's;\$(LOCALBASE)/[^/][^/]*/sctp.h;;g' \
172 -e 's;\$(LOCALBASE)/ssl/include;`%{l_prefix}/bin/pkg-config --cflags-only-I openssl`;g' \
173 -e 's;\$(LOCALBASE)/ssl/lib;`%{l_prefix}/bin/pkg-config --libs openssl`;g' \
174 -e 's;\(data_dir\) *= *\(\$(MAIN_NAME)\);\1 = share/\2;g' \
175 -e 's;LOCALBASE *[\?:]*=.*;LOCALBASE = %{l_prefix};g' \
176 Makefile.defs
177 %{l_shtool} subst \
178 -e 's;CFLAGS *= *$;CFLAGS = %{l_cflags -O};g' \
179 -e 's;LDFLAGS *= *$;LDFLAGS = %{l_ldflags};g' \
180 -e 's;C_INCLUDES *= *$;C_INCLUDES = %{l_cppflags};g' \
181 Makefile.defs
182 %{l_shtool} subst \
183 -e 's;/usr/include/readline/readline.h;;g' \
184 utils/sercmd/Makefile
185 %{l_shtool} subst \
186 -e 's;-I$(LOCALBASE)/Berkeley[^ ]* *;;g' \
187 -e 's;-I$(LOCALBASE)/include[^ ]* *;;g' \
188 -e 's;-I$(SYSBASE)/include[^ ]* *;;g' \
189 -e 's;LIBS=.*;LIBS=`%{l_prefix}/bin/pkg-config --libs db`;g' \
190 utils/db_berkeley/Makefile
191 %{l_shtool} subst \
192 -e 's;\(mkdir.*\$(data_prefix)/\$(data_dir)/.*\)/kamailio;\1;g' \
193 utils/kamctl/Makefile
194 %{l_shtool} subst \
195 -e 's;\(radiusclient\)-ng;\1;g' \
196 -e 's;/usr/local\(/etc/radiusclient/radiusclient.conf\);%{l_prefix}\1;' \
197 Makefile.radius \
198 lib/kcore/radius.h \
199 modules_s/avp_radius/avp_radius.c \
200 modules_s/uri_radius/checks.c \
201 modules_s/uri_radius/urirad_mod.c \
202 modules_s/acc_radius/acc_radius.c \
203 modules_s/auth_radius/authrad_mod.c \
204 modules_s/auth_radius/sterman.h
205 %{l_shtool} subst \
206 -e 's;\(DEFS *[\?:+]*=[^\\]*\);\1 -D__EXTENSIONS__;g' \
207 modules/db_mysql/Makefile \
208 modules/xmlrpc/Makefile
209 %{l_shtool} subst \
210 -e 's;\(-keyout.*\);\1 || true;' \
211 modules/tls/sip-router_cert.sh
213 %build
214 # select modules
215 modslist='acc alias_db auth auth_identity avp avpops avp_db benchmark blst call_control cfgutils cfg_db cfg_rpc counters cpl-c ctl db_text db_flatstore db_ops debugger dialog dialplan dispatcher diversion domain domainpolicy drouting eval exec enum fifo gflags group htable identity imc kex lcr malloc_test mangler matrix maxfwd mi_datagram mi_fifo mi_rpc mediaproxy mqueue msilo mtree nathelper nat_traversal options path pdb pdt peering perl perlvdb permissions pike pipelimit prefix_route presence presence_conference presence_dialoginfo presence_mwi presence_xml privacy pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp pv qos ratelimit regex registrar rr rls rtimer rtpproxy sanity seas siptrace siputils sl sms speeddial sqlops sst statistics textops textopsx timer tm tmx topoh uac uac_redirect uri uri_db userblacklist usrloc utils xcap xcap_client xcap_server xhttp xlog xmlops xmlrpc xmpp'
216 %if "%{with_ssl}" == "yes"
217 modslist="$modslist tls"
218 %endif
219 %if "%{with_croute}" == "yes"
220 modslist="$modslist carrierroute"
221 %endif
222 %if "%{with_ldap}" == "yes"
223 modslist="$modslist ldap h350"
224 %endif
225 %if "%{with_memcached}" == "yes"
226 modslist="$modslist memcached"
227 %endif
228 %if "%{with_osp}" == "yes"
229 modslist="$modslist osp"
230 %endif
231 %if "%{with_radius}" == "yes"
232 modslist="$modslist acc_radius auth_radius avp_radius group misc_radius uri_radius"
233 %endif
234 %if "%{with_snmp}" == "yes"
235 modslist="$modslist snmpstats"
236 %endif
237 %if "%{with_bdb}" == "yes"
238 modslist="$modslist db_berkeley"
239 %endif
240 %if "%{with_mysql}" == "yes"
241 modslist="$modslist db_mysql"
242 %endif
243 %if "%{with_pgsql}" == "yes"
244 modslist="$modslist db_postgres"
245 %endif
246 %if "%{with_odbc}" == "yes"
247 modslist="$modslist db_unixodbc"
248 %endif
249 %if "%{with_lua}" == "yes"
250 modslist="$modslist app_lua"
251 %endif
252 %if "%{with_python}" == "yes"
253 modslist="$modslist app_python"
254 %endif
255 %if "%{with_geoip}" == "yes"
256 modslist="$modslist geoip"
257 %endif
259 # build configuration
260 %{l_make} %{l_mflags} \
261 CC="%{l_cc}" \
262 FLAVOUR=kamailio \
263 %if "%{with_sctp}" == "yes"
264 SCTP=1 \
265 %endif
266 %if "%{with_ssl}" == "yes"
267 TLS_HOOKS=1 \
268 %endif
269 prefix=%{l_prefix} \
270 cfg
272 # build program
273 %{l_make} %{l_mflags -O} \
274 CC="%{l_cc}" \
275 %if "%{with_sctp}" == "yes"
276 SCTP=1 \
277 %endif
278 %if "%{with_ssl}" == "yes"
279 TLS_HOOKS=1 \
280 %endif
281 prefix=%{l_prefix} \
282 kamailio
284 # build utilities
285 %{l_make} %{l_mflags -O} \
286 CC="%{l_cc}" \
287 %if "%{with_sctp}" == "yes"
288 SCTP=1 \
289 %endif
290 %if "%{with_ssl}" == "yes"
291 TLS_HOOKS=1 \
292 %endif
293 prefix=%{l_prefix} \
294 modules="$modslist" \
295 utils utils/kamctl
297 # build modules
298 %{l_make} %{l_mflags -O} \
299 CC="%{l_cc}" \
300 LD_RPATH=-Wl,-rpath, \
301 SER_RPATH_LST=%{l_prefix}/lib/kamailio \
302 %if "%{with_sctp}" == "yes"
303 SCTP=1 \
304 %endif
305 %if "%{with_ssl}" == "yes"
306 TLS_HOOKS=1 \
307 %endif
308 include_modules="$modslist" \
309 skip_modules="" \
310 prefix=%{l_prefix} \
311 every-module
313 %install
314 rm -rf $RPM_BUILD_ROOT
316 # select modules
317 modslist='acc alias_db auth auth_identity avp avpops avp_db benchmark blst call_control cfgutils cfg_db cfg_rpc counters cpl-c ctl db_text db_flatstore db_ops debugger dialog dialplan dispatcher diversion domain domainpolicy drouting eval exec enum fifo gflags group htable identity imc kex lcr malloc_test mangler matrix maxfwd mi_datagram mi_fifo mi_rpc mediaproxy mqueue msilo mtree nathelper nat_traversal options path pdb pdt peering perl perlvdb permissions pike pipelimit prefix_route presence presence_conference presence_dialoginfo presence_mwi presence_xml privacy pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp pv qos ratelimit regex registrar rr rls rtimer rtpproxy sanity seas siptrace siputils sl sms speeddial sqlops sst statistics textops textopsx timer tm tmx topoh uac uac_redirect uri uri_db userblacklist usrloc utils xcap xcap_client xcap_server xhttp xlog xmlops xmlrpc xmpp'
318 %if "%{with_ssl}" == "yes"
319 modslist="$modslist tls"
320 %endif
321 %if "%{with_croute}" == "yes"
322 modslist="$modslist carrierroute"
323 %endif
324 %if "%{with_ldap}" == "yes"
325 modslist="$modslist ldap h350"
326 %endif
327 %if "%{with_memcached}" == "yes"
328 modslist="$modslist memcached"
329 %endif
330 %if "%{with_osp}" == "yes"
331 modslist="$modslist osp"
332 %endif
333 %if "%{with_radius}" == "yes"
334 modslist="$modslist acc_radius auth_radius avp_radius group misc_radius uri_radius"
335 %endif
336 %if "%{with_snmp}" == "yes"
337 modslist="$modslist snmpstats"
338 %endif
339 %if "%{with_bdb}" == "yes"
340 modslist="$modslist db_berkeley"
341 %endif
342 %if "%{with_mysql}" == "yes"
343 modslist="$modslist db_mysql"
344 %endif
345 %if "%{with_pgsql}" == "yes"
346 modslist="$modslist db_postgres"
347 %endif
348 %if "%{with_odbc}" == "yes"
349 modslist="$modslist db_unixodbc"
350 %endif
351 %if "%{with_lua}" == "yes"
352 modslist="$modslist app_lua"
353 %endif
354 %if "%{with_python}" == "yes"
355 modslist="$modslist app_python"
356 %endif
357 %if "%{with_geoip}" == "yes"
358 modslist="$modslist geoip"
359 %endif
361 # install program, utils, and modules
362 %{l_make} %{l_mflags} \
363 INSTALL="%{l_shtool} install -c" \
364 INSTALL_CFG="%{l_shtool} install -c" \
365 INSTALL_BIN="%{l_shtool} install -c" \
366 INSTALL_SCRIPT="%{l_shtool} install -c" \
367 INSTALL_MODULES="%{l_shtool} install -c" \
368 INSTALL_LIB="%{l_shtool} install -c" \
369 INSTALL_DOC="%{l_shtool} install -c" \
370 INSTALL_MAN="%{l_shtool} install -c" \
371 INSTALL_SHARE="%{l_shtool} install -c" \
372 basedir=$RPM_BUILD_ROOT \
373 prefix=%{l_prefix} \
374 doc-dir=share/kamailio/doc \
375 man-dir=man \
376 data-dir=share/kamailio \
377 include_modules="$modslist" \
378 skip_modules="" \
379 install
381 # strip down installation
382 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
384 # create installation hierarchy
385 %{l_shtool} mkdir -f -p -m 700 \
386 $RPM_BUILD_ROOT%{l_prefix}/var/kamailio
388 # install OSSP fsl configuration
389 %{l_shtool} mkdir -f -p -m 755 \
390 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
391 %{l_shtool} install -c -m 644 %{l_value -s -a} \
392 %{SOURCE fsl.kamailio} \
393 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
395 # install runcommand script
396 %{l_shtool} mkdir -f -p -m 755 \
397 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
398 %{l_shtool} install -c -m 755 %{l_value -s -a} \
399 %{SOURCE rc.kamailio} \
400 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
402 # determine installation files
403 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
404 %{l_files_std} \
405 '%not %dir %{l_prefix}/etc/fsl' \
406 '%config %{l_prefix}/etc/fsl/*' \
407 '%config %{l_prefix}/etc/kamailio/*' \
408 '%doc %{l_prefix}/share/kamailio/doc/*' \
409 '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/kamailio'
411 %files -f files
413 %clean
414 rm -rf $RPM_BUILD_ROOT
416 %post
417 # on install, setup database (kamctl db create /pfx/var/kamailio/db)
418 if [ ! -d $RPM_INSTALL_PREFIX/var/kamailio/db ]; then
419 %{l_shtool} mkdir -f -p -m 700 -o %{l_rusr} -g %{l_rgrp} \
420 $RPM_INSTALL_PREFIX/var/kamailio/db
421 rm -f $RPM_INSTALL_PREFIX/share/kamailio/dbtext/*.orig
422 %{l_shtool} install -c -m 600 -o %{l_rusr} -g %{l_rgrp} \
423 $RPM_INSTALL_PREFIX/share/kamailio/dbtext/* \
424 $RPM_INSTALL_PREFIX/var/kamailio/db/
425 fi
427 # after upgrade, restart service
428 [ $1 -eq 2 ] || exit 0
429 eval `%{l_rc} kamailio status 2>/dev/null`
430 [ ".$kamailio_active" = .yes ] && %{l_rc} kamailio restart
431 exit 0
433 %preun
434 # before erase, stop service and remove log files
435 [ $1 -eq 0 ] || exit 0
436 %{l_rc} kamailio stop 2>/dev/null
437 rm -rf $RPM_INSTALL_PREFIX/var/kamailio/db 2>/dev/null || true
438 rm -f $RPM_INSTALL_PREFIX/var/kamailio/* 2>/dev/null || true
439 exit 0