File spindown.spec of Package spindown

#
# spec file for package spindown
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2008-2009 oc2pus
#
# 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 https://bugs.opensuse.org/
#


Name:           spindown
Version:        0.4.0
Release:        0
Summary:        A daemon to spin down idle disks
License:        GPL-3.0-only
Group:          System/Daemons
URL:            https://code.google.com/p/spindown/
Source:         https://spindown.googlecode.com/files/%{name}-%{version}.tar.gz
Source1:        %{name}.service
# not used but without it build fails
Patch0:         %{name}-suse_rc_script.patch
# Fedora patches
Patch2:         %{name}-0.4.0-Makefile.patch
Patch3:         %{name}-0.4.0-iniparser.patch
Patch4:         %{name}-0.4.0-iniparser-3.0-1.patch
Patch5:         %{name}-0.4.0-bz1037334.patch
# required to compile by gcc 14
Patch7:         %{name}-0.4.0-gcc-14.x.patch
BuildRequires:  gcc-c++
BuildRequires:  libiniparser-devel
Requires:       scsi
%{?systemd_ordering}

%description
Spindown is a daemon I've written to spin down idle disks and so
saving energy and giving the disks a longer lifetime. It works by
checking how many blocks are read and written from the disks. When
no blocks are read or written the disk is idle. When a disk stays
idle long enough spindown uses sg_start to spin the disk down.
It also works with usb disks and hot swappable disks because it
doesn't watch the device name (hda, sdb, ...), but the device id.
This means that it doesn't matter if the disk is swapped while the
daemon is running.

%prep
%setup -q
rm -rf src/ininiparser3.0b
%patch -P 0
%patch -P 2 -p1
%patch -P 3 -p1
%patch -P 4 -p1
%patch -P 5 -p1
%patch -P 7 -p1

%build
%make_build OPT="%{optflags}"

%install
%make_install
# systemd service
install -D -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
mkdir -p %{buildroot}%{_sbindir}
ln -s service %{buildroot}%{_sbindir}/rc%{name}

%pre
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%license COPYING
%doc CHANGELOG README spindown.conf.example
%config(noreplace) %{_sysconfdir}/%{name}.conf
%{_unitdir}/%{name}.service
%{_sbindir}/rc%{name}
%{_sbindir}/%{name}d

%changelog
openSUSE Build Service is sponsored by