File btrfsmaintenance.spec of Package btrfsmaintenance.2835

# spec file for package btrfsmaintenance
# Copyright (c) 2016 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

Name:           btrfsmaintenance
Version:        0.2
Release:        0
Summary:        Scripts for btrfs periodic maintenance tasks
License:        GPL-2.0
Group:          System/Base
Source0:        %{name}-%{version}.tar.bz2
Patch1:         sysconfig-override-trim.diff
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
Recommends:     cron
Requires:       zypp-plugin-python
Requires:       libzypp(plugin:commit) = 1
%if 0%{?suse_version} >= 1210
BuildRequires:  systemd
Supplements:    btrfsprogs

Scripts for btrfs maintenance tasks like periodic scrub, balance, trim or defrag
on selected mountpoints or directories.

%setup -q
%patch1 -p0


# fix build error on openSUSE and SLE
mkdir -p %{buildroot}%{_sysconfdir}/cron.daily/
mkdir -p %{buildroot}%{_sysconfdir}/cron.weekly/
mkdir -p %{buildroot}%{_sysconfdir}/cron.monthly/

install -m 755 -d %{buildroot}/usr/share/%{name}
install -m 755 %{buildroot}/usr/share/%{name}
install -m 755 %{buildroot}/usr/share/%{name}
install -m 755 %{buildroot}/usr/share/%{name}
install -m 755 %{buildroot}/usr/share/%{name}
install -m 755 %{buildroot}/usr/share/%{name}

%if 0%{?suse_version} >= 1210
install -m 755 -d %{buildroot}%{_unitdir}
install -m 644 -D btrfsmaintenance-refresh.service %{buildroot}%{_unitdir}
install -m 755 -d %{buildroot}%{_sbindir}
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcbtrfsmaintenance-refresh
# just a hack, but sufficient
install -m 755 -d %{buildroot}/etc/cron.hourly
ln -s /usr/share/%{name}/ %{buildroot}/etc/cron.hourly/

install -m 755 -d %{buildroot}/usr/lib/zypp/plugins/commit
install -m 755 -D %{buildroot}/usr/lib/zypp/plugins/commit

install -m 755 -d %{buildroot}%{_localstatedir}/adm/fillup-templates
install -m 644 -D sysconfig.btrfsmaintenance %{buildroot}%{_localstatedir}/adm/fillup-templates

%{fillup_only btrfsmaintenance}
%if 0%{?suse_version} >= 1210
%service_add_post btrfsmaintenance-refresh.service

%if 0%{?suse_version} >= 1210
%service_add_pre btrfsmaintenance-refresh.service

%service_del_preun btrfsmaintenance-refresh.service
/usr/share/%{name}/ uninstall

%service_del_postun btrfsmaintenance-refresh.service

%if 0%{?suse_version} < 1210
/usr/share/%{name}/ uninstall

%dir /usr/share/%{name}
%dir /usr/lib/zypp/
%dir /usr/lib/zypp/plugins
%dir /usr/lib/zypp/plugins/commit
%if 0%{?suse_version} >= 1210
%dir %{_unitdir}

openSUSE Build Service is sponsored by