File cpupower.spec of Package cpupower

# spec file for package cpupower
# Copyright (c) 2022 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

%define maindir tools/power/cpupower
%define tsdir tools/power/x86/turbostat
%define pbdir tools/power/x86/x86_energy_perf_policy
%define ssdir tools/power/x86/intel-speed-select
# Use this as version when things are in mainline kernel
%define version %(rpm -q --qf '%%{VERSION}' kernel-source)
Name:           cpupower
Version:        %{version}
Release:        0
Summary:        Tools to determine and set CPU Power related Settings
License:        GPL-2.0-only
Group:          System/Base
Patch1:         cpupower_rapl.patch
Patch2:         rapl_monitor.patch
Patch3:         cpupower_exclude_kernel_Makefile.patch
Patch6:         amd_do_not_show_amount_of_boost_states_if_zero.patch
BuildRequires:  gettext-tools
BuildRequires:  kernel-source
BuildRequires:  libcap-devel
BuildRequires:  pciutils
BuildRequires:  pciutils-devel

This tool accesses the Linux kernel's processor power subsystems
like CPU frequency switching (cpufreq) or CPU sleep states (cpuidle).

%package -n libcpupower0
Summary:        Processor power related C-library
Group:          System/Libraries

%description -n libcpupower0
Contains libcpupower which offers easy functions to access
processor frequency, processor idle, processor power hierarchy
and other CPU power consumption related information.

%package devel
Summary:        Include files for libcpupower
Group:          Development/Languages/C and C++
Requires:       libcpupower0 = %{version}

%description devel
Include files for C/C++ development with libcpupower.

%package bench
Summary:        CPU frequency micro benchmark
Group:          System/Benchmark

%description bench
This benchmark helps to test the condition of a given kernel cpufreq
governor (e.g. ondemand, userspace, conservative) and the cpufreq HW driver
(e.g. powernow-k8, acpi-cpufreq, ...).
For that purpose, it compares the performance governor to a configured
powersave module.

%package rebuild
Summary:        Empty package to ensure rebuilding cpupower in OBS
Group:          System/Monitoring
%requires_eq    kernel-source

%description rebuild
This is empty package that ensures cpupower is rebuilt every time
kernel-default is rebuilt in OBS.

There is no reason to install this package.


# copy necessary files from kernel-source since we need to modify them
(cd %{_prefix}/src/linux ; tar -cf - COPYING CREDITS README tools include scripts Kbuild Makefile arch/*/{include,lib,Makefile} lib) | tar -xf -
chmod +x tools/power/cpupower/utils/
cd %{maindir}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch6 -p1

CONF="PACKAGE_BUGREPORT= mandir=%{_mandir} libdir=%{_libdir} CPUFRQ_BENCH=true"
export CFLAGS="%{optflags} -fcommon"
%make_build -C %{maindir} $CONF

%ifarch %{ix86} x86_64
%make_build -C %{tsdir}
%make_build -C %{pbdir}
%make_build -C %{ssdir}

CONF="PACKAGE_BUGREPORT= mandir=%{_mandir} libdir=%{_libdir} CPUFRQ_BENCH=true DESTDIR=%{buildroot} sbindir=%{_sbindir} docdir=%{_docdir}/%{name} confdir=%{_sysconfdir}"
%make_install -C %{maindir} $CONF

%ifarch %{ix86} x86_64
%make_install -C %{tsdir}
%make_install -C %{pbdir}
%make_install -C %{ssdir}

# copy to examples doc dir to avoid complains from the build
# system about an executable in the doc dir.
mkdir -p %{buildroot}/%{_docdir}/%{name}/examples
mv %{buildroot}//%{_docdir}/%{name}/ %{buildroot}/%{_docdir}/%{name}/examples

%find_lang %{name}

%post -n libcpupower0 -p /sbin/ldconfig
%postun -n libcpupower0 -p /sbin/ldconfig

%ifarch %{ix86} x86_64

%files bench
%config %{_sysconfdir}/cpufreq-bench.conf
%dir %{_docdir}/%{name}
%dir %{_docdir}/%{name}/examples

%files -n libcpupower0

%files devel

%files lang -f %{name}.lang

%files rebuild
%license COPYING

openSUSE Build Service is sponsored by