File asterisk.spec of Package asterisk

Name: asterisk
Version: 16.6.2
Release: 1
Summary: Asterisk PBX
Group: System/Base
License: GPL
URL: http://www.asterisk.org
Source0: %{name}-%{version}.tar.gz
Source2: asterisk.service
Source3: https://raw.githubusercontent.com/asterisk/third-party/master/pjproject/2.9/pjproject-2.9.tar.bz2
Source4: https://raw.githubusercontent.com/asterisk/third-party/master/jansson/2.12/jansson-2.12.tar.bz2
Source5: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-gsm-1.6.1.tar.gz
Source6: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-gsm-1.6.1.tar.gz.sha1
Source7: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-moh-opsound-wav-2.03.tar.gz
Source8: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-moh-opsound-wav-2.03.tar.gz.sha1
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: fdupes
BuildRequires: ncurses-devel
BuildRequires: libgsm-devel
BuildRequires: gcc-c++
BuildRequires: openldap2-devel
BuildRequires: net-snmp-devel
BuildRequires: libedit-devel
BuildRequires: pkgconfig(alsa)
BuildRequires: pkgconfig(bluez)
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(libical)
BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(libcrypto)
BuildRequires: pkgconfig(libusb)
BuildRequires: pkgconfig(libnewt)
BuildRequires: pkgconfig(neon)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(lua)
BuildRequires: pkgconfig(uuid)
BuildRequires: pkgconfig(vorbis)
BuildRequires: pkgconfig(ogg)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(speex)
BuildRequires: pkgconfig(speexdsp)
BuildRequires: pkgconfig(spandsp)
BuildRequires: pkgconfig(gmime-2.6)
BuildRequires: pkgconfig(jansson)
BuildRequires: pkgconfig(libsrtp)
BuildRequires: pkgconfig(gtk+-2.0)
BuildRequires: wget
Requires(pre): /usr/sbin/useradd
Requires(pre): /usr/sbin/groupadd

%description
%{summary}.

%files
%defattr(-,root,root,-)
%{_unitdir}/%{name}*.service
%{_sbindir}/*
%dir %{_libdir}/asterisk
%dir %{_libdir}/asterisk/modules
%{_libdir}/asterisk/modules/*.so
%{_libdir}/*.so.*
/var/lib/asterisk
%{_datadir}/man/man8/*
%attr(0750,asterisk,asterisk) %dir %{_localstatedir}/lib/%{name}
%attr(0750,asterisk,asterisk) %dir %{_localstatedir}/spool/%{name}
%attr(0750,asterisk,asterisk) %dir %{_localstatedir}/log/%{name}
%{_localstatedir}/spool/%{name}/*


%package config
Summary: Configuration files for %{name}
Group: System/Base
Requires: %{name} = %{version}-%{release}

%description config
%{summary}.

%files config
%defattr(-,root,root,-)
%dir %{_sysconfdir}/asterisk
%config(noreplace) %{_sysconfdir}/asterisk/*


%package devel
Summary: Development files for %{name}
Group: Development/Libraries/Other
Requires: %{name} = %{version}-%{release}

%description devel
%{summary}.

%files devel
%defattr(-,root,root,-)
%{_includedir}/asterisk.h
%{_includedir}/asterisk/
%{_libdir}/*.so


%prep
%setup -q
mkdir cache
cp -v %{SOURCE3} %{SOURCE4} %{SOURCE5} %{SOURCE6} %{SOURCE7} %{SOURCE8} cache/

# don't download pjproject
%build
./bootstrap.sh
export NOISY_BUILD=yes
%configure --with-jansson-bundled --with-pjproject-bundled --with-download-cache=`pwd`/cache
sed -i 's/^NATIVE_ARCH=$/NATIVE_ARCH=0/' build_tools/menuselect-deps
cat build_tools/menuselect-deps
make menuselect.makeopts
./menuselect/menuselect --list-options
menuselect/menuselect \
    --enable chan_ooh323 \
    --enable chan_mgcp \
    --enable app_meetme \
    --enable app_mysql \
    --enable res_config_mysql \
    --enable res_statsd \
    --enable cdr_mysql \
    --enable aelparse \
    --enable astman \
    --enable check_expr \
    --enable check_expr2 \
    --enable conf2ael \
    --enable muted \
    --enable smsq \
    --enable stereorize \
    --enable streamplayer \
    --disable BUILD_NATIVE \
    menuselect.makeopts
make %{?_smp_mflags}


%install
rm -rf %{buildroot}
make DESTDIR=%{buildroot} install
make DESTDIR=%{buildroot} samples
install -d -m 755 %{buildroot}/%{_localstatedir}/lib/%{name}
install -d -m 755 %{buildroot}/%{_localstatedir}/spool/%{name}
install -d -m 755 %{buildroot}/%{_localstatedir}/log/%{name}
install -d -m 755 %{buildroot}/%{_localstatedir}/run/%{name}
%fdupes %{buildroot}/%{_libdir}
%fdupes %{buildroot}/%{_includedir}
%fdupes %{buildroot}/var/lib/asterisk
install -D -m644 %{SOURCE2} %{buildroot}/%{_unitdir}/asterisk.service
install -D -m644 menuselect.makeopts %{buildroot}/%{_sysconfdir}/%{name}/
cat menuselect.makeopts
sed -i 's,/usr/bin/env bash,/bin/bash,' %{buildroot}/%{_localstatedir}/lib/%{name}/scripts/ast_*
sed -i 's,/usr/bin/env python,/usr/bin/python,' %{buildroot}/%{_localstatedir}/lib/%{name}/scripts/*.py

%post
/sbin/ldconfig ||:
mkdir -p -m 0750 %{_localstatedir}/run/%{name}
chown asterisk:asterisk %{_localstatedir}/run/%{name}


%postun -p /sbin/ldconfig

%pre
/usr/sbin/groupadd -f -r asterisk||:
/usr/sbin/useradd -s /bin/nologin -M -r -d /var/lib/asterisk -c "Asterisk" -g asterisk asterisk ||: