File eturnal.spec of Package eturnal

#
# spec file for package eturnal
#
# Copyright (c) 2013 SUSE LINUX Products 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/
#


%define systemuser _eturnal
%define appdir     /usr/lib/eturnal
%define homedir    /var/lib/eturnal

Name:           eturnal
Version:        1.12.0
Release:        1
Summary:        A modern, straightforward STUN and TURN server
Group:          Productivity/Networking/Talk/Servers
License:        Apache-2.0
URL:            https://eturnal.net/
Source0:        https://eturnal.net/download/eturnal-%{version}.tar.gz
Source1:        eturnalctl
Source99:       eturnal.sysusers
Patch0:         use_distro_path.patch
BuildArch:      noarch
BuildRequires:  sysuser-shadow
BuildRequires:  sysuser-tools
BuildRequires:  pkgconfig(systemd)
%{?systemd_ordering}
%{sysusers_requires}
# for logger
Requires:       util-linux-systemd
Requires(preun):  util-linux-systemd
Requires(postun): util-linux-systemd

BuildRequires:  erlang >= 21
BuildRequires:  erlang-rebar3
%requires_eq    erlang
# from rebar.config
BuildRequires:  erlang-stun-devel >= 1.2.5
%requires_eq    erlang-stun
#
BuildRequires:  erlang-conf-devel >= 0.2.2
%requires_eq    erlang-conf
#
BuildRequires:  erlang-recon-devel >= 2.5.2
%requires_eq    erlang-recon
#
%if %{with influxdb}
BuildRequires:  erlang-influx_udp-devel >= 1.1.2
%requires_eq    erlang-influx_udp
%endif
#/ from rebar.config
Requires:       sudo

%description
eturnal is a modern, straightforward STUN and TURN server with full IPv6
support. For TURN authentication, the mechanism described in the REST API for
Access to TURN Services specification is implemented.

%prep
%autosetup -p 1

%build
rm rebar.lock
SKIP_DEPS=true ./rebar3 as distro release

%sysusers_generate_pre %{SOURCE99} eturnal

%install
export REBAR_DEPS_PREFER_LIBS=1
install -D -m 0644 %{SOURCE99}            %{buildroot}%{_sysusersdir}/eturnal.conf
install -D -m 0755 %{SOURCE1}             %{buildroot}%{_sbindir}/eturnalctl
install -D -m 0755 -d                     %{buildroot}%{appdir}/ %{buildroot}%{_sbindir}
cp -rv                                \
  _build/distro/rel/eturnal/bin/      \
  _build/distro/rel/eturnal/releases/ \
  _build/distro/rel/eturnal/lib/      \
  %{buildroot}%{appdir}/

install -D -m 0644 _build/distro/rel/eturnal/etc/systemd/system/eturnal.service %{buildroot}%{_unitdir}/eturnal.service
install -D -m 0640 _build/distro/rel/eturnal/etc/eturnal.yml                    %{buildroot}%{_sysconfdir}/eturnal.yml
ln -s /usr/sbin/service                   %{buildroot}%{_sbindir}/rc%{name}

install -D -m 0750 -d %{buildroot}%{homedir}

%pre -f %{name}.pre
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service


%files
%doc *.md
%license LICENSE
%config(noreplace) %attr(-,root,%{systemuser}) %{_sysconfdir}/eturnal.yml
%{_sysusersdir}/eturnal.conf
%{_unitdir}/eturnal.service
%{appdir}/
%{_sbindir}/rc%{name}
%{_sbindir}/eturnalctl
%dir %attr(-,%{systemuser},%{systemuser}) %{homedir}

%changelog
openSUSE Build Service is sponsored by