File hd-idle.spec of Package hd-idle

#
# spec file for package hd-idle
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2014 B1 Systems GmbH, Vohburg, 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/
#


Name:           hd-idle
Version:        1.05
Release:        0
Summary:        Spin down external harddisks
License:        GPL-2.0+
Group:          System/Base
Url:            http://hd-idle.sourceforge.net/
Source:         hd-idle-%{version}.tgz
Source2:        hd-idle.default
Source3:        hd-idle.service
Patch1:         hd-idle-systemd-nodaemon.diff
BuildRequires:  sed
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
hd-idle is a utility program for spinning-down external disks after a period of idle time. Since most external IDE disk enclosures don't support setting the IDE idle timer, a program like hd-idle is required to spin down idle disks automatically.

%prep
%setup -q -n %{name}
%patch1 -p1

# don't chown the files
sed -i -e 's/-g root -o root //' Makefile

%build
make %{?_smp_mflags} CFLAGS="%{optflags}"

%install
%make_install
chmod 0644 %{buildroot}%{_mandir}/man1/*

install -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/default/hd-idle
install -D -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/hd-idle.service
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rchd-idle

%pre
%service_add_pre hd-idle.service

%preun
%service_del_preun hd-idle.service

%post
%service_add_post hd-idle.service

%postun
%service_del_postun hd-idle.service

%files
%defattr(-,root,root)
%doc README debian/changelog
%{_sbindir}/hd-idle
%{_sbindir}/rchd-idle
%{_mandir}/man1/hd-idle.1*
%config(noreplace) %{_sysconfdir}/default/hd-idle
%{_unitdir}/hd-idle.service

%changelog