File rest-server.spec of Package rest-server
#
# spec file for package restic
#
# Copyright (c) 2017 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/
#
%if 0%{?suse_version} == 1315
%define _fillupdir %{_localstatedir}/adm/fillup-templates
%endif
Name: rest-server
Version: 0.10.0
Release: 0
License: BSD-2-Clause
Summary: Implementation of restic's REST backend API
Url: https://github.com/restic/rest-server/releases
Group: Productivity/Archiving/Backup
Source: %{name}-%{version}.tar.gz
Source1: rest-server.sysconfig
Source2: vendor.tar.xz
Patch: rest-server-0.9.7_fix_service_file.patch
BuildRequires: golang(API) >= 1.11
BuildRequires: golang-packaging
Requires(pre): shadow
BuildRequires: pkgconfig(systemd)
%{?systemd_requires}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%define home_dir /srv/restic
%define log_dir /var/log/restic
%description
Rest Server is a high performance HTTP server that implements restic's REST backend API.
%prep
%autosetup -p1 -a 2
%build
go run build.go
perl -p -i -e 's|HOMEDIR|%{home_dir}|g' etc/*service
perl -p -i -e 's|LOGDIR|%{log_dir}|g' etc/*service
%install
install -D -m 0755 rest-server %{buildroot}%{_sbindir}/rest-server
install -d -m 0750 %{buildroot}%{home_dir} %{buildroot}%{log_dir}
install -D -m 0644 examples/systemd/rest-server.service %{buildroot}%{_unitdir}/rest-server.service
ln -s -f %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
install -D -m 0644 %{SOURCE1} \
%{buildroot}%{_fillupdir}/sysconfig.%{name}
%pre
getent group rest-server >/dev/null || groupadd -r rest-server
getent passwd rest-server >/dev/null || useradd -r -g rest-server -d %{home_dir} -s /sbin/nologin -c "restic's REST API Server" rest-server
%service_add_pre rest-server.service
%post
%fillup_only rest-server
%service_add_post rest-server.service
%preun
%service_del_preun rest-server.service
%postun
%service_del_postun rest-server.service
%files
%defattr(-,root,root)
%doc *.md LICENSE
%doc docker/
%{_sbindir}/rest-server
%{_sbindir}/rcrest-server
%{_unitdir}/rest-server.service
%dir %attr(-,rest-server,rest-server) %{home_dir}
%dir %attr(-,rest-server,rest-server) %{log_dir}
%{_fillupdir}/sysconfig.%{name}