Tue, 29 Nov 2011 18:44:37 +0100
Reduce private memory allocation after observing stable operation.
1 ##
2 ## opensips.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2008 OpenPKG Foundation e.V. <http://openpkg.net/>
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 options
25 %define V_major 1.6.4
26 %define V_minor 2
27 %define V_rtpproxy 1.2.1
29 # package information
30 Name: opensips
31 Summary: Open SIP Router
32 URL: http://www.opensips.org/
33 Vendor: Voice System SRL
34 Packager: OpenPKG Foundation e.V.
35 Distribution: OpenPKG Community
36 Class: PLUS
37 Group: VoIP
38 License: GPL
39 Version: %{V_major}.%{V_minor}
40 Release: 20111128
42 # package options
43 %option with_cons yes
44 %option with_fsl yes
45 %option with_ssl yes
46 %option with_sctp no
47 %option with_json no
48 %option with_croute no
49 %option with_ldap no
50 %option with_memcached no
51 %option with_radius no
52 %option with_snmp no
53 %option with_bdb no
54 %option with_mysql no
55 %option with_osp no
56 %option with_pgsql no
57 %option with_odbc no
58 %option with_geoip no
59 %option with_dbgmem no
61 # list of sources
62 Source0: http://www.opensips.org/pub/opensips/%{V_major}/src/opensips-%{V_major}-%{V_minor}-tls_src.tar.gz
63 Source1: http://www.b2bua.org/chrome/site/rtpproxy-%{V_rtpproxy}.tar.gz
64 Source2: rc.opensips
65 Source3: fsl.opensips
66 Source4: opensips.cfg
67 Patch0: opensips.patch
68 Patch1: opensips.patch.dict
69 Patch2: opensips.patch.uac
70 Patch3: opensips.patch.lcr
71 Patch4: opensips.patch.reg
72 Patch5: opensips.patch.rtpproxy
74 # build information
75 Prefix: %{l_prefix}
76 BuildRoot: %{l_buildroot}
77 BuildPreReq: OpenPKG, openpkg >= 20060823, make, gcc, flex, bison, sed
78 PreReq: OpenPKG, openpkg >= 20060823, bash
79 BuildPreReq: libxml, expat, curl, pkgconfig
80 PreReq: libxml, expat, curl
81 %if "%{with_cons}" == "yes"
82 PreReq: perl-dbi, perl-term
83 %endif
84 %if "%{with_fsl}" == "yes"
85 BuildPreReq: fsl
86 PreReq: fsl
87 %endif
88 %if "%{with_ssl}" == "yes"
89 BuildPreReq: openssl
90 PreReq: openssl
91 %endif
92 %if "%{with_croute}" == "yes"
93 BuildPreReq: confuse
94 PreReq: confuse
95 %endif
96 %if "%{with_json}" == "yes"
97 BuildPreReq: json
98 PreReq: json
99 %endif
100 %if "%{with_ldap}" == "yes"
101 BuildPreReq: openldap
102 PreReq: openldap
103 %endif
104 %if "%{with_memcached}" == "yes"
105 BuildPreReq: memcached
106 PreReq: memcached
107 %endif
108 %if "%{with_osp}" == "yes"
109 BuildPreReq: osptoolkit
110 PreReq: osptoolkit
111 %endif
112 %if "%{with_radius}" == "yes"
113 BuildPreReq: radiusclient
114 PreReq: radiusclient
115 %endif
116 %if "%{with_snmp}" == "yes"
117 BuildPreReq: snmp
118 PreReq: snmp
119 %endif
120 %if "%{with_bdb}" == "yes"
121 BuildPreReq: db
122 PreReq: db
123 %endif
124 %if "%{with_mysql}" == "yes"
125 BuildPreReq: mysql
126 PreReq: mysql
127 %endif
128 %if "%{with_pgsql}" == "yes"
129 BuildPreReq: postgresql
130 PreReq: postgresql
131 %endif
132 %if "%{with_odbc}" == "yes"
133 BuildPreReq: unixodbc
134 PreReq: unixodbc
135 %endif
136 %if "%{with_geoip}" == "yes"
137 BuildPreReq: geoip
138 PreReq: geoip
139 %endif
140 AutoReq: no
141 AutoReqProv: no
143 %description
144 OpenSIPS is (beside Kamailio) a successor to OpenSER, which in
145 turn was spawned from FhG FOKUS's SIP Express Router (SER). It
146 provides SIP (RFC3621) registrar, proxy and routing functionality.
147 A C shell like scripting language provides for control over the
148 server's behaviour. It's modular architecture allows for fine
149 grained loading of required functionality.
151 The third party Sippy RTPproxy from http://www.rtpproxy.org/
152 is included to make communication between SIP user agents
153 behind NATs (Network Address Translators) possible.
155 OpenSIPS can be used as a: OpenSIPS fits in scenarios:
157 Registrar server SIP trunking
158 Router, proxy SIP load balancing
159 Redirect server SIP front end termination
160 Presence agent Residential providers
161 Back to back user agent white label solutions
162 Instant messaging server Enterprise services
163 SIP to SMS gateway LCR for multi gateways
164 SIP to XMPP gateway
165 Load balancer or dispatcher
166 Front end for asterisk
167 NAT traversal unit
168 Application server
170 %track
171 prog opensips = {
172 version = %{V_major}-%{V_minor}
173 url = http://www.opensips.org/pub/opensips/
174 regex = (\d+\.\d+\.\d+)/
175 url = http://www.opensips.org/pub/opensips/__NEWVER__/src/
176 regex = opensips-(__VER__)-tls_src\.tar\.gz
177 }
178 prog opensips:rtpproxy = {
179 version = %{V_rtpproxy}
180 url = http://www.rtpproxy.org/
181 regex = rtpproxy-(\d+(?:\.\d+)+)\.tar\.gz
182 }
184 %prep
185 %setup -q -n opensips-%{V_major}-%{V_minor}-tls
186 %setup -q -n opensips-%{V_major}-%{V_minor}-tls -T -D -a 1
187 %patch -p0
188 %patch -p0 -P 1
189 %patch -p0 -P 2
190 %patch -p0 -P 3
191 %patch -p0 -P 4
192 ( cd rtpproxy-%{V_rtpproxy}
193 %patch -p0 -P 5
194 ) || exit $?
195 %{l_shtool} subst \
196 -e 's;^#! */bin/sh;#! %{l_prefix}/bin/bash;' \
197 scripts/opensipsctl
198 %{l_shtool} subst \
199 -e 's;^#! */bin/bash;#! %{l_prefix}/bin/bash;' \
200 modules/seas/doc/xml2sgml.sh \
201 scripts/opensipsdbctl \
202 test/*
203 %{l_shtool} subst \
204 %if "%{with_dbgmem}" == "yes"
205 -e 's;\(-DF_MALLOC\);#\1;' \
206 -e 's;#\(-DDBG_QM_MALLOC\);\1;' \
207 %endif
208 -e 's;\(#define PKG_MEM_POOL_SIZE\) \(1024\*1024\);\1 4*\2;' \
209 Makefile.defs \
210 config.h
211 %{l_shtool} subst \
212 %if "%{with_fsl}" == "yes"
213 -e 's;@fslldflags@;-L$(prefix)/lib;g' \
214 -e 's;@fsllibs@;-lfsl;g' \
215 %else
216 -e 's;@fslldflags@;;g' \
217 -e 's;@fsllibs@;;g' \
218 %endif
219 -e 's;^\(DEFS+= -I\)\$(LOCALBASE).*;\1$(prefix)/include;' \
220 -e 's;^\(DEFS+= -L\)\$(LOCALBASE).*;\1$(prefix)/lib -lssl -lcrypto;' \
221 -e 's;^SVNVERSION *=.*;;g' \
222 -e 's;^DBHTML2TXT *=.*;;g' \
223 -e 's;^DBXML2PDF *=.*;;g' \
224 -e 's;lib64;lib;' \
225 Makefile.defs
226 %{l_shtool} subst \
227 -e 's;\(radiusclient\)-ng;\1;g' \
228 modules/aaa_radius/aaa_radius.c \
229 modules/aaa_radius/rad.c \
230 Makefile.defs
231 %{l_shtool} subst \
232 -e 's;\(\$(data-dir)\)/\(dbtext\)/opensips;\1/\2;g' \
233 -e 's;\(\$(data-dir)\)/\(db_berkeley\)/opensips;\1/\2;g' \
234 -e 's;\(/usr/local/etc/opensips\);\1/*;g' \
235 -e 's;\(s#/usr/local/sbin\)#;\1/*#;g' \
236 -e 's;\(s#/usr/share/doc/$(NAME)/#$(doc-target)\)#;\1/#;g' \
237 -e 's;\(\$(MAKE).*\) \(install_module_custom\);\1 makefile_defs=0 \2;' \
238 Makefile
239 %{l_shtool} subst \
240 -e 's;^\(LIBS=\).*;\1-L`%{l_prefix}/bin/pkg-config --libs db`;' \
241 utils/db_berkeley/Makefile
242 %{l_shtool} subst \
243 -e 's;/usr/share/doc/opensips/AUTHORS;%{l_prefix}/share/opensips/doc/AUTHORS;' \
244 scripts/opensipsctl.8
245 %{l_shtool} subst \
246 -e 's;\(ETCDIR=".*\)/"$;\1";' \
247 -e 's;\(ETCDIR="\)/usr/local/\(etc/opensips"\);\1%{l_prefix}/\2;' \
248 -e 's;\. /etc/opensips/opensipsctlrc;true;' \
249 -e 's;\. ~/.opensipsctlrc;true;' \
250 -e 's;/usr/local\(/lib/opensips/opensipsctl\);%{l_prefix}\1;' \
251 -e 's;/usr/local/\(etc/opensips/opensipsctlrc\);%{l_prefix}/\1;' \
252 -e 's;PATH=\$PATH:/usr/local/sbin;PATH=%{l_prefix}/sbin:$PATH;' \
253 scripts/opensipsdbctl \
254 scripts/opensipsctl
255 %{l_shtool} subst \
256 -e 's;\(DB_PATH="\)[^"][^"]*;\1%{l_prefix}/var/opensips/db;' \
257 scripts/osipsconsolerc \
258 scripts/opensipsctlrc
259 %{l_shtool} subst \
260 -e 's;/var/run/\(opensips.pid\);%{l_prefix}/var/opensips/\1;g' \
261 -e 's;\(my \$fifo_reply_path\) = "/tmp/";\1 = "%{l_prefix}/var/opensips/";' \
262 -e 's;\(my \$HISTORY_FILE\) = "/tmp/osipsconsole_history";\1 = "%{l_prefix}/var/opensips/osipsconsole_history";' \
263 scripts/opensipsctl \
264 scripts/opensipsctlrc \
265 scripts/osipsconsole \
266 scripts/osipsconsolerc
267 %{l_shtool} subst \
268 -e 's;/usr/local;;g' \
269 -e 's;\(/etc/opensips/\)\.\(opensipsctlrc\);%{l_prefix}\1\2;g' \
270 scripts/opensipsctl.8
271 %{l_shtool} subst \
272 -e 's;/var/run/\(opensips.pid\);%{l_prefix}/var/opensips/\1;' \
273 scripts/opensipsctl.base
274 %{l_shtool} subst \
275 -e 's;\(path=\)\$CHROOT_DIR/tmp/\(\$name\);\1${OSER_FIRET}/\2;g' \
276 scripts/opensipsctl.fifo
277 %{l_shtool} subst \
278 -e 's;/usr/local/share/opensips/dbtext/opensips;%{l_prefix}/var/opensips/db;' \
279 scripts/opensipsctl.dbtext
280 %{l_shtool} subst \
281 -e 's;\(DB_PATH="\)[^"][^"]*;%{l_prefix}/var/opensips/db_berkeley;' \
282 scripts/opensipsctl.db_berkeley
283 %{l_shtool} subst \
284 -e 's;PATH=\$PATH:/usr/local/sbin;PATH=%{l_prefix}/sbin:$PATH;' \
285 scripts/opensipsctl \
286 scripts/opensipsdbctl.base
287 %{l_shtool} subst \
288 -e 's;/usr/local/etc/opensips/dbtext;%{l_prefix}/var/opensips/db;' \
289 -e 's;\(\$DATA_DIR/dbtext\)/opensips;\1;g' \
290 scripts/opensipsdbctl.dbtext
291 %{l_shtool} subst \
292 -e 's;\(DATA_DIR="\)[^"][^"]*;\1%{l_prefix}/share/opensips;' \
293 scripts/opensipsdbctl.dbtext \
294 scripts/opensipsdbctl.oracle
295 %{l_shtool} subst \
296 -e 's;/usr/local/etc/opensips/db_berkeley;%{l_prefix}/var/opensips/db_berkeley;' \
297 -e 's;/usr/local/BerkeleyDB.[^/][^/]*/bin;%{l_prefix}/bin;' \
298 scripts/opensipsdbctl.db_berkeley
299 %{l_shtool} subst \
300 -e 's;/usr/local/\(share/opensips\);%{l_prefix}/\1;' \
301 scripts/opensipsdbctl.db_berkeley \
302 scripts/opensipsdbctl.mysql \
303 scripts/opensipsdbctl.pgsql
304 %{l_shtool} subst \
305 -e 's;\(script_flags(int\));\1,null);' \
306 scripts/dbtext/opensips/dialog
307 %{l_shtool} subst \
308 -e 's;\(gw_name(string).*\) *$;\1 user(string,null) realm(string,null) passwd(string,null);' \
309 scripts/dbtext/opensips/gw
310 %{l_shtool} subst \
311 -e 's;body(string);body(blob);' \
312 -e 's;sender(string);sender(string,null);' \
313 scripts/dbtext/opensips/presentity
314 %{l_shtool} subst \
315 -e 's;\(expires(int\));\1,null);' \
316 -e 's;\(desired_expires(int\));\1,null);' \
317 -e 's;\(contact(string\));\1,null);' \
318 -e 's;\(remote_contact(string\));\1,null);' \
319 -e 's;\(version(int\));\1,null);' \
320 -e 's;\(extra_headers(string\));\1,null);' \
321 scripts/dbtext/opensips/pua
322 %{l_shtool} subst \
323 -e 's;\(reason(string\));\1,null);' \
324 scripts/dbtext/opensips/active_watchers \
325 scripts/dbtext/opensips/rls_watchers
326 %{l_shtool} subst \
327 -e 's;#! */usr/bin/python;#! %{l_prefix}/bin/python;' \
328 scripts/dbtextdb/*.py
329 %{l_shtool} subst \
330 -e 's;#! */usr/bin/perl;#! %{l_prefix}/bin/perl;' \
331 -e 's;^\(my \$PATH_BIN =\) "./";\1 "%{l_prefix}/bin/";' \
332 -e 's;^\(my \$PATH_CTLRC =\) "./scripts/";\1 "%{l_prefix}/etc/opensips/";' \
333 -e 's;^\(my \$PATH_ETC =\) "/usr/local/etc";\1 "%{l_prefix}/etc";' \
334 -e 's;^\(my \$PATH_LIBS =\) "/usr/local/lib";\1 "%{l_prefix}/lib";' \
335 -e 's;^\(my \$PATH_SHARE =\) "/usr/local/share";\1 "%{l_prefix}/share";' \
336 -e 's;^\(my $path = \)"/tmp/";\1"%{l_prefix}/var/opensips/";' \
337 scripts/osipsconsole
338 %{l_shtool} subst \
339 -e 's;if ( -x "/usr/bin/";if ( -x "%{l_prefix}/bin";' \
340 -e 's;if \[ -x "/usr/bin/\$1" \];if [ -x "%{l_prefix}/bin/$1" ];' \
341 -e 's;\$TOOLPATH = "/usr/bin/";$TOOLPATH = "%{l_prefix}/bin/";' \
342 -e 's;TOOLPATH="/usr/bin/\$1";TOOLPATH="%{l_prefix}/bin/$1";' \
343 -e 's;if ( -x "/bin/";if ( -x "/usr/bin/";' \
344 -e 's;if \[ -x "/bin/\$1" \];if [ -x "/usr/bin/$1" ];' \
345 -e 's;\$TOOLPATH = "/bin/";$TOOLPATH = "/usr/bin/";' \
346 -e 's;TOOLPATH="/bin/\$1";TOOLPATH="/usr/bin/$1";' \
347 -e 's;if ( -x "/usr/local/bin/\$1";if ( -x "/bin/$1";' \
348 -e 's;if \[ -x "/usr/local/bin/\$1" \];if [ -x "/bin/$1" ];' \
349 -e 's;\$TOOLPATH = "/usr/local/bin/;$TOOLPATH = "/bin/;' \
350 -e 's;TOOLPATH="/usr/local/bin/\$1";TOOLPATH="/bin/$1";' \
351 scripts/osipsconsole \
352 scripts/opensipsctl.base
353 %{l_shtool} subst \
354 -e 's;^\(DEFS+=\).*\\$;\1 \\;' \
355 -e "s;\-I[^ \t][^ \t]*;`%{l_prefix}/bin/pkg-config --cflags-only-I libcurl libxml-2.0`;g" \
356 -e "s;^\(LIBS=\).*;\1`%{l_prefix}/bin/pkg-config --libs libcurl libxml-2.0`;" \
357 modules/xcap_client/Makefile
358 %{l_shtool} subst \
359 -e 's;^\(DEFS+=\).*\\$;\1 \\;' \
360 -e "s;\-I[^ \t][^ \t]*;`%{l_prefix}/bin/pkg-config --cflags-only-I libxml-2.0`;g" \
361 -e "s;^\(LIBS=\).*;\1`%{l_prefix}/bin/pkg-config --libs libxml-2.0`;" \
362 modules/cpl-c/Makefile \
363 modules/presence/Makefile \
364 modules/presence_dialoginfo/Makefile \
365 modules/presence_xml/Makefile \
366 modules/pua/Makefile \
367 modules/pua_bla/Makefile \
368 modules/pua_dialoginfo/Makefile \
369 modules/pua_mi/Makefile \
370 modules/pua_usrloc/Makefile \
371 modules/pua_xmpp/Makefile \
372 modules/b2b_logic/Makefile \
373 modules/rls/Makefile
374 %{l_shtool} subst \
375 -e 's;^\(DEFS+=\).*;\1`%{l_prefix}/bin/pkg-config --cflags-only-I libconfuse`;' \
376 -e 's;^\(LIBS=\).*;\1`%{l_prefix}/bin/pkg-config --libs libconfuse`;' \
377 modules/carrierroute/Makefile
378 %{l_shtool} subst \
379 -e 's;\(LIBS = .*-L\$(shell pg_config --libdir) -lpq\);\1 $(shell pg_config --libs);' \
380 modules/db_postgres/Makefile
381 %{l_shtool} subst \
382 -e 's;-I\$(LOCALBASE)/BerkeleyDB[0-9\.\-]*/include[\t ]*;;' \
383 -e 's;-L\$(LOCALBASE)/BerkeleyDB[0-9\.\-]*/lib[\t ]*;;' \
384 modules/db_berkeley/Makefile \
385 utils/db_berkeley/Makefile
386 %{l_shtool} subst \
387 -e 's;\(\$(cfg-prefix)\)\$(shell net-snmp-config --prefix);\1;' \
388 modules/snmpstats/Makefile
389 %{l_shtool} subst \
390 -e 's;LM_WARN(\(\"uac does not spread across\);LM_NOTICE(\1;' \
391 modules/tm/uac.c
392 %{l_shtool} subst \
393 -e 's;\(#define MAX_SSL_RETRIES\) 32;\1 1024;' \
394 tls/tls_server.c
395 %{l_shtool} subst \
396 -e 's;^\(default_bits[ \t]*=[ \t]*\)2048;\14096;' \
397 etc/tls/ca.conf
398 %{l_shtool} subst \
399 -e '1,2d' \
400 etc/tls/README
401 %{l_shtool} subst \
402 -e 's;\(radiusclient\)-ng;\1;g' \
403 -e 's;/usr/local\(/etc/radiusclient/radiusclient.conf\);%{l_prefix}\1;' \
404 radius.h
406 %build
407 # select modules
408 modslist='b2b_entities b2b_logic cpl-c db_http dialplan identity jabber perl perlvdb presence presence_dialoginfo presence_mwi presence_xml pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp regex rls tlsops xcap_client xmpp'
409 %if "%{with_croute}" == "yes"
410 modslist="$modslist carrierroute"
411 %endif
412 %if "%{with_json}" == "yes"
413 modslist="$modslist json"
414 %endif
415 %if "%{with_ldap}" == "yes"
416 modslist="$modslist h350 ldap"
417 %endif
418 %if "%{with_memcached}" == "yes"
419 modslist="$modslist memcached"
420 %endif
421 %if "%{with_osp}" == "yes"
422 modslist="$modslist osp"
423 %endif
424 %if "%{with_radius}" == "yes"
425 modslist="$modslist aaa_radius auth_aaa group uri"
426 %endif
427 %if "%{with_snmp}" == "yes"
428 modslist="$modslist snmpstats"
429 %endif
430 %if "%{with_bdb}" == "yes"
431 modslist="$modslist db_berkeley"
432 %endif
433 %if "%{with_mysql}" == "yes"
434 modslist="$modslist db_mysql"
435 %endif
436 %if "%{with_pgsql}" == "yes"
437 modslist="$modslist db_postgres"
438 %endif
439 %if "%{with_odbc}" == "yes"
440 modslist="$modslist db_unixodbc"
441 %endif
442 %if "%{with_geoip}" == "yes"
443 modslist="$modslist mmgeoip"
444 %endif
446 # build dependencies
447 %{l_make} %{l_mflags} \
448 CC="%{l_cc}" \
449 %if "%{with_sctp}" == "yes"
450 SCTP=1 \
451 %endif
452 %if "%{with_ssl}" == "yes"
453 TLS=1 \
454 %endif
455 prefix=%{l_prefix} \
456 dep >/dev/null 2>&1 || true
458 # build program
459 %{l_make} %{l_mflags -O} \
460 CC="%{l_cc}" \
461 %if "%{with_sctp}" == "yes"
462 SCTP=1 \
463 %endif
464 %if "%{with_ssl}" == "yes"
465 TLS=1 \
466 %endif
467 prefix=%{l_prefix} \
468 opensips
470 # build utilities
471 %{l_make} %{l_mflags -O} \
472 CC="%{l_cc}" \
473 %if "%{with_sctp}" == "yes"
474 SCTP=1 \
475 %endif
476 %if "%{with_ssl}" == "yes"
477 TLS=1 \
478 %endif
479 prefix=%{l_prefix} \
480 modules="$modslist" \
481 utils
483 # build modules
484 %{l_make} %{l_mflags} \
485 CC="%{l_cc}" \
486 %if "%{with_sctp}" == "yes"
487 SCTP=1 \
488 %endif
489 %if "%{with_ssl}" == "yes"
490 TLS=1 \
491 %endif
492 include_modules="$modslist" \
493 skip_modules="" \
494 prefix=%{l_prefix} \
495 modules
497 # build rtpproxy extension
498 ( cd rtpproxy-%{V_rtpproxy}
499 export CC="%{l_cc}"
500 export CFLAGS="%{l_cflags -O}"
501 export LIBS=""
502 case "%{l_platform -t}" in
503 *-sunos* ) LIBS="$LIBS -lsocket -lnsl -lrt" ;;
504 esac
505 export GREP="grep"
506 ./configure
507 %{l_make} %{l_mflags -O}
508 ) || exit $?
510 %install
511 rm -rf $RPM_BUILD_ROOT
513 # select modules
514 modslist='b2b_entities b2b_logic cpl-c db_http dialplan identity jabber perl perlvdb presence presence_dialoginfo presence_mwi presence_xml pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp regex rls tlsops xcap_client xmpp'
515 %if "%{with_croute}" == "yes"
516 modslist="$modslist carrierroute"
517 %endif
518 %if "%{with_json}" == "yes"
519 modslist="$modslist json"
520 %endif
521 %if "%{with_ldap}" == "yes"
522 modslist="$modslist h350 ldap"
523 %endif
524 %if "%{with_memcached}" == "yes"
525 modslist="$modslist memcached"
526 %endif
527 %if "%{with_osp}" == "yes"
528 modslist="$modslist osp"
529 %endif
530 %if "%{with_radius}" == "yes"
531 modslist="$modslist aaa_radius auth_aaa group uri"
532 %endif
533 %if "%{with_snmp}" == "yes"
534 modslist="$modslist snmpstats"
535 %endif
536 %if "%{with_bdb}" == "yes"
537 modslist="$modslist db_berkeley"
538 %endif
539 %if "%{with_mysql}" == "yes"
540 modslist="$modslist db_mysql"
541 %endif
542 %if "%{with_pgsql}" == "yes"
543 modslist="$modslist db_postgres"
544 %endif
545 %if "%{with_odbc}" == "yes"
546 modslist="$modslist db_unixodbc"
547 %endif
548 %if "%{with_geoip}" == "yes"
549 modslist="$modslist mmgeoip"
550 %endif
552 # install program, utils, and modules
553 %{l_make} %{l_mflags} \
554 INSTALL="%{l_shtool} install%{l_nil} -c" \
555 basedir=$RPM_BUILD_ROOT \
556 prefix=%{l_prefix} \
557 doc-dir=share/opensips/doc \
558 man-dir=man \
559 data-dir=share/opensips \
560 include_modules="$modslist" \
561 skip_modules="" \
562 install
564 # install rtpproxy software
565 %{l_shtool} install -c -s -m 755 \
566 rtpproxy-%{V_rtpproxy}/rtpproxy \
567 $RPM_BUILD_ROOT%{l_prefix}/sbin/rtpproxy
569 # strip down installation
570 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
572 # create installation hierarchy
573 %{l_shtool} mkdir -f -p -m 700 \
574 $RPM_BUILD_ROOT%{l_prefix}/var/opensips/acc \
575 $RPM_BUILD_ROOT%{l_prefix}/var/opensips/tmp
577 # install default configuration
578 %{l_shtool} mkdir -f -p -m 755 \
579 $RPM_BUILD_ROOT%{l_prefix}/etc/opensips
580 %{l_shtool} install -c -m 644 %{l_value -s -a} \
581 %{SOURCE opensips.cfg} \
582 %{SOURCE opensipsctlrc} \
583 $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/
585 # conditionally install osipsconsole resources
586 %if "%{with_cons}" == "yes"
587 %{l_shtool} install -c -m 644 %{l_value -s -a} \
588 %{SOURCE osipsconsolerc} \
589 $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/
590 %else
591 rm $RPM_BUILD_ROOT%{l_prefix}/sbin/osipsconsole
592 %endif
594 # install OSSP fsl configuration
595 %{l_shtool} mkdir -f -p -m 755 \
596 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
597 %{l_shtool} install -c -m 644 %{l_value -s -a} \
598 %{SOURCE fsl.opensips} \
599 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
601 # install runcommand script
602 %{l_shtool} mkdir -f -p -m 755 \
603 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
604 %{l_shtool} install -c -m 755 %{l_value -s -a} \
605 %{SOURCE rc.opensips} \
606 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
608 # determine installation files
609 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
610 %{l_files_std} \
611 '%not %dir %{l_prefix}/etc/fsl' \
612 '%config %{l_prefix}/etc/fsl/*' \
613 '%config %{l_prefix}/etc/opensips/*' \
614 '%doc %{l_prefix}/share/opensips/doc/*' \
615 '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/opensips'
617 %files -f files
619 %clean
620 rm -rf $RPM_BUILD_ROOT
622 %post
623 # on install, setup database (osipsconsole db create /pfx/var/opensips/db)
624 if [ ! -d $RPM_INSTALL_PREFIX/var/opensips/db ]; then
625 %{l_shtool} mkdir -f -p -m 700 -o %{l_rusr} -g %{l_rgrp} \
626 $RPM_INSTALL_PREFIX/var/opensips/db
627 rm -f $RPM_INSTALL_PREFIX/share/opensips/dbtext/*.orig
628 %{l_shtool} install -c -m 600 -o %{l_rusr} -g %{l_rgrp} \
629 $RPM_INSTALL_PREFIX/share/opensips/dbtext/* \
630 $RPM_INSTALL_PREFIX/var/opensips/db/
631 fi
633 # after upgrade, restart service
634 [ $1 -eq 2 ] || exit 0
635 eval `%{l_rc} opensips status 2>/dev/null`
636 [ ".$opensips_active" = .yes ] && %{l_rc} opensips restart
637 exit 0
639 %preun
640 # before erase, stop service and remove log files
641 [ $1 -eq 0 ] || exit 0
642 %{l_rc} opensips stop 2>/dev/null
643 rm -rf $RPM_INSTALL_PREFIX/var/opensips/db 2>/dev/null || true
644 rm -f $RPM_INSTALL_PREFIX/var/opensips/* 2>/dev/null || true
645 exit 0