File thinkfan.spec of Package thinkfan

#
# spec file for package thinkfan
#
# Copyright (c) 2020 SUSE LLC
#
# 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:           thinkfan
Version:        1.2.2
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:  libatasmart-devel
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 -DUSE_ATASMART:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=/usr
make %{?_smp_mflags} CFLAGS="%{optflags}"

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

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

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

mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-wakeup
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-sleep

mkdir -p %{buildroot}%{_sysconfdir}/modprobe.d
echo "options thinkpad_acpi fan_control=1" > %{buildroot}%{_sysconfdir}/modprobe.d/50-%{name}.conf

%pre
%service_add_pre %{name}.service
%service_add_pre %{name}-wakeup.service
%service_add_pre %{name}-sleep.service

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

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

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

%files
%defattr(-,root,root)
%license COPYING
%doc README.md examples/*
%dir %{_sysconfdir}/modprobe.d
%{_sbindir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}.conf
%config(noreplace) %{_sysconfdir}/modprobe.d/50-%{name}.conf
%{_mandir}/man1/%{name}.1*
%{_mandir}/man5/%{name}.conf.5*
%{_mandir}/man5/%{name}.conf.legacy.5*
%{_unitdir}/*.service
%{_sbindir}/rc*

%changelog
openSUSE Build Service is sponsored by