Integrate rpm spec with systemd, bump version

This commit is contained in:
dcrdev 2017-08-31 12:16:03 +01:00
parent f3d2a69089
commit 4e440b4d81
1 changed files with 71 additions and 13 deletions

View File

@ -1,17 +1,25 @@
%global version 1.4.13 %global version 1.4.14
%global git_tag v%{version} %global git_tag v%{version}
Name: sanoid # Enable with systemctl "enable sanoid.timer"
Version: %{version} %global _with_systemd 1
Release: 1%{?dist}
BuildArch: noarch Name: sanoid
Summary: A policy-driven snapshot management tool for ZFS file systems Version: %{version}
Group: Applications/System Release: 2%{?dist}
License: GPLv3 BuildArch: noarch
URL: https://github.com/jimsalterjrs/sanoid Summary: A policy-driven snapshot management tool for ZFS file systems
Source0: https://github.com/jimsalterjrs/%{name}/archive/%{git_tag}/%{name}-%{version}.tar.gz Group: Applications/System
#BuildRequires: License: GPLv3
Requires: perl, mbuffer, lzop, pv URL: https://github.com/jimsalterjrs/sanoid
Source0: https://github.com/jimsalterjrs/%{name}/archive/%{git_tag}/%{name}-%{version}.tar.gz
Requires: perl, mbuffer, lzop, pv
%if 0%{?_with_systemd}
Requires: systemd >= 212
BuildRequires: systemd
%endif
%description %description
Sanoid is a policy-driven snapshot management Sanoid is a policy-driven snapshot management
@ -24,20 +32,62 @@ human-readable TOML configuration file.
%setup -q %setup -q
%build %build
echo "Nothing to build"
%install %install
%{__install} -D -m 0644 sanoid.defaults.conf %{buildroot}/etc/sanoid/sanoid.defaults.conf %{__install} -D -m 0644 sanoid.defaults.conf %{buildroot}/etc/sanoid/sanoid.defaults.conf
%{__install} -d %{buildroot}%{_sbindir} %{__install} -d %{buildroot}%{_sbindir}
%{__install} -m 0755 sanoid syncoid findoid sleepymutex %{buildroot}%{_sbindir} %{__install} -m 0755 sanoid syncoid findoid sleepymutex %{buildroot}%{_sbindir}
%if 0%{?_with_systemd}
%{__install} -d %{buildroot}%{_unitdir}
%endif
%if 0%{?fedora} %if 0%{?fedora}
%{__install} -D -m 0644 sanoid.conf %{buildroot}%{_docdir}/%{name}/examples/sanoid.conf %{__install} -D -m 0644 sanoid.conf %{buildroot}%{_docdir}/%{name}/examples/sanoid.conf
echo "* * * * * root %{_sbindir}/sanoid --cron" > %{buildroot}%{_docdir}/%{name}/examples/sanoid.cron
%endif %endif
%if 0%{?rhel} %if 0%{?rhel}
%{__install} -D -m 0644 sanoid.conf %{buildroot}%{_docdir}/%{name}-%{version}/examples/sanoid.conf %{__install} -D -m 0644 sanoid.conf %{buildroot}%{_docdir}/%{name}-%{version}/examples/sanoid.conf
%endif
%if 0%{?_with_systemd}
cat > %{buildroot}%{_unitdir}/%{name}.service <<EOF
[Unit]
Description=Snapshot ZFS Pool
Requires=zfs.target
After=zfs.target
[Service]
Type=oneshot
ExecStart=%{_sbindir}/sanoid --cron
EOF
cat > %{buildroot}%{_unitdir}/%{name}.timer <<EOF
[Unit]
Description=Run Sanoid Every Minute
[Timer]
OnCalendar=*:0/1
Persistent=true
[Install]
WantedBy=timers.target
EOF
%else
%if 0%{?fedora}
%{__install} -D -m 0644 sanoid.conf %{buildroot}%{_docdir}/%{name}/examples/sanoid.conf
%endif
%if 0%{?rhel}
echo "* * * * * root %{_sbindir}/sanoid --cron" > %{buildroot}%{_docdir}/%{name}-%{version}/examples/sanoid.cron echo "* * * * * root %{_sbindir}/sanoid --cron" > %{buildroot}%{_docdir}/%{name}-%{version}/examples/sanoid.cron
%endif %endif
%endif
%post
%{?_with_systemd:%{_bindir}/systemctl daemon-reload}
%postun
%{?_with_systemd:%{_bindir}/systemctl daemon-reload}
%files %files
%doc CHANGELIST VERSION README.md FREEBSD.readme %doc CHANGELIST VERSION README.md FREEBSD.readme
@ -54,8 +104,16 @@ echo "* * * * * root %{_sbindir}/sanoid --cron" > %{buildroot}%{_docdir}/%{name}
%if 0%{?rhel} %if 0%{?rhel}
%{_docdir}/%{name}-%{version} %{_docdir}/%{name}-%{version}
%endif %endif
%if 0%{?_with_systemd}
%{_unitdir}/%{name}.service
%{_unitdir}/%{name}.timer
%endif
%changelog %changelog
* Wed Aug 30 2017 Dominic Robinson <github@dcrdev.com> - 1.4.14-2
- Add systemd timers
* Wed Aug 30 2017 Dominic Robinson <github@dcrdev.com> - 1.4.14-1
- Version bump
* Wed Jul 12 2017 Thomas M. Lapp <tmlapp@gmail.com> - 1.4.13-1 * Wed Jul 12 2017 Thomas M. Lapp <tmlapp@gmail.com> - 1.4.13-1
- Version bump - Version bump
- Include FREEBSD.readme in docs - Include FREEBSD.readme in docs