SHA256
1
0
forked from pool/cpupower
Dominique Leuenberger 2018-12-07 13:35:29 +00:00 committed by Git OBS Bridge
commit e8a139085c
3 changed files with 248 additions and 65 deletions

View File

@ -1,3 +1,20 @@
-------------------------------------------------------------------
Thu Dec 6 12:50:21 UTC 2018 - Jan Engelhardt <jengelh@inai.de>
- Description updates.
-------------------------------------------------------------------
Thu Dec 6 09:33:55 UTC 2018 - Ismail Dönmez <idonmez@suse.com>
- Run spec-cleaner
- Don't disable as-needed, it works now.
-------------------------------------------------------------------
Tue Dec 4 12:14:23 UTC 2018 - trenn@suse.de
- Add bash completion for cpupower command (from mainline submit)
A cpupower_bash-completion_for_cpupower_tool.patch
-------------------------------------------------------------------
Tue Oct 16 12:50:20 UTC 2018 - trenn@suse.de

View File

@ -2,7 +2,6 @@
# spec file for package cpupower
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# Author: Thomas Renninger <trenn@suse.de>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -13,157 +12,149 @@
# 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/
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: cpupower
# Use this as version when things are in mainline kernel
%define version %(rpm -q --qf '%VERSION' kernel-source)
Version: 4.19
Release: 0
%define version %(rpm -q --qf '%{VERSION}' kernel-source)
%define tsversion 18.07.27
%define pbversion 17.05.11
Name: cpupower
Version: 4.19
Release: 0
Summary: Tools to determine and set CPU Power related Settings
License: GPL-2.0
License: GPL-2.0-only
Group: System/Base
Url: https://git.kernel.org/cgit/linux/kernel/git/rafael/linux-pm.git
Source: %name-%version.tar.bz2
Source1: turbostat-%tsversion.tar.bz2
URL: https://git.kernel.org/cgit/linux/kernel/git/rafael/linux-pm.git
Source: %{name}-%{version}.tar.bz2
Source1: turbostat-%{tsversion}.tar.bz2
Source2: cpupower_export_tarball_from_git.sh
Source3: x86_energy_perf_policy-%{pbversion}.tar.bz2
Patch1: cpupower_rapl.patch
Patch2: rapl_monitor.patch
Patch3: cpupower_exclude_kernel_Makefile.patch
Patch4: cpupower_fix_compilation_and_sysfs_read_file_mess.patch
Patch5: cpupower_bash-completion_for_cpupower_tool.patch
Patch22: turbostat_makefile_fix_asm_header.patch
# Fixes bsc#1048546:
Patch30: x86_perf_makefile_fix_asm_header.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: gettext-tools
BuildRequires: pciutils
BuildRequires: pciutils-devel
Obsoletes: cpufrequtils
Provides: cpufrequtils = %version
Provides: cpufrequtils = %{version}
%description
This tool is to make access to the Linux kernel's processor power subsystems
like CPU frequency switching (cpufreq) or CPU sleep states (cpuidle) for users
and userspace tools easier.
This tool accesses the Linux kernel's processor power subsystems
like CPU frequency switching (cpufreq) or CPU sleep states (cpuidle).
%package -n libcpupower0
Summary: Obsolete processor frequency related C-library
Group: System/Libraries
%description -n libcpupower0
Contains libcpupower and soon possibly other CPU power related
C libraries.
Contains libcpupower.
%package devel
Summary: Include files and C-libraries
Summary: Include files for libcpupower
Group: Development/Languages/C and C++
Requires: libcpupower0 = %{version}
Conflicts: cpufrequtils-devel
Requires: libcpupower0 = %version
%description devel
Include files and C-libraries for C/C++ development
Include files for C/C++ development with libcpupower.
%package bench
Summary: CPU frequency micro benchmark
Group: System/Benchmark
Obsoletes: cpufrequtils-bench < %version
Provides: cpufrequtils-bench = %version
Obsoletes: cpufrequtils-bench < %{version}
Provides: cpufrequtils-bench = %{version}
%description bench
Helps to test the condition of a given kernel cpufreq
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.
%prep
%setup -D -b 1 -b 3
%setup -q -D -b 1 -b 3
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
cd ../turbostat-%tsversion
cd ../turbostat-%{tsversion}
%patch22 -p1
cd ../x86_energy_perf_policy-%{pbversion}
%patch30 -p1
%build
# This package failed when testing with -Wl,-as-needed being default.
# So we disable it here, if you want to retest, just delete this comment and the line below.
export SUSE_ASNEEDED=0
CONF="PACKAGE_BUGREPORT=http://bugs.opensuse.org mandir=%_mandir libdir=%_libdir CPUFRQ_BENCH=true VERSION=%version"
export CFLAGS="%optflags -I ."
CONF="PACKAGE_BUGREPORT=https://bugs.opensuse.org mandir=%{_mandir} libdir=%{_libdir} CPUFRQ_BENCH=true VERSION=%{version}"
export CFLAGS="%{optflags} -I ."
make $CONF %{?_smp_mflags}
%ifarch ix86 x86_64
cd ../turbostat-%tsversion
export CFLAGS="%optflags -I ."
cd ../turbostat-%{tsversion}
export CFLAGS="%{optflags} -I ."
make %{?_smp_mflags}
cd ../x86_energy_perf_policy-%{pbversion}
make %{?_smp_mflags}
%endif
%install
export SUSE_ASNEEDED=0
CONF="PACKAGE_BUGREPORT=http://bugs.opensuse.org mandir=%_mandir libdir=%_libdir CPUFRQ_BENCH=true DESTDIR=%buildroot sbindir=%_sbindir docdir=%_docdir/%name confdir=%_sysconfdir VERSION=%version"
CONF="PACKAGE_BUGREPORT=https://bugs.opensuse.org mandir=%{_mandir} libdir=%{_libdir} CPUFRQ_BENCH=true DESTDIR=%{buildroot} sbindir=%{_sbindir} docdir=%{_docdir}/%{name} confdir=%{_sysconfdir} VERSION=%{version}"
%make_install $CONF
# 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/cpufreq-bench_script.sh %buildroot/%_docdir/%name/examples
%find_lang %name
mkdir -p %{buildroot}/%{_docdir}/%{name}/examples
mv %{buildroot}//%{_docdir}/%{name}/cpufreq-bench_script.sh %{buildroot}/%{_docdir}/%{name}/examples
%find_lang %{name}
%ifarch ix86 x86_64
cd ../turbostat-%tsversion
cd ../turbostat-%{tsversion}
%make_install -e
cd ../x86_energy_perf_policy-%{pbversion}
%make_install
%endif
%post -n libcpupower0 -p /sbin/ldconfig
%postun -n libcpupower0 -p /sbin/ldconfig
%files -f %name.lang
%defattr (-,root,root)
%_mandir/man1/cpupower*
%_bindir/cpupower
%files -f %{name}.lang
%{_datadir}/bash-completion/completions/cpupower
%{_mandir}/man1/cpupower*
%{_bindir}/cpupower
%ifarch ix86 x86_64
%_mandir/man8/turbostat*
%_bindir/turbostat
%_mandir/man8/x86_energy_perf_policy*
%_bindir/x86_energy_perf_policy
%{_mandir}/man8/turbostat*
%{_bindir}/turbostat
%{_mandir}/man8/x86_energy_perf_policy*
%{_bindir}/x86_energy_perf_policy
%endif
%files bench
%defattr (-,root,root)
%config %_sysconfdir/cpufreq-bench.conf
%_sbindir/cpufreq-bench
%_bindir/cpufreq-bench_plot.sh
%dir %_docdir/%name
%dir %_docdir/%name/examples
%_docdir/%name/examples/cpufreq-bench_script.sh
%_docdir/%name/README-BENCH
%config %{_sysconfdir}/cpufreq-bench.conf
%{_sbindir}/cpufreq-bench
%{_bindir}/cpufreq-bench_plot.sh
%dir %{_docdir}/%{name}
%dir %{_docdir}/%{name}/examples
%{_docdir}/%{name}/examples/cpufreq-bench_script.sh
%{_docdir}/%{name}/README-BENCH
%files -n libcpupower0
%defattr(-,root,root)
%_libdir/libcpupower*.so.*
%{_libdir}/libcpupower*.so.*
%files devel
%defattr(-,root,root)
%_includedir/cpufreq.h
%_includedir/cpuidle.h
/usr/include/powercap.h
%_libdir/libcpu*.so
%{_includedir}/cpufreq.h
%{_includedir}/cpuidle.h
%{_includedir}/powercap.h
%{_libdir}/libcpu*.so
%changelog

View File

@ -0,0 +1,175 @@
From: "Abhishek Goel" <huntbag@linux.vnet.ibm.com>
cpupower : bash-completion for cpupower tool
Signed-off-by: Abhishek Goel <huntbag@linux.vnet.ibm.com>
---
Makefile | 4 +-
cpupower-completion.bash | 129 ++++++++++++++++++
2 files changed, 132 insertions(+), 1 deletion(-)
create mode 100644 cpupower-completion.bash
Index: cpupower-4.19/Makefile
===================================================================
--- cpupower-4.19.orig/Makefile 2018-12-04 12:56:27.824106229 +0100
+++ cpupower-4.19/Makefile 2018-12-04 13:16:53.452172269 +0100
@@ -87,6 +87,7 @@ endif
localedir ?= /usr/share/locale
docdir ?= /usr/share/doc/packages/cpupower
confdir ?= /etc/
+bash_completion_dir ?= /usr/share/bash-completion/completions
# Toolchain: what tools do we use, and what options do they need:
@@ -94,7 +95,7 @@ CP = cp -fpR
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
-INSTALL_SCRIPT = ${INSTALL_PROGRAM}
+INSTALL_SCRIPT = ${INSTALL} -m 755
# If you are running a cross compiler, you may want to set this
# to something more interesting, like "arm-linux-". If you want
@@ -288,6 +289,8 @@ install-lib:
install-tools:
$(INSTALL) -d $(DESTDIR)${bindir}
$(INSTALL_PROGRAM) $(OUTPUT)cpupower $(DESTDIR)${bindir}
+ $(INSTALL) -d $(DESTDIR)${bindir}
+ $(INSTALL_DATA) -D cpupower-completion.sh '$(DESTDIR)${bash_completion_dir}/cpupower'
install-man:
$(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1
Index: cpupower-4.19/cpupower-completion.sh
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ cpupower-4.19/cpupower-completion.sh 2018-12-04 12:58:53.776114094 +0100
@@ -0,0 +1,129 @@
+# -*- shell-script -*-
+# bash completion script for cpupower
+# Taken from git.git's completion script.
+
+_cpupower_commands="frequency-info frequency-set idle-info idle-set set info monitor"
+
+_frequency_info ()
+{
+ local flags="-f -w -l -d -p -g -a -s -y -o -m -n --freq --hwfreq --hwlimits --driver --policy --governors --related-cpus --affected-cpus --stats --latency --proc --human --no-rounding"
+ local prev="${COMP_WORDS[COMP_CWORD-1]}"
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$prev" in
+ frequency-info) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
+ esac
+}
+
+_frequency_set ()
+{
+ local flags="-f -g --freq --governor -d --min -u --max -r --related"
+ local prev="${COMP_WORDS[COMP_CWORD-1]}"
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$prev" in
+ -f| --freq | -d | --min | -u | --max)
+ if [ -d /sys/devices/system/cpu/cpufreq/ ] ; then
+ COMPREPLY=($(compgen -W '$(cat $(ls -d /sys/devices/system/cpu/cpufreq/policy* | head -1)/scaling_available_frequencies)' -- "$cur"))
+ fi ;;
+ -g| --governor)
+ if [ -d /sys/devices/system/cpu/cpufreq/ ] ; then
+ COMPREPLY=($(compgen -W '$(cat $(ls -d /sys/devices/system/cpu/cpufreq/policy* | head -1)/scaling_available_governors)' -- "$cur"))
+ fi;;
+ frequency-set) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
+
+ esac
+}
+
+_idle_info()
+{
+ local flags="-f --silent"
+ local prev="${COMP_WORDS[COMP_CWORD-1]}"
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$prev" in
+ idle-info) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
+ esac
+}
+
+_idle_set()
+{
+ local flags="-d --disable -e --enable -D --disable-by-latency -E --enable-all"
+ local prev="${COMP_WORDS[COMP_CWORD-1]}"
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$prev" in
+ idle-set) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
+ esac
+}
+
+_set()
+{
+ local flags="--perf-bias, -b"
+ local prev="${COMP_WORDS[COMP_CWORD-1]}"
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$prev" in
+ set) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
+ esac
+}
+
+_monitor()
+{
+ local flags="-l -m -i -c -v"
+ local prev="${COMP_WORDS[COMP_CWORD-1]}"
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$prev" in
+ monitor) COMPREPLY=($(compgen -W "$flags" -- "$cur")) ;;
+ esac
+}
+
+_taskset()
+{
+ local prev_to_prev="${COMP_WORDS[COMP_CWORD-2]}"
+ local prev="${COMP_WORDS[COMP_CWORD-1]}"
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$prev_to_prev" in
+ -c|--cpu) COMPREPLY=($(compgen -W "$_cpupower_commands" -- "$cur")) ;;
+ esac
+ case "$prev" in
+ frequency-info) _frequency_info ;;
+ frequency-set) _frequency_set ;;
+ idle-info) _idle_info ;;
+ idle-set) _idle_set ;;
+ set) _set ;;
+ monitor) _monitor ;;
+ esac
+
+}
+
+_cpupower ()
+{
+ local i
+ local c=1
+ local command
+
+ while test $c -lt $COMP_CWORD; do
+ if test $c == 1; then
+ command="${COMP_WORDS[c]}"
+ fi
+ c=$((++c))
+ done
+
+ # Complete name of subcommand if the user has not finished typing it yet.
+ if test $c -eq $COMP_CWORD -a -z "$command"; then
+ COMPREPLY=($(compgen -W "help -v --version -c --cpu $_cpupower_commands" -- "${COMP_WORDS[COMP_CWORD]}"))
+ return
+ fi
+
+ # Complete arguments to subcommands.
+ case "$command" in
+ -v|--version) return ;;
+ -c|--cpu) _taskset ;;
+ help) COMPREPLY=($(compgen -W "$_cpupower_commands" -- "${COMP_WORDS[COMP_CWORD]}")) ;;
+ frequency-info) _frequency_info ;;
+ frequency-set) _frequency_set ;;
+ idle-info) _idle_info ;;
+ idle-set) _idle_set ;;
+ set) _set ;;
+ monitor) _monitor ;;
+ esac
+}
+
+complete -o bashdefault -o default -F _cpupower cpupower 2>/dev/null \
+ || complete -o default -F _cpupower cpupower