michael@376: ## michael@376: ## opensips.spec -- OpenPKG RPM Package Specification michael@376: ## Copyright (c) 2000-2010 OpenPKG Foundation e.V. michael@376: ## michael@376: ## Permission to use, copy, modify, and distribute this software for michael@376: ## any purpose with or without fee is hereby granted, provided that michael@376: ## the above copyright notice and this permission notice appear in all michael@376: ## copies. michael@376: ## michael@376: ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED michael@376: ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF michael@376: ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. michael@376: ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR michael@376: ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@376: ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@376: ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF michael@376: ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND michael@376: ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, michael@376: ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT michael@376: ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@376: ## SUCH DAMAGE. michael@376: ## michael@376: michael@376: # package options michael@376: %define V_opensips 1.6.4 michael@376: %define V_rtpproxy 1.2.1 michael@376: michael@376: # package information michael@376: Name: opensips michael@376: Summary: Open SIP Server michael@376: URL: http://www.opensips.org/ michael@376: Vendor: FhG FOKUS et al. michael@376: Packager: OpenPKG Foundation e.V. michael@376: Distribution: OpenPKG Community michael@376: Class: PLUS michael@376: Group: VoIP michael@376: License: GPL michael@376: Version: %{V_opensips} michael@376: Release: 20101221 michael@376: michael@376: # package options michael@376: %option with_fsl yes michael@376: %option with_ssl no michael@376: michael@376: # list of sources michael@376: Source0: http://www.opensips.org/pub/opensips/%{version}/src/opensips-%{V_opensips}-tls_src.tar.gz michael@376: Source1: http://b2bua.org/chrome/site/rtpproxy-%{V_rtpproxy}.tar.gz michael@376: Source2: rc.opensips michael@376: Source3: fsl.opensips michael@376: Source4: opensips.cfg michael@376: Source5: opensips.schema-dbtext.txt michael@376: Patch0: opensips.patch michael@376: michael@376: # build information michael@376: BuildPreReq: OpenPKG, openpkg >= 20100101, make, gcc, flex, bison, sed michael@376: PreReq: OpenPKG, openpkg >= 20100101 michael@376: BuildPreReq: pcre michael@376: PreReq: pcre michael@376: %if "%{with_fsl}" == "yes" michael@376: BuildPreReq: fsl michael@376: PreReq: fsl michael@376: %endif michael@376: %if "%{with_ssl}" == "yes" michael@376: BuildPreReq: openssl michael@376: PreReq: openssl michael@376: %endif michael@376: michael@376: %description michael@376: OpenSIPS is (beside Kamailio) a successor to OpenSER, which in michael@376: turn was spawned from FhG FOKUS' SIP Express Router (SER). It michael@376: provides SIP (RFC3621) registrar, proxy and routing functionality. michael@376: A C shell like scripting language provides full control over the michael@376: server's behaviour. It's modular architecture allows only required michael@376: functionality to be loaded. michael@376: michael@376: %track michael@376: prog opensips = { michael@376: version = %{V_opensips} michael@376: url = http://www.opensips.org/pub/opensips/ michael@376: regex = (\d+\.\d+\.\d+)/ michael@376: url = http://www.opensips.org/pub/opensips/__NEWVER__/src/ michael@376: regex = opensips-(__VER__)-tls_src\.tar\.gz michael@376: } michael@376: prog opensips:rtpproxy = { michael@376: version = %{V_rtpproxy} michael@376: url = http://www.rtpproxy.org/ michael@376: regex = rtpproxy-(\d+(?:\.\d+)+)\.tar\.gz michael@376: } michael@376: michael@376: %prep michael@376: %setup -q -n opensips-%{version}-tls michael@376: %setup -q -n opensips-%{version}-tls -T -D -a 1 michael@376: %patch -p0 michael@376: michael@376: %build michael@376: # build dependencies michael@376: %{l_make} %{l_mflags} \ michael@376: CC="%{l_cc} %{l_cflags} %{l_cppflags}" \ michael@376: %if "%{with_ssl}" == "yes" michael@376: TLS=1 \ michael@376: %endif michael@376: prefix=%{l_prefix} \ michael@376: dep >/dev/null 2>&1 || true michael@376: michael@376: # build program michael@376: %{l_make} %{l_mflags} \ michael@376: CC="%{l_cc} %{l_cflags} %{l_cppflags}" \ michael@376: %if "%{with_ssl}" == "yes" michael@376: TLS=1 \ michael@376: %endif michael@376: prefix=%{l_prefix} michael@376: michael@376: # build modules michael@376: %{l_make} %{l_mflags} \ michael@376: CC="%{l_cc} %{l_cflags} %{l_cppflags}" \ michael@376: %if "%{with_ssl}" == "yes" michael@376: TLS=1 \ michael@376: %endif michael@376: prefix=%{l_prefix} \ michael@376: modules \ michael@376: skip_modules="mysql jabber" michael@376: michael@376: # build rtpproxy extension michael@376: ( cd rtpproxy-%{V_rtpproxy} michael@376: export CC="%{l_cc}" michael@376: export CFLAGS="%{l_cflags -O}" michael@376: export LIBS="" michael@376: case "%{l_platform -t}" in michael@376: *-sunos* ) LIBS="$LIBS -lsocket -lnsl -lrt" ;; michael@376: esac michael@376: ./configure michael@376: %{l_make} %{l_mflags} michael@376: ) || exit $? michael@376: michael@376: %install michael@376: michael@376: # install program michael@376: %{l_make} %{l_mflags} \ michael@376: INSTALL="%{l_shtool} install%{l_nil} -c" \ michael@376: basedir=$RPM_BUILD_ROOT \ michael@376: prefix=%{l_prefix} \ michael@376: cfg-prefix=$RPM_BUILD_ROOT \ michael@376: cfg-target=%{l_prefix}/etc/opensips/ \ michael@376: doc-dir=share/opensips/doc/ \ michael@376: man-dir=man/ \ michael@376: install michael@376: michael@376: # install modules michael@376: %{l_make} %{l_mflags} \ michael@376: INSTALL="%{l_shtool} install%{l_nil} -c" \ michael@376: basedir=$RPM_BUILD_ROOT \ michael@376: prefix=%{l_prefix} \ michael@376: cfg-prefix=$RPM_BUILD_ROOT \ michael@376: cfg-target=%{l_prefix}/etc/opensips/ \ michael@376: doc-dir=share/opensips/doc/ \ michael@376: man-dir=man/ \ michael@376: install-modules \ michael@376: skip_modules="mysql jabber" michael@376: michael@376: # install rtpproxy extension michael@376: %{l_shtool} install -c -s -m 755 \ michael@376: rtpproxy-%{V_rtpproxy}/rtpproxy $RPM_BUILD_ROOT%{l_prefix}/sbin/opensips_rtpproxy michael@376: michael@376: # strip down installation michael@376: strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true michael@376: rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/opensips_mysql.sh michael@376: michael@376: # post-adjust installation michael@376: %{l_shtool} subst \ michael@376: -e 's;/etc/opensips/opensipsctlrc;%{l_prefix}/etc/opensips/opensipsctlrc;g' \ michael@376: $RPM_BUILD_ROOT%{l_prefix}/sbin/opensipsctl michael@376: %{l_shtool} mkdir -f -p -m 755 \ michael@376: $RPM_BUILD_ROOT%{l_prefix}/etc/opensips michael@376: %{l_shtool} install -c -m 644 \ michael@376: -e 's;^# \(PID_FILE\)=.*;\1=%{l_prefix}/var/opensips/opensips.pid;' \ michael@376: -e 's;^# \(OSIPS_FIFO\)=.*;\1=%{l_prefix}/var/opensips/opensips.fifo;' \ michael@376: scripts/opensipsctlrc \ michael@376: $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/opensipsctlrc michael@376: michael@376: # install default configuration michael@376: %{l_shtool} mkdir -f -p -m 755 \ michael@376: $RPM_BUILD_ROOT%{l_prefix}/etc/opensips michael@376: %{l_shtool} install -c -m 755 %{l_value -s -a} \ michael@376: %{SOURCE opensips.cfg} \ michael@376: $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/ michael@376: michael@376: # install OSSP fsl configuration michael@376: %{l_shtool} mkdir -f -p -m 755 \ michael@376: $RPM_BUILD_ROOT%{l_prefix}/etc/fsl michael@376: %{l_shtool} install -c -m 644 %{l_value -s -a} \ michael@376: %{SOURCE fsl.opensips} \ michael@376: $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/ michael@376: michael@376: # install run-command script michael@376: %{l_shtool} mkdir -f -p -m 755 \ michael@376: $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d michael@376: %{l_shtool} install -c -m 755 %{l_value -s -a} \ michael@376: %{SOURCE rc.opensips} \ michael@376: $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ michael@376: michael@376: # create database directory and install database schema definitions michael@376: %{l_shtool} mkdir -f -p -m 755 \ michael@376: $RPM_BUILD_ROOT%{l_prefix}/var/opensips michael@376: %{l_shtool} install -c -m 644 \ michael@376: %{SOURCE opensips.schema-dbtext.txt} \ michael@376: $RPM_BUILD_ROOT%{l_prefix}/share/opensips/ michael@376: michael@376: # determine installation files michael@376: %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ michael@376: %{l_files_std} \ michael@376: '%config %{l_prefix}/etc/fsl/*' \ michael@376: '%config %{l_prefix}/etc/opensips/*' \ michael@376: '%doc %{l_prefix}/share/opensips/doc/*' \ michael@376: '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/opensips' michael@376: michael@376: %files -f files michael@376: michael@376: %clean michael@376: michael@376: %post michael@376: # on install, setup database michael@376: if [ ! -d $RPM_INSTALL_PREFIX/var/opensips/db ]; then michael@376: mkdir $RPM_INSTALL_PREFIX/var/opensips/db michael@376: chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/opensips/db michael@376: chmod 755 $RPM_INSTALL_PREFIX/var/opensips/db michael@376: schema="$RPM_INSTALL_PREFIX/share/opensips/opensips.schema-dbtext.txt" michael@376: for table in `sed -e '/^#.*/d' -e '/^$/d' -e 's;\([^:]*\):.*;\1;' <$schema | sort -u`; do michael@376: grep "^${table}:" $schema | sed -e "s;^${table}: *;;" \ michael@376: >$RPM_INSTALL_PREFIX/var/opensips/db/$table michael@376: done michael@376: chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/opensips/db/* 2>/dev/null || true michael@376: chmod 644 $RPM_INSTALL_PREFIX/var/opensips/db/* 2>/dev/null || true michael@376: fi michael@376: michael@376: # after upgrade, restart service michael@376: [ $1 -eq 2 ] || exit 0 michael@376: eval `%{l_rc} opensips status 2>/dev/null` michael@376: [ ".$opensips_active" = .yes ] && %{l_rc} opensips restart michael@376: exit 0 michael@376: michael@376: %preun michael@376: # before erase, stop service and remove log files michael@376: [ $1 -eq 0 ] || exit 0 michael@376: %{l_rc} opensips stop 2>/dev/null michael@376: rm -rf $RPM_INSTALL_PREFIX/var/opensips/db 2>/dev/null || true michael@376: rm -f $RPM_INSTALL_PREFIX/var/opensips/* 2>/dev/null || true michael@376: exit 0 michael@376: