File thinkfan.spec of Package thinkfan
#
# spec file for package thinkfan
#
# Copyright (c) 2018 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/
#
Name: thinkfan
Version: 1.3.1
Release: 0
Summary: A minimalist fan control program
License: GPL-3.0
Group: Productivity/Other
URL: https://github.com/vmatare/thinkfan/
Source0: %{name}-%{version}.tar.bz2
Source1: thinkfan-sysconfig
Source10: thinkfan-rpmlintrc
Patch1: thinkfan-1.3.0-systemd.patch
BuildRequires: cmake
BuildRequires: gcc-c++
BuildRequires: libatasmart-devel
BuildRequires: systemd
BuildRequires: yaml-cpp-devel
%{?systemd_requires}
%if ! %{defined _fillupdir}
%define _fillupdir %{_localstatedir}/adm/fillup-templates
%endif
%description
A simple fan control program. Read temperatures, check them against configured
limits and switch to appropriate (also pre-configured) fan level.
Requires a working thinkpad_acpi or any other hwmon driver
that enables temperature reading and fan control from userspace.
Don't forget to set the desired temperature values in /etc/thinkfan.conf
%prep
%setup -q
%patch1 -p1
%build
%cmake -DUSE_ATASMART:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=Release
make %{?_smp_mflags} CFLAGS="%{optflags}"
%install
%cmake_install
rm -rf %{buildroot}%{_datadir}/doc/%{name}
mkdir -p %{buildroot}/%{_sysconfdir}
install -D -m0644 %{SOURCE1} %{buildroot}%{_fillupdir}/sysconfig.%{name}
rm %{buildroot}%{_sysconfdir}/systemd/system/thinkfan.service.d/override.conf
cp examples/%{name}.yaml %{buildroot}/%{_sysconfdir}/%{name}.yaml
mkdir -p %{buildroot}/%{_unitdir}
cp rcscripts/systemd/*.service %{buildroot}/%{_unitdir}/
sed -i "s|/usr/local/sbin|%{_sbindir}|g" %{buildroot}/%{_unitdir}/*
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-sleep
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-wakeup
mkdir -p %{buildroot}%{_sysconfdir}/modprobe.d
echo "options thinkpad_acpi fan_control=1" > %{buildroot}%{_sysconfdir}/modprobe.d/50-thinkfan.conf
%pre
%service_add_pre %{name}.service
%service_add_pre %{name}-sleep.service
%service_add_pre %{name}-wakeup.service
%post
%service_add_post %{name}.service
%service_add_post %{name}-sleep.service
%service_add_post %{name}-wakeup.service
%preun
%service_del_preun %{name}.service
%service_del_preun %{name}-sleep.service
%service_del_preun %{name}-wakeup.service
%postun
%service_del_postun %{name}.service
%service_del_postun %{name}-sleep.service
%service_del_postun %{name}-wakeup.service
%{fillup_only %{name}}
%files
%defattr(-,root,root)
%doc README.md COPYING examples/*
%dir %{_sysconfdir}/modprobe.d
%dir %{_sysconfdir}/systemd/system/thinkfan.service.d
%{_sbindir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}.yaml
%config(noreplace) %{_sysconfdir}/modprobe.d/50-thinkfan.conf
%{_fillupdir}/sysconfig.%{name}
%{_mandir}/man1/%{name}.1*
%{_mandir}/man5/thinkfan.conf.5*
%{_mandir}/man5/thinkfan.conf.legacy.5*
%{_unitdir}/*.service
%{_sbindir}/rc*
%changelog