File sonarr.spec of Package sonarr

#
# spec file for package sonarr
#
# Copyright (c) 2018 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/
#


Name:           sonarr
Version:        3.0.6.1196
Release:        0
Summary:        Smart PVR for newsgroup and bittorrent users
License:        GPL-3.0-only
Group:          Productivity/Networking/File-Sharing
URL:            https://sonarr.tv/
Source0:        http://download.sonarr.tv/v3/main/%{version}/Sonarr.main.%{version}.linux.tar.gz
Source2:        sonarr.service
Source3:        sonarr.xml
Source4:        https://raw.githubusercontent.com/Sonarr/Sonarr/develop/README.md
Source98:       https://raw.githubusercontent.com/Sonarr/Sonarr/develop/COPYRIGHT.md
Source99:       https://raw.githubusercontent.com/Sonarr/Sonarr/develop/LICENSE.md
BuildRequires:  firewall-macros
BuildRequires:  fdupes
BuildRequires:  mono-devel
BuildRequires:  mono-addins-msbuild
Requires:       curl
Requires:       libsqlite3-0
Requires:       mediainfo
Requires:       mono-core
Requires(pre):  shadow
AutoReqProv:    no

%description
Sonarr is a PVR for Usenet and BitTorrent users. It can monitor multiple
RSS feeds for new episodes of your favorite shows and will grab, sort and
rename them. It can also be configured to automatically upgrade the quality
of files already downloaded when a better quality format becomes available.

%prep
%setup -q -n Sonarr
cp %{SOURCE4} .
cp %{SOURCE98} .
cp %{SOURCE99} .

%build

%install
mkdir -p %{buildroot}%{_datadir}
tar -xvf %{SOURCE0} -C %{buildroot}%{_datadir}
mv %{buildroot}%{_datadir}/Sonarr %{buildroot}%{_datadir}/sonarr

mkdir -p %{buildroot}%{_unitdir}
install %{SOURCE2} %{buildroot}%{_unitdir}
mkdir -p %{buildroot}/%{_libexecdir}/firewalld/services/
install -D -m 644 %{SOURCE3} %{buildroot}/%{_libexecdir}/firewalld/services/
mkdir -p %{buildroot}%{_sbindir}/
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcsonarr

mkdir -p %{buildroot}%{_localstatedir}/lib/sonarr

%fdupes %{buildroot}%{_datadir}/sonarr

%pre
getent group sonarr >/dev/null || groupadd sonarr
getent passwd sonarr >/dev/null || useradd -g sonarr -m -d %{_localstatedir}/lib/sonarr -c "Sonarr User" -s /sbin/nologin  sonarr
%service_add_pre sonarr.service

%post
%firewalld_reload
%service_add_post sonarr.service

%preun
%stop_on_removal sonarr
%service_del_preun sonarr.service

%postun
%service_del_postun sonarr.service

%files
%{_datadir}/sonarr
%attr(0755,sonarr,sonarr) %{_localstatedir}/lib/sonarr
%dir %{_libexecdir}/firewalld
%dir %{_libexecdir}/firewalld/services
%{_libexecdir}/firewalld/services/sonarr.xml
%{_unitdir}/sonarr.service
%{_sbindir}/rcsonarr

%changelog
openSUSE Build Service is sponsored by