File throttled.spec of Package throttled

Name:               throttled
Summary:            Fixing Intel CPU throttling on Linux
Version:            0.6
Release:            1
License:            MIT
Group:              System/Management
Source0:            %{name}-%{version}.tar.gz
Url:                https://github.com/erpalma/throttled
BuildRequires:      python-rpm-macros
BuildRequires:      python3-base
Conflicts:          thermald
BuildArch:          noarch

%description
This tool was originally developed to fix Linux CPU throttling issues affecting 
Lenovo T480 / T480s / X1C6.

The CPU package power limit (PL1/2) is forced to a value of 44 W (29 W on 
battery) and the temperature trip point to 95 'C (85 'C on battery) by 
overriding default values in MSR and MCHBAR every 5 seconds (30 on battery) to 
block the Embedded Controller from resetting these values to default.

%prep
%setup -q
sed -i 's|/usr/bin/env python|/usr/bin/python|' lenovo_fix.py
sed -i 's|ExecStart=.*|ExecStart=%{_bindir}/lenovo_fix|' systemd/lenovo_fix.service

%build
# Nothing

%install
install -Dm 0755 lenovo_fix.py %{buildroot}%{_bindir}/lenovo_fix
install -Dm 0644 mmio.py %{buildroot}%{python3_sitelib}/mmio.py
install -Dm 0644 etc/lenovo_fix.conf %{buildroot}%{_sysconfdir}/lenovo_fix.conf
install -Dm 0644 systemd/lenovo_fix.service %{buildroot}%{_unitdir}/lenovo_fix.service
mkdir -p %{buildroot}%{_sbindir}
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rclenovo_fix

%pre
%service_add_pre lenovo_fix.service

%post
%service_add_post lenovo_fix.service

%preun
%service_del_preun lenovo_fix.service

%postun
%service_del_postun lenovo_fix.service

%files
%defattr(-,root,root,-)
%license LICENSE
%attr(755, root, root) %{_bindir}/lenovo_fix
%attr(644, root, root) %{python3_sitelib}/mmio.py
%config(noreplace) %attr(640, root, root) %{_sysconfdir}/lenovo_fix.conf
%{_unitdir}/lenovo_fix.service
%{_sbindir}/rclenovo_fix

%changelog

openSUSE Build Service is sponsored by