1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/opensips/opensips.spec Wed Sep 21 14:02:13 2011 +0200 1.3 @@ -0,0 +1,248 @@ 1.4 +## 1.5 +## opensips.spec -- OpenPKG RPM Package Specification 1.6 +## Copyright (c) 2000-2010 OpenPKG Foundation e.V. <http://openpkg.net/> 1.7 +## 1.8 +## Permission to use, copy, modify, and distribute this software for 1.9 +## any purpose with or without fee is hereby granted, provided that 1.10 +## the above copyright notice and this permission notice appear in all 1.11 +## copies. 1.12 +## 1.13 +## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 1.14 +## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1.15 +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1.16 +## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR 1.17 +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.18 +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.19 +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 1.20 +## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 1.21 +## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 1.22 +## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 1.23 +## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1.24 +## SUCH DAMAGE. 1.25 +## 1.26 + 1.27 +# package options 1.28 +%define V_opensips 1.6.4 1.29 +%define V_rtpproxy 1.2.1 1.30 + 1.31 +# package information 1.32 +Name: opensips 1.33 +Summary: Open SIP Server 1.34 +URL: http://www.opensips.org/ 1.35 +Vendor: FhG FOKUS et al. 1.36 +Packager: OpenPKG Foundation e.V. 1.37 +Distribution: OpenPKG Community 1.38 +Class: PLUS 1.39 +Group: VoIP 1.40 +License: GPL 1.41 +Version: %{V_opensips} 1.42 +Release: 20101221 1.43 + 1.44 +# package options 1.45 +%option with_fsl yes 1.46 +%option with_ssl no 1.47 + 1.48 +# list of sources 1.49 +Source0: http://www.opensips.org/pub/opensips/%{version}/src/opensips-%{V_opensips}-tls_src.tar.gz 1.50 +Source1: http://b2bua.org/chrome/site/rtpproxy-%{V_rtpproxy}.tar.gz 1.51 +Source2: rc.opensips 1.52 +Source3: fsl.opensips 1.53 +Source4: opensips.cfg 1.54 +Source5: opensips.schema-dbtext.txt 1.55 +Patch0: opensips.patch 1.56 + 1.57 +# build information 1.58 +BuildPreReq: OpenPKG, openpkg >= 20100101, make, gcc, flex, bison, sed 1.59 +PreReq: OpenPKG, openpkg >= 20100101 1.60 +BuildPreReq: pcre 1.61 +PreReq: pcre 1.62 +%if "%{with_fsl}" == "yes" 1.63 +BuildPreReq: fsl 1.64 +PreReq: fsl 1.65 +%endif 1.66 +%if "%{with_ssl}" == "yes" 1.67 +BuildPreReq: openssl 1.68 +PreReq: openssl 1.69 +%endif 1.70 + 1.71 +%description 1.72 + OpenSIPS is (beside Kamailio) a successor to OpenSER, which in 1.73 + turn was spawned from FhG FOKUS' SIP Express Router (SER). It 1.74 + provides SIP (RFC3621) registrar, proxy and routing functionality. 1.75 + A C shell like scripting language provides full control over the 1.76 + server's behaviour. It's modular architecture allows only required 1.77 + functionality to be loaded. 1.78 + 1.79 +%track 1.80 + prog opensips = { 1.81 + version = %{V_opensips} 1.82 + url = http://www.opensips.org/pub/opensips/ 1.83 + regex = (\d+\.\d+\.\d+)/ 1.84 + url = http://www.opensips.org/pub/opensips/__NEWVER__/src/ 1.85 + regex = opensips-(__VER__)-tls_src\.tar\.gz 1.86 + } 1.87 + prog opensips:rtpproxy = { 1.88 + version = %{V_rtpproxy} 1.89 + url = http://www.rtpproxy.org/ 1.90 + regex = rtpproxy-(\d+(?:\.\d+)+)\.tar\.gz 1.91 + } 1.92 + 1.93 +%prep 1.94 + %setup -q -n opensips-%{version}-tls 1.95 + %setup -q -n opensips-%{version}-tls -T -D -a 1 1.96 + %patch -p0 1.97 + 1.98 +%build 1.99 + # build dependencies 1.100 + %{l_make} %{l_mflags} \ 1.101 + CC="%{l_cc} %{l_cflags} %{l_cppflags}" \ 1.102 +%if "%{with_ssl}" == "yes" 1.103 + TLS=1 \ 1.104 +%endif 1.105 + prefix=%{l_prefix} \ 1.106 + dep >/dev/null 2>&1 || true 1.107 + 1.108 + # build program 1.109 + %{l_make} %{l_mflags} \ 1.110 + CC="%{l_cc} %{l_cflags} %{l_cppflags}" \ 1.111 +%if "%{with_ssl}" == "yes" 1.112 + TLS=1 \ 1.113 +%endif 1.114 + prefix=%{l_prefix} 1.115 + 1.116 + # build modules 1.117 + %{l_make} %{l_mflags} \ 1.118 + CC="%{l_cc} %{l_cflags} %{l_cppflags}" \ 1.119 +%if "%{with_ssl}" == "yes" 1.120 + TLS=1 \ 1.121 +%endif 1.122 + prefix=%{l_prefix} \ 1.123 + modules \ 1.124 + skip_modules="mysql jabber" 1.125 + 1.126 + # build rtpproxy extension 1.127 + ( cd rtpproxy-%{V_rtpproxy} 1.128 + export CC="%{l_cc}" 1.129 + export CFLAGS="%{l_cflags -O}" 1.130 + export LIBS="" 1.131 + case "%{l_platform -t}" in 1.132 + *-sunos* ) LIBS="$LIBS -lsocket -lnsl -lrt" ;; 1.133 + esac 1.134 + ./configure 1.135 + %{l_make} %{l_mflags} 1.136 + ) || exit $? 1.137 + 1.138 +%install 1.139 + 1.140 + # install program 1.141 + %{l_make} %{l_mflags} \ 1.142 + INSTALL="%{l_shtool} install%{l_nil} -c" \ 1.143 + basedir=$RPM_BUILD_ROOT \ 1.144 + prefix=%{l_prefix} \ 1.145 + cfg-prefix=$RPM_BUILD_ROOT \ 1.146 + cfg-target=%{l_prefix}/etc/opensips/ \ 1.147 + doc-dir=share/opensips/doc/ \ 1.148 + man-dir=man/ \ 1.149 + install 1.150 + 1.151 + # install modules 1.152 + %{l_make} %{l_mflags} \ 1.153 + INSTALL="%{l_shtool} install%{l_nil} -c" \ 1.154 + basedir=$RPM_BUILD_ROOT \ 1.155 + prefix=%{l_prefix} \ 1.156 + cfg-prefix=$RPM_BUILD_ROOT \ 1.157 + cfg-target=%{l_prefix}/etc/opensips/ \ 1.158 + doc-dir=share/opensips/doc/ \ 1.159 + man-dir=man/ \ 1.160 + install-modules \ 1.161 + skip_modules="mysql jabber" 1.162 + 1.163 + # install rtpproxy extension 1.164 + %{l_shtool} install -c -s -m 755 \ 1.165 + rtpproxy-%{V_rtpproxy}/rtpproxy $RPM_BUILD_ROOT%{l_prefix}/sbin/opensips_rtpproxy 1.166 + 1.167 + # strip down installation 1.168 + strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true 1.169 + rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/opensips_mysql.sh 1.170 + 1.171 + # post-adjust installation 1.172 + %{l_shtool} subst \ 1.173 + -e 's;/etc/opensips/opensipsctlrc;%{l_prefix}/etc/opensips/opensipsctlrc;g' \ 1.174 + $RPM_BUILD_ROOT%{l_prefix}/sbin/opensipsctl 1.175 + %{l_shtool} mkdir -f -p -m 755 \ 1.176 + $RPM_BUILD_ROOT%{l_prefix}/etc/opensips 1.177 + %{l_shtool} install -c -m 644 \ 1.178 + -e 's;^# \(PID_FILE\)=.*;\1=%{l_prefix}/var/opensips/opensips.pid;' \ 1.179 + -e 's;^# \(OSIPS_FIFO\)=.*;\1=%{l_prefix}/var/opensips/opensips.fifo;' \ 1.180 + scripts/opensipsctlrc \ 1.181 + $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/opensipsctlrc 1.182 + 1.183 + # install default configuration 1.184 + %{l_shtool} mkdir -f -p -m 755 \ 1.185 + $RPM_BUILD_ROOT%{l_prefix}/etc/opensips 1.186 + %{l_shtool} install -c -m 755 %{l_value -s -a} \ 1.187 + %{SOURCE opensips.cfg} \ 1.188 + $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/ 1.189 + 1.190 + # install OSSP fsl configuration 1.191 + %{l_shtool} mkdir -f -p -m 755 \ 1.192 + $RPM_BUILD_ROOT%{l_prefix}/etc/fsl 1.193 + %{l_shtool} install -c -m 644 %{l_value -s -a} \ 1.194 + %{SOURCE fsl.opensips} \ 1.195 + $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/ 1.196 + 1.197 + # install run-command script 1.198 + %{l_shtool} mkdir -f -p -m 755 \ 1.199 + $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d 1.200 + %{l_shtool} install -c -m 755 %{l_value -s -a} \ 1.201 + %{SOURCE rc.opensips} \ 1.202 + $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ 1.203 + 1.204 + # create database directory and install database schema definitions 1.205 + %{l_shtool} mkdir -f -p -m 755 \ 1.206 + $RPM_BUILD_ROOT%{l_prefix}/var/opensips 1.207 + %{l_shtool} install -c -m 644 \ 1.208 + %{SOURCE opensips.schema-dbtext.txt} \ 1.209 + $RPM_BUILD_ROOT%{l_prefix}/share/opensips/ 1.210 + 1.211 + # determine installation files 1.212 + %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ 1.213 + %{l_files_std} \ 1.214 + '%config %{l_prefix}/etc/fsl/*' \ 1.215 + '%config %{l_prefix}/etc/opensips/*' \ 1.216 + '%doc %{l_prefix}/share/opensips/doc/*' \ 1.217 + '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/opensips' 1.218 + 1.219 +%files -f files 1.220 + 1.221 +%clean 1.222 + 1.223 +%post 1.224 + # on install, setup database 1.225 + if [ ! -d $RPM_INSTALL_PREFIX/var/opensips/db ]; then 1.226 + mkdir $RPM_INSTALL_PREFIX/var/opensips/db 1.227 + chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/opensips/db 1.228 + chmod 755 $RPM_INSTALL_PREFIX/var/opensips/db 1.229 + schema="$RPM_INSTALL_PREFIX/share/opensips/opensips.schema-dbtext.txt" 1.230 + for table in `sed -e '/^#.*/d' -e '/^$/d' -e 's;\([^:]*\):.*;\1;' <$schema | sort -u`; do 1.231 + grep "^${table}:" $schema | sed -e "s;^${table}: *;;" \ 1.232 + >$RPM_INSTALL_PREFIX/var/opensips/db/$table 1.233 + done 1.234 + chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/opensips/db/* 2>/dev/null || true 1.235 + chmod 644 $RPM_INSTALL_PREFIX/var/opensips/db/* 2>/dev/null || true 1.236 + fi 1.237 + 1.238 + # after upgrade, restart service 1.239 + [ $1 -eq 2 ] || exit 0 1.240 + eval `%{l_rc} opensips status 2>/dev/null` 1.241 + [ ".$opensips_active" = .yes ] && %{l_rc} opensips restart 1.242 + exit 0 1.243 + 1.244 +%preun 1.245 + # before erase, stop service and remove log files 1.246 + [ $1 -eq 0 ] || exit 0 1.247 + %{l_rc} opensips stop 2>/dev/null 1.248 + rm -rf $RPM_INSTALL_PREFIX/var/opensips/db 2>/dev/null || true 1.249 + rm -f $RPM_INSTALL_PREFIX/var/opensips/* 2>/dev/null || true 1.250 + exit 0 1.251 +