File tumbleweed-snapshot.spec of Package tumbleweed-snapshot
#
# spec file for package tumbleweed-snapshot
#
# Copyright (c) 2017 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} >= 1210 || 0%{?centos_version} >= 600
%bcond_without systemd
%else
%bcond_with systemd
%endif
%define home_dir %{_localstatedir}/lib/%{name}
Name: tumbleweed-snapshot
Version: 0.4.3
Release: 0
Summary: Script for creating snapshots of Tumbleweed repositories
License: GPL-2.0
Group: System/Packages
Url: https://github.com/boombatower/tumbleweed-cli
Source: %{name}-%{version}.tar.xz
Source1: %{name}-init
# see https://github.com/steamtricks/steamtricks/issues/27
Requires: coreutils
Requires: findutils
Requires: grep
Requires: procmail
Requires: rsync
# for SLE-11
BuildRequires: xz
%if 0%{?suse_version}
PreReq: %fillup_prereq
%endif
%if %{with systemd}
BuildRequires: systemd
%{?systemd_requires}
%endif
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
tumbleweed-snapshot provides a script for creating snapshots of Tumbleweed repositories.
%prep
%setup -q
%build
%install
make install DESTDIR="%{buildroot}"
install -d -m 0750 %{buildroot}%{home_dir}
mkdir -p %{buildroot}/%{_sbindir}
%if %{with systemd}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%else
install -Dm 755 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init.d/%{name}
ln -s -f ../../etc/init.d/%{name} %{buildroot}/%{_sbindir}/rc%{name}
rm -rf %{buildroot}/%{_prefix}/lib/systemd
%endif
%pre
%{_sbindir}/groupadd -r %{name} >/dev/null 2>&1 || :
%{_sbindir}/useradd -g %{name} -s /bin/false -r -c "tumbleweed snapshot script" -d %{home_dir} %{name} >/dev/null 2>&1 || :
%if %{with systemd}
%service_add_pre %{name}.service
%endif
%preun
%if %{with systemd}
%service_del_preun %{name}.service
%else
%stop_on_removal %{name}
%endif
%post
%if %{with systemd}
%service_add_post %{name}.service
%else
%{fillup_and_insserv -fy %{name}}
%endif
%postun
%if %{with systemd}
%service_del_postun %{name}.service
%else
%restart_on_update %{name}
%{insserv_cleanup}
%endif
%files
%defattr(-,root,root,-)
%doc README.md
%dir %attr(700,%{name},%{name}) %{home_dir}
%{_bindir}/%{name}
%{_datadir}/%{name}
%{_sbindir}/rc%{name}
%if %{with systemd}
%attr(644,root,root) %{_unitdir}/%{name}.service
%attr(644,root,root) %{_unitdir}/%{name}.timer
%else
%{_sysconfdir}/init.d/%{name}
%endif
%attr(640,root,root) %config(noreplace) %{_sysconfdir}/%{name}.conf
%attr(644,root,root) /usr/share/tumbleweed-snapshot/.htaccess
%changelog