File benno-rest.spec of Package benno-rest

#
# spec file for package benno-rest
#
# Copyright (c) 2012,2013,2017,2018 FSP Computer & Netzwerke, Schotten, 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 to stefan.schaefer@fsproductions.de
#

# norootforbuild

Name:         benno-rest
Version:      2.10.1
Release:      1
Group:        Productivity/Networking/Email/Servers
Summary:      Email Archive - Benno MailArchiv REST interface
License:      AGPL-3.0
Autoreqprov:  on
URL:          http://www.benno-mailarchiv.de
Source:       %{name}-%{version}.tar.bz2
BuildRoot:    %{_tmppath}/%{name}-%{version}-build
PreReq:       /usr/sbin/useradd
BuildRequires: systemd benno-core cron
Requires:     java >= 1.7.0 benno-lib benno-core benno-rest-lib apache-commons-codec log4j
Requires:	  perl(JSON) cron
%if 0%{?suse_version} >= 1315 
Requires: benno-systemd-global
%endif

BuildArch:    noarch
Source1:      README.SUSE
Source2:      benno-rest.init
Source3:      BMA2_Installation.pdf
Source4:      BMA2_Quick-Install.pdf
Source5:      BMA2_RESTAPI.pdf
Source6:      BMA_Migration_v1-v2.pdf
Source8:	  benno-rest-service.conf
Source9:      benno-rest-fsp.service
Source10:	  benno-license-info

Patch1:		  etc-default.patch

%define USRADDBENNO /usr/sbin/useradd -r -g benno -c "Benno MailArchive REST-Daemon User" bennorest 2> /dev/null || :

%description
Benno MailArchiv REST interface core libraries
Benno MailArchiv REST interface core libraries from external sources

Using Benno MailArchiv is not free of charge. It is possible to get a
30 day evaluation license for testing.

For further information about licensing have a look at:
http://www.benno-mailarchiv.de or 
http://www.fsproductions.de (Benno MailArchiv Partner)

Authors:
--------
    Martin Werthmoeller <mw@lw-systems.de>
    Stefan Schaefer <stefan.schaefer@fsproductions.de>

%prep
%setup -n %{name}-%{version}

%patch1 -p1

%build


%install
%{USRADDBENNO}
export NO_BRP_CHECK_BYTECODE_VERSION=true
mkdir -p %{buildroot}
rm -rf install
mv * %{buildroot}
mkdir %{buildroot}%{_defaultdocdir}
mv %{buildroot}/usr/share/doc/%{name} %{buildroot}/%{_defaultdocdir}
%{__cp} %{S:1} %{buildroot}%{_defaultdocdir}/%{name}/README.SUSE
%{__cp} %{S:3} %{buildroot}%{_defaultdocdir}/%{name}/
%{__cp} %{S:4} %{buildroot}%{_defaultdocdir}/%{name}/
%{__cp} %{S:5} %{buildroot}%{_defaultdocdir}/%{name}/
%{__cp} %{S:6} %{buildroot}%{_defaultdocdir}/%{name}/

%if 0%{?suse_version} >= 1315 
%{__cp} %{S:8} %{buildroot}%{_sysconfdir}/benno/
mkdir -p %{buildroot}%{_unitdir}
%{__cp} %{S:9} %{buildroot}%{_unitdir}
mv %{buildroot}/lib/systemd/system/benno-rest.service %{buildroot}%{_unitdir}
mkdir %{buildroot}%{_bindir}
%{__cp} %{S:10} %{buildroot}%{_bindir}/
rm -f %{buildroot}%{_sysconfdir}/init.d/%{name}
ln -sf %{_sbindir}/service %{buildroot}/%{_sbindir}/rc%{name}
%else
%{__cp} %{S:2} %{buildroot}%{_sysconfdir}/init.d/%{name}
ln -sf ../../etc/init.d/%{name} %{buildroot}%{_sbindir}/rc%{name}
%endif
rm -f %{buildroot}%{_sysconfdir}/default/benno-rest.orig

%pre
%{USRADDBENNO}
%if 0%{?suse_version} >= 1315 
%service_add_pre %{name}.service
%endif

%post
%if 0%{?suse_version} >= 1315 
%service_add_post %{name}.service
%endif

%preun
%if 0%{?suse_version} >= 1315 
%service_del_preun %{name}.service
%endif
%stop_on_removal %{name}

%postun 
%restart_on_update %{name}
%if 0%{?suse_version} >= 1315 
%service_del_postun %{name}.service
%else
%insserv_cleanup %{name}
%endif

%files
%defattr(-,root,root)
%dir %doc %{_defaultdocdir}/%{name}
%doc %{_defaultdocdir}/%{name}/*
%config %{_sysconfdir}/benno/rest-log4j.xml
%config %{_sysconfdir}/benno/jetty.xml
%config(noreplace) %{_sysconfdir}/default/%{name}
%if 0%{?suse_version} >= 1315 
%config(noreplace) %{_sysconfdir}/benno/%{name}-service.conf
%attr(644,root,root) %{_unitdir}/%{name}-fsp.service
%attr(644,root,root) %{_unitdir}/%{name}.service
%{_sbindir}/rc%{name}
%else
%attr(0750,root,root) %{_sysconfdir}/init.d/%{name}
%attr(0644,root,root) %{_sbindir}/rc%{name}
%endif
%attr(0644,root,root) %{_sysconfdir}/cron.weekly/benno-rest
%attr(0750,root,root) %{_sbindir}/benno-report
%attr(0755,root,root) %{_bindir}/benno-license-info
%attr(0644,root,root) /opt/benno/bennorest.jar

%changelog
openSUSE Build Service is sponsored by