opensips/opensips.spec

Wed, 21 Sep 2011 14:02:13 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 21 Sep 2011 14:02:13 +0200
changeset 376
8f552d1cd671
child 377
67e813202d53
permissions
-rw-r--r--

Import package vendor original specs for necessary manipulations.

     1 ##
     2 ##  opensips.spec -- OpenPKG RPM Package Specification
     3 ##  Copyright (c) 2000-2010 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_opensips  1.6.4
    26 %define       V_rtpproxy  1.2.1
    28 #   package information
    29 Name:         opensips
    30 Summary:      Open SIP Server
    31 URL:          http://www.opensips.org/
    32 Vendor:       FhG FOKUS et al.
    33 Packager:     OpenPKG Foundation e.V.
    34 Distribution: OpenPKG Community
    35 Class:        PLUS
    36 Group:        VoIP
    37 License:      GPL
    38 Version:      %{V_opensips}
    39 Release:      20101221
    41 #   package options
    42 %option       with_fsl  yes
    43 %option       with_ssl  no
    45 #   list of sources
    46 Source0:      http://www.opensips.org/pub/opensips/%{version}/src/opensips-%{V_opensips}-tls_src.tar.gz
    47 Source1:      http://b2bua.org/chrome/site/rtpproxy-%{V_rtpproxy}.tar.gz
    48 Source2:      rc.opensips
    49 Source3:      fsl.opensips
    50 Source4:      opensips.cfg
    51 Source5:      opensips.schema-dbtext.txt
    52 Patch0:       opensips.patch
    54 #   build information
    55 BuildPreReq:  OpenPKG, openpkg >= 20100101, make, gcc, flex, bison, sed
    56 PreReq:       OpenPKG, openpkg >= 20100101
    57 BuildPreReq:  pcre
    58 PreReq:       pcre
    59 %if "%{with_fsl}" == "yes"
    60 BuildPreReq:  fsl
    61 PreReq:       fsl
    62 %endif
    63 %if "%{with_ssl}" == "yes"
    64 BuildPreReq:  openssl
    65 PreReq:       openssl
    66 %endif
    68 %description
    69     OpenSIPS is (beside Kamailio) a successor to OpenSER, which in
    70     turn was spawned from FhG FOKUS' SIP Express Router (SER). It
    71     provides SIP (RFC3621) registrar, proxy and routing functionality.
    72     A C shell like scripting language provides full control over the
    73     server's behaviour. It's modular architecture allows only required
    74     functionality to be loaded.
    76 %track
    77     prog opensips = {
    78         version   = %{V_opensips}
    79         url       = http://www.opensips.org/pub/opensips/
    80         regex     = (\d+\.\d+\.\d+)/
    81         url       = http://www.opensips.org/pub/opensips/__NEWVER__/src/
    82         regex     = opensips-(__VER__)-tls_src\.tar\.gz
    83     }
    84     prog opensips:rtpproxy = {
    85         version   = %{V_rtpproxy}
    86         url       = http://www.rtpproxy.org/
    87         regex     = rtpproxy-(\d+(?:\.\d+)+)\.tar\.gz
    88     }
    90 %prep
    91     %setup -q -n opensips-%{version}-tls
    92     %setup -q -n opensips-%{version}-tls -T -D -a 1
    93     %patch -p0
    95 %build
    96     #   build dependencies
    97     %{l_make} %{l_mflags} \
    98         CC="%{l_cc} %{l_cflags} %{l_cppflags}" \
    99 %if "%{with_ssl}" == "yes"
   100         TLS=1 \
   101 %endif
   102         prefix=%{l_prefix} \
   103         dep >/dev/null 2>&1 || true
   105     #   build program
   106     %{l_make} %{l_mflags} \
   107         CC="%{l_cc} %{l_cflags} %{l_cppflags}" \
   108 %if "%{with_ssl}" == "yes"
   109         TLS=1 \
   110 %endif
   111         prefix=%{l_prefix}
   113     #   build modules
   114     %{l_make} %{l_mflags} \
   115         CC="%{l_cc} %{l_cflags} %{l_cppflags}" \
   116 %if "%{with_ssl}" == "yes"
   117         TLS=1 \
   118 %endif
   119         prefix=%{l_prefix} \
   120         modules \
   121         skip_modules="mysql jabber"
   123     #   build rtpproxy extension
   124     ( cd rtpproxy-%{V_rtpproxy}
   125       export CC="%{l_cc}"
   126       export CFLAGS="%{l_cflags -O}"
   127       export LIBS=""
   128       case "%{l_platform -t}" in
   129           *-sunos* ) LIBS="$LIBS -lsocket -lnsl -lrt" ;;
   130       esac
   131       ./configure
   132       %{l_make} %{l_mflags}
   133     ) || exit $?
   135 %install
   137     #   install program
   138     %{l_make} %{l_mflags} \
   139         INSTALL="%{l_shtool} install%{l_nil} -c" \
   140         basedir=$RPM_BUILD_ROOT \
   141         prefix=%{l_prefix} \
   142         cfg-prefix=$RPM_BUILD_ROOT \
   143         cfg-target=%{l_prefix}/etc/opensips/ \
   144         doc-dir=share/opensips/doc/ \
   145         man-dir=man/ \
   146         install
   148     #   install modules
   149     %{l_make} %{l_mflags} \
   150         INSTALL="%{l_shtool} install%{l_nil} -c" \
   151         basedir=$RPM_BUILD_ROOT \
   152         prefix=%{l_prefix} \
   153         cfg-prefix=$RPM_BUILD_ROOT \
   154         cfg-target=%{l_prefix}/etc/opensips/ \
   155         doc-dir=share/opensips/doc/ \
   156         man-dir=man/ \
   157         install-modules \
   158         skip_modules="mysql jabber"
   160     #   install rtpproxy extension
   161     %{l_shtool} install -c -s -m 755 \
   162         rtpproxy-%{V_rtpproxy}/rtpproxy $RPM_BUILD_ROOT%{l_prefix}/sbin/opensips_rtpproxy
   164     #   strip down installation
   165     strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
   166     rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/opensips_mysql.sh
   168     #   post-adjust installation
   169     %{l_shtool} subst \
   170         -e 's;/etc/opensips/opensipsctlrc;%{l_prefix}/etc/opensips/opensipsctlrc;g' \
   171         $RPM_BUILD_ROOT%{l_prefix}/sbin/opensipsctl
   172     %{l_shtool} mkdir -f -p -m 755 \
   173         $RPM_BUILD_ROOT%{l_prefix}/etc/opensips
   174     %{l_shtool} install -c -m 644 \
   175         -e 's;^# \(PID_FILE\)=.*;\1=%{l_prefix}/var/opensips/opensips.pid;' \
   176         -e 's;^# \(OSIPS_FIFO\)=.*;\1=%{l_prefix}/var/opensips/opensips.fifo;' \
   177         scripts/opensipsctlrc \
   178         $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/opensipsctlrc
   180     #   install default configuration
   181     %{l_shtool} mkdir -f -p -m 755 \
   182         $RPM_BUILD_ROOT%{l_prefix}/etc/opensips
   183     %{l_shtool} install -c -m 755 %{l_value -s -a} \
   184         %{SOURCE opensips.cfg} \
   185         $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/
   187     #   install OSSP fsl configuration
   188     %{l_shtool} mkdir -f -p -m 755 \
   189         $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
   190     %{l_shtool} install -c -m 644 %{l_value -s -a} \
   191         %{SOURCE fsl.opensips} \
   192         $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
   194     #   install run-command script
   195     %{l_shtool} mkdir -f -p -m 755 \
   196         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
   197     %{l_shtool} install -c -m 755 %{l_value -s -a} \
   198         %{SOURCE rc.opensips} \
   199         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
   201     #   create database directory and install database schema definitions
   202     %{l_shtool} mkdir -f -p -m 755 \
   203         $RPM_BUILD_ROOT%{l_prefix}/var/opensips
   204     %{l_shtool} install -c -m 644 \
   205         %{SOURCE opensips.schema-dbtext.txt} \
   206         $RPM_BUILD_ROOT%{l_prefix}/share/opensips/
   208     #   determine installation files
   209     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
   210         %{l_files_std} \
   211         '%config %{l_prefix}/etc/fsl/*' \
   212         '%config %{l_prefix}/etc/opensips/*' \
   213         '%doc %{l_prefix}/share/opensips/doc/*' \
   214         '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/opensips'
   216 %files -f files
   218 %clean
   220 %post
   221     #   on install, setup database
   222     if [ ! -d $RPM_INSTALL_PREFIX/var/opensips/db ]; then
   223         mkdir $RPM_INSTALL_PREFIX/var/opensips/db
   224         chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/opensips/db
   225         chmod 755 $RPM_INSTALL_PREFIX/var/opensips/db
   226         schema="$RPM_INSTALL_PREFIX/share/opensips/opensips.schema-dbtext.txt"
   227         for table in `sed -e '/^#.*/d' -e '/^$/d' -e 's;\([^:]*\):.*;\1;' <$schema | sort -u`; do
   228             grep "^${table}:" $schema | sed -e "s;^${table}: *;;" \
   229                 >$RPM_INSTALL_PREFIX/var/opensips/db/$table
   230         done
   231         chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/opensips/db/* 2>/dev/null || true
   232         chmod 644 $RPM_INSTALL_PREFIX/var/opensips/db/* 2>/dev/null || true
   233     fi
   235     #   after upgrade, restart service
   236     [ $1 -eq 2 ] || exit 0
   237     eval `%{l_rc} opensips status 2>/dev/null`
   238     [ ".$opensips_active" = .yes ] && %{l_rc} opensips restart
   239     exit 0
   241 %preun
   242     #   before erase, stop service and remove log files
   243     [ $1 -eq 0 ] || exit 0
   244     %{l_rc} opensips stop 2>/dev/null
   245     rm -rf $RPM_INSTALL_PREFIX/var/opensips/db 2>/dev/null || true
   246     rm -f  $RPM_INSTALL_PREFIX/var/opensips/*  2>/dev/null || true
   247     exit 0

mercurial