You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
251 lines
9.5 KiB
251 lines
9.5 KiB
## |
|
## asterisk.spec -- OpenPKG RPM Package Specification |
|
## Copyright (c) 2000-2006 OpenPKG Foundation e.V. <http://openpkg.net/> |
|
## Copyright (c) 2000-2006 Ralf S. Engelschall <http://engelschall.com/> |
|
## |
|
## Permission to use, copy, modify, and distribute this software for |
|
## any purpose with or without fee is hereby granted, provided that |
|
## the above copyright notice and this permission notice appear in all |
|
## copies. |
|
## |
|
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
|
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
|
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
|
## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
|
## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
## SUCH DAMAGE. |
|
## |
|
|
|
# package version |
|
%define V_asterisk 1.2.12.1 |
|
%define V_asterisk_addons 1.2.4 |
|
%define V_asterisk_sounds 1.2.1 |
|
%define V_app_conference 20051216 |
|
%define V_asterisk_perl 0.09 |
|
|
|
# package information |
|
Name: asterisk |
|
Summary: Private Branch Exchange (PBX) for VoIP |
|
URL: http://www.asterisk.org/ |
|
Vendor: Mark Spencer et al. |
|
Packager: OpenPKG Foundation e.V. |
|
Distribution: OpenPKG Community |
|
Class: EVAL |
|
Group: VoIP |
|
License: GPL |
|
Version: %{V_asterisk} |
|
Release: 20061013 |
|
|
|
# package options |
|
%option with_zaptel no |
|
|
|
# list of sources |
|
Source0: ftp://ftp.digium.com/pub/asterisk/releases/asterisk-%{V_asterisk}.tar.gz |
|
Source1: ftp://ftp.digium.com/pub/asterisk/releases/asterisk-addons-%{V_asterisk_addons}.tar.gz |
|
Source2: ftp://ftp.digium.com/pub/asterisk/releases/asterisk-sounds-%{V_asterisk_sounds}.tar.gz |
|
Source3: ftp://ftp.openpkg.org/sources/CPY/VERSIONED/asterisk/app_conference-%{V_app_conference}.tar.gz |
|
Source4: http://asterisk.gnuinter.net/files/asterisk-perl-%{V_asterisk_perl}.tar.gz |
|
Source5: asterisk.txt |
|
Source6: rc.asterisk |
|
Patch0: asterisk.patch |
|
|
|
# build information |
|
Prefix: %{l_prefix} |
|
BuildRoot: %{l_buildroot} |
|
BuildPreReq: OpenPKG, openpkg >= 20040130, bison, gcc, make |
|
PreReq: OpenPKG, openpkg >= 20040130, mpg123 |
|
BuildPreReq: zlib, curl, openssl, ncurses, speex |
|
PreReq: zlib, curl, openssl, ncurses, speex |
|
BuildPreReq: perl, perl-openpkg |
|
PreReq: perl |
|
AutoReq: no |
|
AutoReqProv: no |
|
|
|
%description |
|
Asterisk is a complete Private Branch Exchange (PBX) in software. |
|
It provides all of the features you would expect from a PBX and |
|
more. Asterisk does Voice over IP (VoIP) in many protocols. Asterisk |
|
provides Voicemail services with Directory, Call Conferencing, |
|
Interactive Voice Response and Call Queuing. It has support for |
|
three-way calling, caller ID services, ADSI, SIP, etc. Asterisk |
|
needs no additional hardware for VoIP. |
|
|
|
NOTICE: This OpenPKG packaging of Asterisk is special according to |
|
the following aspects: 1. for full portability this package does |
|
NOT include Asterisk support for any telephony hardware, 2. this |
|
package uses a stripped down default configuration which provides |
|
an out-of-the-box VoIP configuration for a small organisation, |
|
3. this package includes the add-on Asterisk application module |
|
"app_conference" for hardware-timer independent conferencing, and 4. |
|
this package includes the Perl Asterisk::AGI module. |
|
|
|
%track |
|
prog asterisk = { |
|
version = %{V_asterisk} |
|
url = http://www.asterisk.org/download |
|
regex = asterisk-(\d+\.\d+(\.\d+)+)\.tar\.gz |
|
} |
|
prog asterisk:addons = { |
|
version = %{V_asterisk_addons} |
|
url = http://www.asterisk.org/download |
|
regex = asterisk-addons-(\d+\.\d+(\.\d+)+)\.tar\.gz |
|
} |
|
prog asterisk:sounds = { |
|
version = %{V_asterisk_sounds} |
|
url = http://www.asterisk.org/download |
|
regex = asterisk-sounds-(\d+\.\d+(\.\d+)+)\.tar\.gz |
|
} |
|
prog asterisk:agi = { |
|
version = %{V_asterisk_perl} |
|
url = http://asterisk.gnuinter.net/files/ |
|
regex = asterisk-perl-(__VER__)\.tar\.gz |
|
} |
|
|
|
%prep |
|
%setup -q |
|
%setup -q -D -T -a 1 |
|
%setup -q -D -T -a 2 |
|
%setup -q -D -T -a 3 |
|
%setup -q -D -T -a 4 |
|
%patch -p0 |
|
%{l_shtool} subst \ |
|
-e 's;/usr/local/bin/mpg123;%{l_prefix}/bin/mpg123;' \ |
|
-e 's;/usr/bin/mpg123;%{l_prefix}/bin/mpg123;' \ |
|
res/res_musiconhold.c |
|
%{l_shtool} subst \ |
|
-e 's;/usr/local/bin/mpg123;%{l_prefix}/bin/mpg123;' \ |
|
-e 's;/usr/bin/mpg123;%{l_prefix}/bin/mpg123;' \ |
|
apps/app_mp3.c |
|
|
|
%build |
|
# sanity check |
|
%if "%{with_zaptel}" == "yes" |
|
case "%{l_platform -t}" in |
|
*-linux* ) |
|
if [ ! -f /usr/include/linux/zaptel.h ]; then |
|
echo "option \"with_zaptel\" requires Zaptel Linux drivers installed" 1>&2; exit 1 |
|
fi |
|
;; |
|
*-freebsd* ) |
|
if [ ! -f /usr/local/include/zaptel.h ]; then |
|
echo "option \"with_zaptel\" requires Zaptel FreeBSD drivers installed" 1>&2; exit 1 |
|
fi |
|
;; |
|
* ) echo "option \"with_zaptel\" supported under Linux and FreeBSD only" 1>&2; exit 1 ;; |
|
esac |
|
%endif |
|
|
|
# build program |
|
%{l_make} %{l_mflags} \ |
|
%if "%{with_zaptel}" == "no" |
|
WITHOUT_ZAPTEL=1 \ |
|
%endif |
|
CC="%{l_cc}" \ |
|
INSTALL_PREFIX=%{l_prefix} |
|
|
|
# build addon modules |
|
( cd app_conference |
|
%{l_make} %{l_mflags} \ |
|
INSTALL_PREFIX=%{l_prefix} \ |
|
) || exit $? |
|
|
|
# build Perl API |
|
%{l_prefix}/bin/perl-openpkg prepare |
|
%{l_prefix}/bin/perl-openpkg -d asterisk-perl-%{V_asterisk_perl} configure build |
|
|
|
%install |
|
# install program |
|
rm -rf $RPM_BUILD_ROOT |
|
%{l_make} %{l_mflags} install \ |
|
DESTDIR=$RPM_BUILD_ROOT \ |
|
INSTALL_PREFIX=%{l_prefix} |
|
|
|
# install additional sounds |
|
( cd asterisk-sounds-%{V_asterisk_sounds} |
|
%{l_make} %{l_mflags} install \ |
|
DESTDIR=$RPM_BUILD_ROOT \ |
|
ASTVARLIBDIR=%{l_prefix}/share/asterisk |
|
) || exit $? |
|
%{l_shtool} install -c -m 644 %{l_value -s -a} \ |
|
sounds/*.mp3 $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/mohmp3/ |
|
|
|
# install addon modules |
|
( cd app_conference |
|
%{l_make} %{l_mflags} install \ |
|
INSTALL_PREFIX=$RPM_BUILD_ROOT%{l_prefix} |
|
) || exit $? |
|
|
|
# install Perl API |
|
%{l_prefix}/bin/perl-openpkg -d asterisk-perl-%{V_asterisk_perl} install |
|
%{l_shtool} install -c -m 644 %{l_value -s -a} \ |
|
-e 's;/usr/bin/perl;%{l_prefix}/bin/perl;' \ |
|
asterisk-perl-%{V_asterisk_perl}/examples/* \ |
|
$RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/agi-bin/ |
|
%{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup |
|
|
|
# strip down installation |
|
rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/autosupport >/dev/null 2>&1 || true |
|
rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/safe_asterisk >/dev/null 2>&1 || true |
|
rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/autosupport.8 >/dev/null 2>&1 || true |
|
rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/safe_asterisk.8 >/dev/null 2>&1 || true |
|
rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/firmware >/dev/null 2>&1 || true |
|
rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/images >/dev/null 2>&1 || true |
|
|
|
# post-adjust installation |
|
strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true |
|
for bin in $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/agi-bin/*.*; do |
|
mv $bin `echo $bin | sed -e 's;\.[^.]*$;;'` |
|
done |
|
|
|
# install default configuration |
|
for name in `grep "^<file" %{SOURCE asterisk.txt} | sed -e 's;^.*name=";;' -e 's;".*$;;'`; do |
|
%if "%{with_zaptel}" == "no" |
|
[ ".$name" = ".zapata.conf" ] && continue |
|
%endif |
|
(echo ""; cat %{SOURCE asterisk.txt}; echo "") |\ |
|
sed -e "1,/^<file name=\"$name\">/d" -e "/<\/file>/,\$d" >$name |
|
%{l_shtool} install -c -m 644 %{l_value -s -a} \ |
|
$name $RPM_BUILD_ROOT%{l_prefix}/etc/asterisk/ |
|
done |
|
|
|
# install run-command script |
|
%{l_shtool} mkdir -f -p -m 755 \ |
|
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d |
|
%{l_shtool} install -c -m 755 %{l_value -s -a} \ |
|
%{SOURCE rc.asterisk} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ |
|
|
|
# determine installation files |
|
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ |
|
%{l_files_std} `cat perl-openpkg-files` \ |
|
'%config %attr(640,%{l_mgrp},%{l_rgrp}) %{l_prefix}/etc/asterisk/*' \ |
|
'%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/asterisk/*' \ |
|
'%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/asterisk/*/*' |
|
|
|
%files -f files |
|
|
|
%clean |
|
rm -rf $RPM_BUILD_ROOT |
|
|
|
%post |
|
# after upgrade, restart service |
|
[ $1 -eq 2 ] || exit 0 |
|
eval `%{l_rc} asterisk status 2>/dev/null` |
|
[ ".$asterisk_active" = .yes ] && %{l_rc} asterisk restart |
|
exit 0 |
|
|
|
%preun |
|
# before erase, stop service and remove log files |
|
[ $1 -eq 0 ] || exit 0 |
|
%{l_rc} asterisk stop 2>/dev/null |
|
rm -f $RPM_INSTALL_PREFIX/var/asterisk/log/* >/dev/null 2>&1 || true |
|
rm -f $RPM_INSTALL_PREFIX/var/asterisk/run/* >/dev/null 2>&1 || true |
|
rm -f $RPM_INSTALL_PREFIX/var/asterisk/spool/*/* >/dev/null 2>&1 || true |
|
rm -f $RPM_INSTALL_PREFIX/var/asterisk/spool/astdb >/dev/null 2>&1 || true |
|
exit 0 |
|
|
|
|