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.gz
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  yaml-cpp-devel
BuildRequires:  systemd
%{?systemd_requires}

%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 -n %{name}-%{version}

%build
%cmake -DCMAKE_BUILD_TYPE:STRING=Release
make %{?_smp_mflags} CFLAGS="%{optflags}"

%install
%cmake_install
rm -rf %{buildroot}%{_datadir}/doc/%{name}

mkdir -p %{buildroot}/%{_sysconfdir}
mkdir -p %{buildroot}%{_localstatedir}/adm/fillup-templates

cp examples/%{name}.yaml %{buildroot}/%{_sysconfdir}/%{name}.conf

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}/rcthinkfan-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 thinkfan-wakeup.service

%post
%service_add_post %{name}.service
%service_add_post thinkfan-wakeup.service

%preun
%service_del_preun %{name}.service
%service_del_preun thinkfan-wakeup.service

%postun
%service_del_postun %{name}.service
%service_del_postun thinkfan-wakeup.service

%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}.conf
%config(noreplace) %{_sysconfdir}/systemd/system/thinkfan.service.d/override.conf
%config(noreplace) %{_sysconfdir}/modprobe.d/50-thinkfan.conf
%{_mandir}/man1/%{name}.1*
%{_mandir}/man5/thinkfan.conf.*
%{_unitdir}/*.service
%{_sbindir}/rc*

%changelog
openSUSE Build Service is sponsored by