File coturn.spec of Package coturn
#
# spec file for package coturn
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%if 0%{?suse_version} >= 1500
%define use_firewalld 1
%else
%define use_firewalld 0
%endif
%define _lto_cflags %{nil}
Name: coturn
Version: 4.5.1.1
Release: 0
Summary: TURN and STUN server for VoIP
License: BSD-3-Clause and MIT
Group: Productivity/Networking/Talk/Servers
Url: https://github.com/coturn/coturn/
Source: %{name}-%{version}.tar.gz
Source1: turnserver.service
Source2: turnserver.tmpfiles
Source3: turnserver.sysconfig
Source4: turnserver.firewalld
Source5: turnserver.sysuser
Source6: turnserver.logrotate
Source10: coturn-rpmlintrc
Patch: coturn-fix_missing-call-to-setgroups-before-setuid.patch
BuildRequires: pkgconfig(libssl) >= 1.0.2
BuildRequires: pkgconfig(libevent) >= 2.0
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(libpq)
BuildRequires: pkgconfig(hiredis)
BuildRequires: libmysqld-devel
BuildRequires: sqlite3
BuildRequires: systemd
%if 0%{?suse_version}
Requires(pre): %fillup_prereq
Requires(pre): pwdutils
Recommends: logrotate
BuildRequires: fdupes
%endif
BuildRequires: sysuser-tools
#Requires(pre): user(turnserver)
#Requires(pre): group(turnserver)
%if %{use_firewalld}
BuildRequires: firewall-macros
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
STUN (Session Traversal Utilities for NAT) and TURN (Traversal Using Relays
around NAT) are protocols that can be used to provide NAT traversal for VoIP
and WebRTC.
It can be used as a general-purpose network traffic TURN server and gateway,
too. On-line management interface (over telnet or over HTTPS) for the TURN
server is available. The implementation also includes some extra experimental
features.
%package -n system-user-turnserver
Summary: System user and group turnserver
%sysusers_requires
%description -n system-user-turnserver
This package creates the system user and group named turnserver.
%package devel
Summary: Development files for %{name}
Group: Development/Libraries/C and C++
Requires: %{name} >= %{version}
Requires: libevent-devel
Requires: hiredis-devel
Requires: sqlite-devel >= 3.0
Requires: pkgconfig(libssl)
Requires: libmysqld-devel
Requires: pkgconfig(libpq)
%description devel
This package contains header files needed to develop applications using
coturn.
%prep
%setup -q
%patch -p1
%build
%sysusers_generate_pre %{SOURCE5} turnserver
%configure \
--mandir='%{_datadir}' \
--sysconfdir='%{_sysconfdir}/turnserver' \
--docsdir='%{_defaultdocdir}/%{name}/doc' \
--examplesdir='%{_defaultdocdir}/%{name}/examples' \
--schemadir='%{_defaultdocdir}/%{name}/schema' \
--turndbdir='%{_localstatedir}/lib/turnserver' \
--disable-rpath
make %{?_smp_mflags}
%install
%make_install
mkdir -p %{buildroot}/{var/log/turnserver,%{_sysconfdir}/turnserver,var/lib/turnserver,run/turnserver} %{buildroot}%{_sbindir}
sed \
"s|^#log-file=.*|log-file=\/var\/log\/turnserver\/turn.log|; \
s|^#pidfile=.*|pidfile=\/run\/turnserver\/turnserver.pid|; \
s|^#no-stdout-log|no-stdout-log|; \
s|^#userdb|userdb|; \
s|\/var\/db\/turndb|%{_localstatedir}\/lib\/turnserver/turndb|" \
%{buildroot}%{_sysconfdir}/turnserver/turnserver.conf.default > %{buildroot}%{_sysconfdir}/turnserver/turnserver.conf
chmod -x %{buildroot}%{_sysconfdir}/turnserver/* %{buildroot}%{_defaultdocdir}/%{name}/schema/*
install -D -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/turnserver.service
install -D -m0644 %{SOURCE2} %{buildroot}%{_prefix}/lib/tmpfiles.d/turnserver.conf
install -D -m0644 %{SOURCE3} %{buildroot}%{_fillupdir}/sysconfig.turnserver
install -D -m0644 %{SOURCE6} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
%if %{use_firewalld}
install -D -m0644 %{SOURCE4} %{buildroot}%{_libexecdir}/firewalld/services/turnserver.xml
%endif
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcturnserver
%fdupes -s %{buildroot}/%{_mandir}
%fdupes %{buildroot}/%{_prefix}
%check
make check
%pre -n system-user-turnserver -f turnserver.pre
%pre
%service_add_pre turnserver.service
%post
getent group turnserver >/dev/null 2>&1 || /usr/sbin/groupadd -r turnserver 2>/dev/null || :
getent passwd turnserver >/dev/null 2>&1 || /usr/sbin/useradd -r -g turnserver -d /var/lib/turnserver -s /bin/false -c "TurnServer user" turnserver 2>/dev/null || :
%service_add_post turnserver.service
systemd-tmpfiles --create %{_prefix}/lib/tmpfiles.d/turnserver.conf
%{fillup_only -n turnserver}
%if %{use_firewalld}
%firewalld_reload
%endif
%preun
%service_del_preun turnserver.service
%postun
%service_del_postun turnserver.service
%files
%defattr(0644,root,root,0755)
%license LICENSE*
%dir %{_defaultdocdir}/%{name}
%{_defaultdocdir}/%{name}/*
%attr(0755,root,root) %{_bindir}/*
%{_mandir}/man1/*
%{_sbindir}/rcturnserver
%attr(0755,root,root) %{_defaultdocdir}/%{name}/schema/*.sh
%attr(0755,root,root) %{_defaultdocdir}/%{name}/examples/scripts/*.sh
%attr(0755,root,root) %{_defaultdocdir}/%{name}/examples/scripts/*/*.sh
%if %{use_firewalld}
%dir %{_libexecdir}/firewalld
%dir %{_libexecdir}/firewalld/services
%{_libexecdir}/firewalld/services/turnserver.xml
%endif
%attr(0640,root,turnserver) %config(noreplace) %{_sysconfdir}/turnserver/turnserver.conf
%config %{_sysconfdir}/turnserver/turnserver.conf.default
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%dir /var/log/turnserver
%{_fillupdir}/sysconfig.turnserver
%{_unitdir}/turnserver.service
%{_prefix}/lib/tmpfiles.d/turnserver.conf
%dir %{_sysconfdir}/turnserver
#
%defattr(-,turnserver,turnserver,0750)
%dir /var/lib/turnserver
%dir /var/log/turnserver
%ghost %dir /run/turnserver
%config(noreplace) %attr(0640,turnserver,turnserver) %{_localstatedir}/lib/turnserver/turndb
%files -n system-user-turnserver
%defattr(-,root,root)
%dir %attr(0750,turnserver,turnserver) /var/lib/turnserver
%files devel
%defattr(0644,root,root,0755)
%dir %{_includedir}/turn/
%{_includedir}/turn/*
%{_libdir}/libturnclient.a
%changelog