summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Väth <martin@mvath.de>2021-04-27 08:15:53 +0200
committerMartin Väth <martin@mvath.de>2021-04-27 08:15:53 +0200
commitb286b861aae86a78757657e8df6b06fee66457e3 (patch)
tree388cc89613937abf81a05f3973258cb1d3763078
parentx11-libs/gtk+:3 version bump (diff)
downloadmv-b286b861aae86a78757657e8df6b06fee66457e3.tar.gz
mv-b286b861aae86a78757657e8df6b06fee66457e3.tar.bz2
mv-b286b861aae86a78757657e8df6b06fee66457e3.zip
Add sys-power/cpupower live version which uses current kernel tarball
Signed-off-by: Martin Väth <martin@mvath.de>
-rw-r--r--metadata/pkg_desc_index1
-rw-r--r--sys-power/cpupower/cpupower-99999999.ebuild75
-rw-r--r--sys-power/cpupower/files/conf.d-r236
-rw-r--r--sys-power/cpupower/files/cpupower-5.4-cflags.patch32
-rw-r--r--sys-power/cpupower/files/cpupower-frequency-set.service9
-rw-r--r--sys-power/cpupower/files/cpupower-frequency-set.service.conf2
-rw-r--r--sys-power/cpupower/files/init.d-r441
-rw-r--r--sys-power/cpupower/metadata.xml11
8 files changed, 207 insertions, 0 deletions
diff --git a/metadata/pkg_desc_index b/metadata/pkg_desc_index
index c4794d3d..4fb41fbd 100644
--- a/metadata/pkg_desc_index
+++ b/metadata/pkg_desc_index
@@ -112,6 +112,7 @@ sys-fs/squashmount 22.0.1: Keep directories compressed with squashfs. Useful for
sys-kernel/kccmp 0.3-r1: A simple tool for comparing two linux kernel .config files
sys-kernel/kconfig-hardened-check 0.5.9 99999999: A script for checking the hardening options in the Linux kernel config
sys-kernel/kernel 6.2: A POSIX shell script to compile the kernel with user permissions
+sys-power/cpupower 99999999: Shows and sets processor power related values
virtual/cdrtools 1: Virtual for command-line recorders cdrtools and cdrkit
virtual/freedesktop-icon-theme 0-r3: A virtual to choose between different icon themes
virtual/man 0-r4: Virtual for man
diff --git a/sys-power/cpupower/cpupower-99999999.ebuild b/sys-power/cpupower/cpupower-99999999.ebuild
new file mode 100644
index 00000000..539012a8
--- /dev/null
+++ b/sys-power/cpupower/cpupower-99999999.ebuild
@@ -0,0 +1,75 @@
+# Copyright 2013-2021 Gentoo Authors and Martin V\"ath
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit systemd toolchain-funcs linux-info
+
+DESCRIPTION="Shows and sets processor power related values"
+HOMEPAGE="https://www.kernel.org/"
+SRC_URI=""
+
+LICENSE="GPL-2"
+SLOT="0/0"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86"
+IUSE="nls"
+
+# File collision w/ headers of the deprecated cpufrequtils
+RDEPEND="sys-apps/pciutils"
+DEPEND="${RDEPEND}
+ virtual/os-headers
+ nls? ( sys-devel/gettext )"
+
+PATCHES=(
+ "${FILESDIR}/cpupower-5.4-cflags.patch"
+)
+
+pkg_setup() {
+ linux-info_pkg_setup
+ KV_SRC=${KV_MAJOR}.${KV_MINOR}
+ LINUX_SRC=linux-${KV_SRC}
+ S="${WORKDIR}/${LINUX_SRC}"
+}
+
+src_unpack() {
+ unpack "${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/${LINUX_SRC}.tar.xz"
+}
+
+src_configure() {
+ export bindir="${EPREFIX}/usr/bin"
+ export sbindir="${EPREFIX}/usr/sbin"
+ export mandir="${EPREFIX}/usr/share/man"
+ export includedir="${EPREFIX}/usr/include"
+ export libdir="${EPREFIX}/usr/$(get_libdir)"
+ export localedir="${EPREFIX}/usr/share/locale"
+ export docdir="${EPREFIX}/usr/share/doc/${PF}"
+ export confdir="${EPREFIX}/etc"
+ export bash_completion_dir="${EPREFIX}/usr/share/bash-completion/completions"
+ export V=1
+ export NLS=$(usex nls true false)
+}
+
+src_compile() {
+ myemakeargs=(
+ AR="$(tc-getAR)"
+ CC="$(tc-getCC)"
+ LD="$(tc-getCC)"
+ VERSION=${KV_FULL}
+ )
+
+ cd tools/power/cpupower || die
+ emake "${myemakeargs[@]}"
+}
+
+src_install() {
+ cd tools/power/cpupower || die
+ emake "${myemakeargs[@]}" DESTDIR="${D}" install
+ doheader lib/cpupower.h
+ einstalldocs
+
+ newconfd "${FILESDIR}"/conf.d-r2 cpupower
+ newinitd "${FILESDIR}"/init.d-r4 cpupower
+
+ systemd_dounit "${FILESDIR}"/cpupower-frequency-set.service
+ systemd_install_serviced "${FILESDIR}"/cpupower-frequency-set.service.conf
+}
diff --git a/sys-power/cpupower/files/conf.d-r2 b/sys-power/cpupower/files/conf.d-r2
new file mode 100644
index 00000000..1e67ed04
--- /dev/null
+++ b/sys-power/cpupower/files/conf.d-r2
@@ -0,0 +1,36 @@
+# /etc/conf.d/cpupower: config file for /etc/init.d/cpupower
+
+# Options when starting cpufreq (given to the `cpupower` program)
+# Possible options are:
+# -g --governor <GOV> (ie: ondemand, performance, or powersave)
+# -d --min <FREQ> (ie: 1000MHz)
+# -u --max <FREQ> (ie: 2000MHz)
+# -f --freq <FREQ> (requires userspace governor, this *can not* be combined with
+# with any other parameters).
+# Frequencies can be passed in Hz, kHz (default), MHz, GHz, or THz by postfixing the
+# value with the wanted unit name, without any space.
+# (frequency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).
+
+START_OPTS="--governor ondemand"
+
+# Options when stopping cpufreq (given to the `cpupower` program)
+# This option can be used to change governer on stop. Leaving it empty will ensure
+# the governer remains on the one provided above.
+STOP_OPTS=""
+
+# Extra settings to write to sysfs cpufreq values.
+#
+# up_threshold: threshold for stepping up frequency, where the value represents
+# the percentage of cpu load.
+#
+# down_threshold: threshold for stepping down frequency, where the value
+# represents the percentage of cpu load.
+#
+# sampling_down_factor: determines how frequently the governor polls the cpu, a
+# value greater than 1 improves performance by reducing the polling when the
+# load is high. This tunable has no effect on behavior at lower CPU frequencies.
+#
+# ignore_nice_load: when set to '1' the processes that are run with a 'nice'
+# value will not count in the usage calculation.
+
+#SYSFS_EXTRA="ondemand/ignore_nice_load=1 ondemand/up_threshold=75 ondemand/sampling_down_factor=10"
diff --git a/sys-power/cpupower/files/cpupower-5.4-cflags.patch b/sys-power/cpupower/files/cpupower-5.4-cflags.patch
new file mode 100644
index 00000000..f21435a0
--- /dev/null
+++ b/sys-power/cpupower/files/cpupower-5.4-cflags.patch
@@ -0,0 +1,32 @@
+From 6ae1f1b03aaaee6a9a56040d3ba7af6bf6648ad6 Mon Sep 17 00:00:00 2001
+From: Mike Gilbert <floppym@gentoo.org>
+Date: Wed, 27 Nov 2019 10:51:15 -0500
+Subject: [PATCH] Respect user CFLAGS
+
+---
+ tools/power/cpupower/Makefile | 9 +--------
+ 1 file changed, 1 insertion(+), 8 deletions(-)
+
+diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
+index c8622497ef23..f17e8c94da16 100644
+--- a/tools/power/cpupower/Makefile
++++ b/tools/power/cpupower/Makefile
+@@ -178,14 +178,7 @@ else
+ endif
+ export QUIET ECHO
+
+-# if DEBUG is enabled, then we do not strip or optimize
+-ifeq ($(strip $(DEBUG)),true)
+- override CFLAGS += -O1 -g -DDEBUG
+- STRIPCMD = /bin/true -Since_we_are_debugging
+-else
+- override CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer
+- STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
+-endif
++STRIPCMD = true
+
+
+ # the actual make rules
+--
+2.24.0
+
diff --git a/sys-power/cpupower/files/cpupower-frequency-set.service b/sys-power/cpupower/files/cpupower-frequency-set.service
new file mode 100644
index 00000000..8f2f4d9b
--- /dev/null
+++ b/sys-power/cpupower/files/cpupower-frequency-set.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=CPU Frequency Scaling
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/cpupower frequency-set $OPTS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/sys-power/cpupower/files/cpupower-frequency-set.service.conf b/sys-power/cpupower/files/cpupower-frequency-set.service.conf
new file mode 100644
index 00000000..969c8ab2
--- /dev/null
+++ b/sys-power/cpupower/files/cpupower-frequency-set.service.conf
@@ -0,0 +1,2 @@
+[Service]
+Environment="OPTS=-g ondemand"
diff --git a/sys-power/cpupower/files/init.d-r4 b/sys-power/cpupower/files/init.d-r4
new file mode 100644
index 00000000..febed865
--- /dev/null
+++ b/sys-power/cpupower/files/init.d-r4
@@ -0,0 +1,41 @@
+#!/sbin/openrc-run
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+CPUFREQ_SYSFS=/sys/devices/system/cpu/cpufreq
+
+change() {
+ local c ret=0 opts="$1"
+ if [ -n "$opts" ] ; then
+ ebegin "Running cpupower -c all frequency-set ${opts}"
+ cpupower -c all frequency-set ${opts} >/dev/null 2>&1
+ : $(( ret += $? ))
+ eend ${ret}
+
+ if [ -d ${CPUFREQ_SYSFS} ] && [ -n "${SYSFS_EXTRA}" ] ; then
+ c=1
+ einfo "Setting extra options: ${SYSFS_EXTRA}"
+ if cd ${CPUFREQ_SYSFS} ; then
+ local o v
+ for o in ${SYSFS_EXTRA} ; do
+ v=${o#*=}
+ o=${o%%=*}
+ echo ${v} > ${o} || break
+ done
+ c=0
+ fi
+ eend ${c}
+ : $(( ret += c ))
+ fi
+ fi
+
+ return ${ret}
+}
+
+start() {
+ change "${START_OPTS}"
+}
+
+stop() {
+ change "${STOP_OPTS}"
+}
diff --git a/sys-power/cpupower/metadata.xml b/sys-power/cpupower/metadata.xml
new file mode 100644
index 00000000..5bcecc2e
--- /dev/null
+++ b/sys-power/cpupower/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>floppym@gentoo.org</email>
+ <name>Mike Gilbert</name>
+ </maintainer>
+ <slots>
+ <subslots>Subslots correspond to major version of libcpupower</subslots>
+ </slots>
+</pkgmetadata>