Wed, 21 Sep 2011 14:02:13 +0200
Import package vendor original specs for necessary manipulations.
michael@376 | 1 | ## |
michael@376 | 2 | ## opensips.spec -- OpenPKG RPM Package Specification |
michael@376 | 3 | ## Copyright (c) 2000-2010 OpenPKG Foundation e.V. <http://openpkg.net/> |
michael@376 | 4 | ## |
michael@376 | 5 | ## Permission to use, copy, modify, and distribute this software for |
michael@376 | 6 | ## any purpose with or without fee is hereby granted, provided that |
michael@376 | 7 | ## the above copyright notice and this permission notice appear in all |
michael@376 | 8 | ## copies. |
michael@376 | 9 | ## |
michael@376 | 10 | ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
michael@376 | 11 | ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
michael@376 | 12 | ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
michael@376 | 13 | ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
michael@376 | 14 | ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@376 | 15 | ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@376 | 16 | ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
michael@376 | 17 | ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
michael@376 | 18 | ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
michael@376 | 19 | ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
michael@376 | 20 | ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
michael@376 | 21 | ## SUCH DAMAGE. |
michael@376 | 22 | ## |
michael@376 | 23 | |
michael@376 | 24 | # package options |
michael@376 | 25 | %define V_opensips 1.6.4 |
michael@376 | 26 | %define V_rtpproxy 1.2.1 |
michael@376 | 27 | |
michael@376 | 28 | # package information |
michael@376 | 29 | Name: opensips |
michael@376 | 30 | Summary: Open SIP Server |
michael@376 | 31 | URL: http://www.opensips.org/ |
michael@376 | 32 | Vendor: FhG FOKUS et al. |
michael@376 | 33 | Packager: OpenPKG Foundation e.V. |
michael@376 | 34 | Distribution: OpenPKG Community |
michael@376 | 35 | Class: PLUS |
michael@376 | 36 | Group: VoIP |
michael@376 | 37 | License: GPL |
michael@376 | 38 | Version: %{V_opensips} |
michael@376 | 39 | Release: 20101221 |
michael@376 | 40 | |
michael@376 | 41 | # package options |
michael@376 | 42 | %option with_fsl yes |
michael@376 | 43 | %option with_ssl no |
michael@376 | 44 | |
michael@376 | 45 | # list of sources |
michael@376 | 46 | Source0: http://www.opensips.org/pub/opensips/%{version}/src/opensips-%{V_opensips}-tls_src.tar.gz |
michael@376 | 47 | Source1: http://b2bua.org/chrome/site/rtpproxy-%{V_rtpproxy}.tar.gz |
michael@376 | 48 | Source2: rc.opensips |
michael@376 | 49 | Source3: fsl.opensips |
michael@376 | 50 | Source4: opensips.cfg |
michael@376 | 51 | Source5: opensips.schema-dbtext.txt |
michael@376 | 52 | Patch0: opensips.patch |
michael@376 | 53 | |
michael@376 | 54 | # build information |
michael@376 | 55 | BuildPreReq: OpenPKG, openpkg >= 20100101, make, gcc, flex, bison, sed |
michael@376 | 56 | PreReq: OpenPKG, openpkg >= 20100101 |
michael@376 | 57 | BuildPreReq: pcre |
michael@376 | 58 | PreReq: pcre |
michael@376 | 59 | %if "%{with_fsl}" == "yes" |
michael@376 | 60 | BuildPreReq: fsl |
michael@376 | 61 | PreReq: fsl |
michael@376 | 62 | %endif |
michael@376 | 63 | %if "%{with_ssl}" == "yes" |
michael@376 | 64 | BuildPreReq: openssl |
michael@376 | 65 | PreReq: openssl |
michael@376 | 66 | %endif |
michael@376 | 67 | |
michael@376 | 68 | %description |
michael@376 | 69 | OpenSIPS is (beside Kamailio) a successor to OpenSER, which in |
michael@376 | 70 | turn was spawned from FhG FOKUS' SIP Express Router (SER). It |
michael@376 | 71 | provides SIP (RFC3621) registrar, proxy and routing functionality. |
michael@376 | 72 | A C shell like scripting language provides full control over the |
michael@376 | 73 | server's behaviour. It's modular architecture allows only required |
michael@376 | 74 | functionality to be loaded. |
michael@376 | 75 | |
michael@376 | 76 | %track |
michael@376 | 77 | prog opensips = { |
michael@376 | 78 | version = %{V_opensips} |
michael@376 | 79 | url = http://www.opensips.org/pub/opensips/ |
michael@376 | 80 | regex = (\d+\.\d+\.\d+)/ |
michael@376 | 81 | url = http://www.opensips.org/pub/opensips/__NEWVER__/src/ |
michael@376 | 82 | regex = opensips-(__VER__)-tls_src\.tar\.gz |
michael@376 | 83 | } |
michael@376 | 84 | prog opensips:rtpproxy = { |
michael@376 | 85 | version = %{V_rtpproxy} |
michael@376 | 86 | url = http://www.rtpproxy.org/ |
michael@376 | 87 | regex = rtpproxy-(\d+(?:\.\d+)+)\.tar\.gz |
michael@376 | 88 | } |
michael@376 | 89 | |
michael@376 | 90 | %prep |
michael@376 | 91 | %setup -q -n opensips-%{version}-tls |
michael@376 | 92 | %setup -q -n opensips-%{version}-tls -T -D -a 1 |
michael@376 | 93 | %patch -p0 |
michael@376 | 94 | |
michael@376 | 95 | %build |
michael@376 | 96 | # build dependencies |
michael@376 | 97 | %{l_make} %{l_mflags} \ |
michael@376 | 98 | CC="%{l_cc} %{l_cflags} %{l_cppflags}" \ |
michael@376 | 99 | %if "%{with_ssl}" == "yes" |
michael@376 | 100 | TLS=1 \ |
michael@376 | 101 | %endif |
michael@376 | 102 | prefix=%{l_prefix} \ |
michael@376 | 103 | dep >/dev/null 2>&1 || true |
michael@376 | 104 | |
michael@376 | 105 | # build program |
michael@376 | 106 | %{l_make} %{l_mflags} \ |
michael@376 | 107 | CC="%{l_cc} %{l_cflags} %{l_cppflags}" \ |
michael@376 | 108 | %if "%{with_ssl}" == "yes" |
michael@376 | 109 | TLS=1 \ |
michael@376 | 110 | %endif |
michael@376 | 111 | prefix=%{l_prefix} |
michael@376 | 112 | |
michael@376 | 113 | # build modules |
michael@376 | 114 | %{l_make} %{l_mflags} \ |
michael@376 | 115 | CC="%{l_cc} %{l_cflags} %{l_cppflags}" \ |
michael@376 | 116 | %if "%{with_ssl}" == "yes" |
michael@376 | 117 | TLS=1 \ |
michael@376 | 118 | %endif |
michael@376 | 119 | prefix=%{l_prefix} \ |
michael@376 | 120 | modules \ |
michael@376 | 121 | skip_modules="mysql jabber" |
michael@376 | 122 | |
michael@376 | 123 | # build rtpproxy extension |
michael@376 | 124 | ( cd rtpproxy-%{V_rtpproxy} |
michael@376 | 125 | export CC="%{l_cc}" |
michael@376 | 126 | export CFLAGS="%{l_cflags -O}" |
michael@376 | 127 | export LIBS="" |
michael@376 | 128 | case "%{l_platform -t}" in |
michael@376 | 129 | *-sunos* ) LIBS="$LIBS -lsocket -lnsl -lrt" ;; |
michael@376 | 130 | esac |
michael@376 | 131 | ./configure |
michael@376 | 132 | %{l_make} %{l_mflags} |
michael@376 | 133 | ) || exit $? |
michael@376 | 134 | |
michael@376 | 135 | %install |
michael@376 | 136 | |
michael@376 | 137 | # install program |
michael@376 | 138 | %{l_make} %{l_mflags} \ |
michael@376 | 139 | INSTALL="%{l_shtool} install%{l_nil} -c" \ |
michael@376 | 140 | basedir=$RPM_BUILD_ROOT \ |
michael@376 | 141 | prefix=%{l_prefix} \ |
michael@376 | 142 | cfg-prefix=$RPM_BUILD_ROOT \ |
michael@376 | 143 | cfg-target=%{l_prefix}/etc/opensips/ \ |
michael@376 | 144 | doc-dir=share/opensips/doc/ \ |
michael@376 | 145 | man-dir=man/ \ |
michael@376 | 146 | install |
michael@376 | 147 | |
michael@376 | 148 | # install modules |
michael@376 | 149 | %{l_make} %{l_mflags} \ |
michael@376 | 150 | INSTALL="%{l_shtool} install%{l_nil} -c" \ |
michael@376 | 151 | basedir=$RPM_BUILD_ROOT \ |
michael@376 | 152 | prefix=%{l_prefix} \ |
michael@376 | 153 | cfg-prefix=$RPM_BUILD_ROOT \ |
michael@376 | 154 | cfg-target=%{l_prefix}/etc/opensips/ \ |
michael@376 | 155 | doc-dir=share/opensips/doc/ \ |
michael@376 | 156 | man-dir=man/ \ |
michael@376 | 157 | install-modules \ |
michael@376 | 158 | skip_modules="mysql jabber" |
michael@376 | 159 | |
michael@376 | 160 | # install rtpproxy extension |
michael@376 | 161 | %{l_shtool} install -c -s -m 755 \ |
michael@376 | 162 | rtpproxy-%{V_rtpproxy}/rtpproxy $RPM_BUILD_ROOT%{l_prefix}/sbin/opensips_rtpproxy |
michael@376 | 163 | |
michael@376 | 164 | # strip down installation |
michael@376 | 165 | strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true |
michael@376 | 166 | rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/opensips_mysql.sh |
michael@376 | 167 | |
michael@376 | 168 | # post-adjust installation |
michael@376 | 169 | %{l_shtool} subst \ |
michael@376 | 170 | -e 's;/etc/opensips/opensipsctlrc;%{l_prefix}/etc/opensips/opensipsctlrc;g' \ |
michael@376 | 171 | $RPM_BUILD_ROOT%{l_prefix}/sbin/opensipsctl |
michael@376 | 172 | %{l_shtool} mkdir -f -p -m 755 \ |
michael@376 | 173 | $RPM_BUILD_ROOT%{l_prefix}/etc/opensips |
michael@376 | 174 | %{l_shtool} install -c -m 644 \ |
michael@376 | 175 | -e 's;^# \(PID_FILE\)=.*;\1=%{l_prefix}/var/opensips/opensips.pid;' \ |
michael@376 | 176 | -e 's;^# \(OSIPS_FIFO\)=.*;\1=%{l_prefix}/var/opensips/opensips.fifo;' \ |
michael@376 | 177 | scripts/opensipsctlrc \ |
michael@376 | 178 | $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/opensipsctlrc |
michael@376 | 179 | |
michael@376 | 180 | # install default configuration |
michael@376 | 181 | %{l_shtool} mkdir -f -p -m 755 \ |
michael@376 | 182 | $RPM_BUILD_ROOT%{l_prefix}/etc/opensips |
michael@376 | 183 | %{l_shtool} install -c -m 755 %{l_value -s -a} \ |
michael@376 | 184 | %{SOURCE opensips.cfg} \ |
michael@376 | 185 | $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/ |
michael@376 | 186 | |
michael@376 | 187 | # install OSSP fsl configuration |
michael@376 | 188 | %{l_shtool} mkdir -f -p -m 755 \ |
michael@376 | 189 | $RPM_BUILD_ROOT%{l_prefix}/etc/fsl |
michael@376 | 190 | %{l_shtool} install -c -m 644 %{l_value -s -a} \ |
michael@376 | 191 | %{SOURCE fsl.opensips} \ |
michael@376 | 192 | $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/ |
michael@376 | 193 | |
michael@376 | 194 | # install run-command script |
michael@376 | 195 | %{l_shtool} mkdir -f -p -m 755 \ |
michael@376 | 196 | $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d |
michael@376 | 197 | %{l_shtool} install -c -m 755 %{l_value -s -a} \ |
michael@376 | 198 | %{SOURCE rc.opensips} \ |
michael@376 | 199 | $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ |
michael@376 | 200 | |
michael@376 | 201 | # create database directory and install database schema definitions |
michael@376 | 202 | %{l_shtool} mkdir -f -p -m 755 \ |
michael@376 | 203 | $RPM_BUILD_ROOT%{l_prefix}/var/opensips |
michael@376 | 204 | %{l_shtool} install -c -m 644 \ |
michael@376 | 205 | %{SOURCE opensips.schema-dbtext.txt} \ |
michael@376 | 206 | $RPM_BUILD_ROOT%{l_prefix}/share/opensips/ |
michael@376 | 207 | |
michael@376 | 208 | # determine installation files |
michael@376 | 209 | %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ |
michael@376 | 210 | %{l_files_std} \ |
michael@376 | 211 | '%config %{l_prefix}/etc/fsl/*' \ |
michael@376 | 212 | '%config %{l_prefix}/etc/opensips/*' \ |
michael@376 | 213 | '%doc %{l_prefix}/share/opensips/doc/*' \ |
michael@376 | 214 | '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/opensips' |
michael@376 | 215 | |
michael@376 | 216 | %files -f files |
michael@376 | 217 | |
michael@376 | 218 | %clean |
michael@376 | 219 | |
michael@376 | 220 | %post |
michael@376 | 221 | # on install, setup database |
michael@376 | 222 | if [ ! -d $RPM_INSTALL_PREFIX/var/opensips/db ]; then |
michael@376 | 223 | mkdir $RPM_INSTALL_PREFIX/var/opensips/db |
michael@376 | 224 | chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/opensips/db |
michael@376 | 225 | chmod 755 $RPM_INSTALL_PREFIX/var/opensips/db |
michael@376 | 226 | schema="$RPM_INSTALL_PREFIX/share/opensips/opensips.schema-dbtext.txt" |
michael@376 | 227 | for table in `sed -e '/^#.*/d' -e '/^$/d' -e 's;\([^:]*\):.*;\1;' <$schema | sort -u`; do |
michael@376 | 228 | grep "^${table}:" $schema | sed -e "s;^${table}: *;;" \ |
michael@376 | 229 | >$RPM_INSTALL_PREFIX/var/opensips/db/$table |
michael@376 | 230 | done |
michael@376 | 231 | chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/opensips/db/* 2>/dev/null || true |
michael@376 | 232 | chmod 644 $RPM_INSTALL_PREFIX/var/opensips/db/* 2>/dev/null || true |
michael@376 | 233 | fi |
michael@376 | 234 | |
michael@376 | 235 | # after upgrade, restart service |
michael@376 | 236 | [ $1 -eq 2 ] || exit 0 |
michael@376 | 237 | eval `%{l_rc} opensips status 2>/dev/null` |
michael@376 | 238 | [ ".$opensips_active" = .yes ] && %{l_rc} opensips restart |
michael@376 | 239 | exit 0 |
michael@376 | 240 | |
michael@376 | 241 | %preun |
michael@376 | 242 | # before erase, stop service and remove log files |
michael@376 | 243 | [ $1 -eq 0 ] || exit 0 |
michael@376 | 244 | %{l_rc} opensips stop 2>/dev/null |
michael@376 | 245 | rm -rf $RPM_INSTALL_PREFIX/var/opensips/db 2>/dev/null || true |
michael@376 | 246 | rm -f $RPM_INSTALL_PREFIX/var/opensips/* 2>/dev/null || true |
michael@376 | 247 | exit 0 |
michael@376 | 248 |