<commit_before># -*- rpm-spec -*-

%define _prefix    @CMAKE_INSTALL_PREFIX@
%define pkg_prefix @BC_PACKAGE_NAME_PREFIX@
%define package_name @CPACK_PACKAGE_NAME@-${FULL_VERSION}

# re-define some directories for older RPMBuild versions which don't. This messes up the doc/ dir
# taken from https://fedoraproject.org/wiki/Packaging:RPMMacros?rd=Packaging/RPMMacros
%define _datarootdir       %{_prefix}/share
%define _datadir           %{_datarootdir}
%define _docdir            %{_datadir}/doc

%define epoch     1

Summary:       SIP proxy with media capabilities
Name:          @CPACK_PACKAGE_NAME@
Version:       ${RPM_VERSION}
Release:       ${RPM_RELEASE}%{?dist}

#to be alined with redhat which changed epoc to 1 for an unknown reason
Epoch:         %{epoch}
License:       AGPLv3
Group:         Applications/Communications
URL:           http://flexisip.org
Source0:       %{package_name}.tar.gz
BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-buildroot

Requires:      bash >= 2.0
Requires:      at >= 3.1.10
Requires:      %{pkg_prefix}sofia-sip >= 1.13

%if @ENABLE_PROTOBUF@
Requires: protobuf >= 2.3.0
#Requires: protobuf-c >= 0.15
#BuildRequires: protobuf-c-devel >= 0.15
BuildRequires: protobuf-compiler >= 2.3.0
%endif

%if @ENABLE_REDIS@
Requires: %{pkg_prefix}hiredis-devel >= 0.13
%endif

%if @ENABLE_SNMP@
Requires: net-snmp-libs
Requires: net-snmp-devel
%endif

%if @ENABLE_SOCI@
Requires: %{pkg_prefix}soci
Requires: %{pkg_prefix}soci-mysql-devel
%endif

%if @ENABLE_TRANSCODER@
Requires: %{pkg_prefix}mediastreamer
%endif

%if @ENABLE_PRESENCE@
Requires: %{pkg_prefix}belle-sip
%endif

%if @ENABLE_CONFERENCE@
Requires: %{pkg_prefix}liblinphone
%endif

%{systemd_requires}

%if 0%{?rhel} && 0%{?rhel} <= 7
%global cmake_name cmake3
%define ctest_name ctest3
%else
%global cmake_name cmake
%define ctest_name ctest
%endif

%global flexisip_services %(printf 'flexisip-proxy.service'; if [ @ENABLE_PRESENCE@ -eq 1 ]; then printf ' flexisip-presence.service'; fi; if [ @ENABLE_CONFERENCE@ -eq 1 ]; then printf ' flexisip-conference.service\n'; fi)

%description
Extensible SIP proxy with media capabilities. Designed for robustness and easy of use.

%if @ENABLE_JWE_AUTH_PLUGIN@

%package jwe-auth-plugin
Summary:       JweAuth plugin offers the possibility to use JSON Web Encryption tokens on flexisip
Group:         Security

Requires:      %{name} = %{epoch}:%{version}-%{release}
Requires:      %{pkg_prefix}jose
Requires:      jansson

%description jwe-auth-plugin
JweAuth plugin offers the possibility to use JSON Web Encryption tokens on flexisip.

%endif

%if @ENABLE_EXTERNAL_AUTH_PLUGIN@

%package external-auth-plugin
Summary:       Add the ability to delegate authentication process to an external HTTP server
Group:         Security

Requires:      %{name} = %{epoch}:%{version}-%{release}

%description external-auth-plugin
Add the ability to delegate authentication process to an external HTTP server.

%endif


%prep
%setup -n %{package_name}

%build
%{expand:%%%cmake_name} . -DCMAKE_BUILD_TYPE=@CMAKE_BUILD_TYPE@ -DCMAKE_PREFIX_PATH:PATH=%{_prefix} -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} @RPM_ALL_CMAKE_OPTIONS@


make %{?_smp_mflags}

%install
make install DESTDIR=%{buildroot}

# Mark all libraries as executable because CMake doesn't on
# Debian to be complient with Debian policy. But rpmbuild
# won't strip libraries that aren't marked as executable.
chmod +x `find %{buildroot} *.so.*`

#
# Shouldn't be the role of cmake to install all the following stuff ?
# It is surprising to let the specfile install all these things from the source tree.
#
mkdir -p  $RPM_BUILD_ROOT/etc/flexisip
mkdir -p  $RPM_BUILD_ROOT/%{_docdir}
mkdir -p  $RPM_BUILD_ROOT/%{_localstatedir}/log/flexisip
mkdir -p  $RPM_BUILD_ROOT/%{_localstatedir}/%{_prefix}/log/flexisip

mkdir -p $RPM_BUILD_ROOT/lib/systemd/system
install -p -m 0644 scripts/flexisip-proxy.service $RPM_BUILD_ROOT/lib/systemd/system
install -p -m 0644 scripts/flexisip-proxy\@.service $RPM_BUILD_ROOT/lib/systemd/system
%if @ENABLE_PRESENCE@
install -p -m 0644 scripts/flexisip-presence.service $RPM_BUILD_ROOT/lib/systemd/system
install -p -m 0644 scripts/flexisip-presence\@.service $RPM_BUILD_ROOT/lib/systemd/system
%endif
%if @ENABLE_CONFERENCE@
	install -p -m 0644 scripts/flexisip-conference.service $RPM_BUILD_ROOT/lib/systemd/system
	install -p -m 0644 scripts/flexisip-conference\@.service $RPM_BUILD_ROOT/lib/systemd/system
%endif
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
install -p -m 0644 scripts/flexisip-logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d

install -p -m 0744 scripts/flexisip_cli.py $RPM_BUILD_ROOT%{_bindir}
install -p -m 0744 scripts/flexisip_monitor.py $RPM_BUILD_ROOT%{_bindir}

%check
%{ctest_name} -V %{?_smp_mflags}

%clean
rm -rf $RPM_BUILD_ROOT

%post
%systemd_post %flexisip_services

%preun
%systemd_preun %flexisip_services

%postun
%systemd_postun_with_restart %flexisip_services

%files
%defattr(-,root,root,-)
%docdir %{_docdir}
%{_bindir}/*
%{_libdir}/*.so
%{_datarootdir}/*
%dir %{_includedir}/flexisip
%{_includedir}/flexisip/*.hh
%{_includedir}/flexisip/*.h
%{_includedir}/flexisip/*.cc
%{_localstatedir}/*

%config(noreplace) /lib/systemd/system/flexisip-proxy.service
%config(noreplace) /lib/systemd/system/flexisip-proxy@.service

%if @ENABLE_PRESENCE@
	%config(noreplace) /lib/systemd/system/flexisip-presence.service
	%config(noreplace) /lib/systemd/system/flexisip-presence@.service
%endif

%if @ENABLE_CONFERENCE@
	%config(noreplace) /lib/systemd/system/flexisip-conference.service
	%config(noreplace) /lib/systemd/system/flexisip-conference@.service
%endif

%{_sysconfdir}/flexisip
%config(noreplace) %{_sysconfdir}/logrotate.d/flexisip-logrotate

%if @ENABLE_JWE_AUTH_PLUGIN@
%files jwe-auth-plugin
%defattr(-,root,root,-)
%{_libdir}/flexisip/plugins/libjweauth.so
%{_libdir}/flexisip/plugins/libjweauth.so.*
%endif

%if @ENABLE_EXTERNAL_AUTH_PLUGIN@
%files external-auth-plugin
%defattr(-,root,root,-)
%{_libdir}/flexisip/plugins/libexternal-auth.so
%{_libdir}/flexisip/plugins/libexternal-auth.so.*
%endif

# This is for Debian build where debug_package has to be manually specified whereas it mustn't on Centos
%define custom_debug_package %{!?_enable_debug_packages:%debug_package}%{?_enable_debug_package:%{nil}}
%custom_debug_package

%changelog

* Wed Jan 16 2019 <NAME> <<EMAIL>>
- Added include directory with flexisip header files

* Tue Nov 27 2018 ronan.abhamon <<EMAIL>>
- Do not set CMAKE_INSTALL_LIBDIR and never with _libdir!

* Mon Nov 05 2018 <NAME> <<EMAIL>>
- Add share directory

* Wed Oct 31 2018 ronan.abhamon <<EMAIL>>
- Use epoch in JweAuth plugin requires

* Wed Jun 13 2018 ronan.abhamon <<EMAIL>>
- Add JweAuth plugin

* Tue Aug 29  2017 <NAME> <<EMAIL>>
- cmake port

* Fri Dec 02 2016 <NAME> <<EMAIL>>
- Add init scripts for flexisip-presence

* Thu Jul 28 2016 <NAME> <<EMAIL>>
- Add systemd unit files

* Mon Feb 08 2016 <NAME> <<EMAIL>>
- Add soci option

* Wed Nov 04 2015 <NAME> <<EMAIL>>
- Add option to disable odb

* Tue Oct 14 2014 <NAME> <<EMAIL>>
- Add /opt packaging possibility

* Wed Feb 15 2012 <NAME> <<EMAIL>>
- Force use of redhat init script

* Tue Oct 19 2010 <NAME> <<EMAIL>>
- Initial specfile for first prototype release
<commit_msg>RPM: make conference server to be restart on package update<commit_after># -*- rpm-spec -*-

%define _prefix    @CMAKE_INSTALL_PREFIX@
%define pkg_prefix @BC_PACKAGE_NAME_PREFIX@
%define package_name @CPACK_PACKAGE_NAME@-${FULL_VERSION}

# re-define some directories for older RPMBuild versions which don't. This messes up the doc/ dir
# taken from https://fedoraproject.org/wiki/Packaging:RPMMacros?rd=Packaging/RPMMacros
%define _datarootdir       %{_prefix}/share
%define _datadir           %{_datarootdir}
%define _docdir            %{_datadir}/doc

%define epoch     1

Summary:       SIP proxy with media capabilities
Name:          @CPACK_PACKAGE_NAME@
Version:       ${RPM_VERSION}
Release:       ${RPM_RELEASE}%{?dist}

#to be alined with redhat which changed epoc to 1 for an unknown reason
Epoch:         %{epoch}
License:       AGPLv3
Group:         Applications/Communications
URL:           http://flexisip.org
Source0:       %{package_name}.tar.gz
BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-buildroot

Requires:      bash >= 2.0
Requires:      at >= 3.1.10
Requires:      %{pkg_prefix}sofia-sip >= 1.13

%if @ENABLE_PROTOBUF@
Requires: protobuf >= 2.3.0
#Requires: protobuf-c >= 0.15
#BuildRequires: protobuf-c-devel >= 0.15
BuildRequires: protobuf-compiler >= 2.3.0
%endif

%if @ENABLE_REDIS@
Requires: %{pkg_prefix}hiredis-devel >= 0.13
%endif

%if @ENABLE_SNMP@
Requires: net-snmp-libs
Requires: net-snmp-devel
%endif

%if @ENABLE_SOCI@
Requires: %{pkg_prefix}soci
Requires: %{pkg_prefix}soci-mysql-devel
%endif

%if @ENABLE_TRANSCODER@
Requires: %{pkg_prefix}mediastreamer
%endif

%if @ENABLE_PRESENCE@
Requires: %{pkg_prefix}belle-sip
%endif

%if @ENABLE_CONFERENCE@
Requires: %{pkg_prefix}liblinphone
%endif

%{systemd_requires}

%if 0%{?rhel} && 0%{?rhel} <= 7
%global cmake_name cmake3
%define ctest_name ctest3
%else
%global cmake_name cmake
%define ctest_name ctest
%endif

%global flexisip_services %(printf 'flexisip-proxy.service'; if [ @ENABLE_PRESENCE@ -eq 1 ]; then printf ' flexisip-presence.service'; fi; if [ @ENABLE_CONFERENCE@ -eq 1 ]; then printf ' flexisip-conference.service'; fi)

%description
Extensible SIP proxy with media capabilities. Designed for robustness and easy of use.

%if @ENABLE_JWE_AUTH_PLUGIN@

%package jwe-auth-plugin
Summary:       JweAuth plugin offers the possibility to use JSON Web Encryption tokens on flexisip
Group:         Security

Requires:      %{name} = %{epoch}:%{version}-%{release}
Requires:      %{pkg_prefix}jose
Requires:      jansson

%description jwe-auth-plugin
JweAuth plugin offers the possibility to use JSON Web Encryption tokens on flexisip.

%endif

%if @ENABLE_EXTERNAL_AUTH_PLUGIN@

%package external-auth-plugin
Summary:       Add the ability to delegate authentication process to an external HTTP server
Group:         Security

Requires:      %{name} = %{epoch}:%{version}-%{release}

%description external-auth-plugin
Add the ability to delegate authentication process to an external HTTP server.

%endif


%prep
%setup -n %{package_name}

%build
%{expand:%%%cmake_name} . -DCMAKE_BUILD_TYPE=@CMAKE_BUILD_TYPE@ -DCMAKE_PREFIX_PATH:PATH=%{_prefix} -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} @RPM_ALL_CMAKE_OPTIONS@


make %{?_smp_mflags}

%install
make install DESTDIR=%{buildroot}

# Mark all libraries as executable because CMake doesn't on
# Debian to be complient with Debian policy. But rpmbuild
# won't strip libraries that aren't marked as executable.
chmod +x `find %{buildroot} *.so.*`

#
# Shouldn't be the role of cmake to install all the following stuff ?
# It is surprising to let the specfile install all these things from the source tree.
#
mkdir -p  $RPM_BUILD_ROOT/etc/flexisip
mkdir -p  $RPM_BUILD_ROOT/%{_docdir}
mkdir -p  $RPM_BUILD_ROOT/%{_localstatedir}/log/flexisip
mkdir -p  $RPM_BUILD_ROOT/%{_localstatedir}/%{_prefix}/log/flexisip

mkdir -p $RPM_BUILD_ROOT/lib/systemd/system
install -p -m 0644 scripts/flexisip-proxy.service $RPM_BUILD_ROOT/lib/systemd/system
install -p -m 0644 scripts/flexisip-proxy\@.service $RPM_BUILD_ROOT/lib/systemd/system
%if @ENABLE_PRESENCE@
install -p -m 0644 scripts/flexisip-presence.service $RPM_BUILD_ROOT/lib/systemd/system
install -p -m 0644 scripts/flexisip-presence\@.service $RPM_BUILD_ROOT/lib/systemd/system
%endif
%if @ENABLE_CONFERENCE@
	install -p -m 0644 scripts/flexisip-conference.service $RPM_BUILD_ROOT/lib/systemd/system
	install -p -m 0644 scripts/flexisip-conference\@.service $RPM_BUILD_ROOT/lib/systemd/system
%endif
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
install -p -m 0644 scripts/flexisip-logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d

install -p -m 0744 scripts/flexisip_cli.py $RPM_BUILD_ROOT%{_bindir}
install -p -m 0744 scripts/flexisip_monitor.py $RPM_BUILD_ROOT%{_bindir}

%check
%{ctest_name} -V %{?_smp_mflags}

%clean
rm -rf $RPM_BUILD_ROOT

%post
%systemd_post %flexisip_services

%preun
%systemd_preun %flexisip_services

%postun
%systemd_postun_with_restart %flexisip_services

%files
%defattr(-,root,root,-)
%docdir %{_docdir}
%{_bindir}/*
%{_libdir}/*.so
%{_datarootdir}/*
%dir %{_includedir}/flexisip
%{_includedir}/flexisip/*.hh
%{_includedir}/flexisip/*.h
%{_includedir}/flexisip/*.cc
%{_localstatedir}/*

%config(noreplace) /lib/systemd/system/flexisip-proxy.service
%config(noreplace) /lib/systemd/system/flexisip-proxy@.service

%if @ENABLE_PRESENCE@
	%config(noreplace) /lib/systemd/system/flexisip-presence.service
	%config(noreplace) /lib/systemd/system/flexisip-presence@.service
%endif

%if @ENABLE_CONFERENCE@
	%config(noreplace) /lib/systemd/system/flexisip-conference.service
	%config(noreplace) /lib/systemd/system/flexisip-conference@.service
%endif

%{_sysconfdir}/flexisip
%config(noreplace) %{_sysconfdir}/logrotate.d/flexisip-logrotate

%if @ENABLE_JWE_AUTH_PLUGIN@
%files jwe-auth-plugin
%defattr(-,root,root,-)
%{_libdir}/flexisip/plugins/libjweauth.so
%{_libdir}/flexisip/plugins/libjweauth.so.*
%endif

%if @ENABLE_EXTERNAL_AUTH_PLUGIN@
%files external-auth-plugin
%defattr(-,root,root,-)
%{_libdir}/flexisip/plugins/libexternal-auth.so
%{_libdir}/flexisip/plugins/libexternal-auth.so.*
%endif

# This is for Debian build where debug_package has to be manually specified whereas it mustn't on Centos
%define custom_debug_package %{!?_enable_debug_packages:%debug_package}%{?_enable_debug_package:%{nil}}
%custom_debug_package

%changelog

* Wed Jan 16 2019 <NAME> <<EMAIL>>
- Added include directory with flexisip header files

* Tue Nov 27 2018 ronan.abhamon <<EMAIL>>
- Do not set CMAKE_INSTALL_LIBDIR and never with _libdir!

* Mon Nov 05 2018 <NAME> <<EMAIL>>
- Add share directory

* Wed Oct 31 2018 ronan.abhamon <<EMAIL>>
- Use epoch in JweAuth plugin requires

* Wed Jun 13 2018 ronan.abhamon <<EMAIL>>
- Add JweAuth plugin

* Tue Aug 29  2017 <NAME> <<EMAIL>>
- cmake port

* Fri Dec 02 2016 <NAME> <<EMAIL>>
- Add init scripts for flexisip-presence

* Thu Jul 28 2016 <NAME> <<EMAIL>>
- Add systemd unit files

* Mon Feb 08 2016 <NAME> <<EMAIL>>
- Add soci option

* Wed Nov 04 2015 <NAME> <<EMAIL>>
- Add option to disable odb

* Tue Oct 14 2014 <NAME> <<EMAIL>>
- Add /opt packaging possibility

* Wed Feb 15 2012 <NAME> <<EMAIL>>
- Force use of redhat init script

* Tue Oct 19 2010 <NAME> <<EMAIL>>
- Initial specfile for first prototype release

{'fraction_non_alphanumeric': 0.1215492377420684, 'fraction_numerical': 0.02046422194753468, 'mean_word_length': 4.912708079577751, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 91, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '96943', 'n_tokens_mistral': 5688, 'n_tokens_neox': 5271, 'n_words': 1313}