blob: 8eeb4764a2a0b58e27e4a5436c5e4f0d85a99536 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{8..11} )
DISTUTILS_USE_PEP517=setuptools
inherit distutils-r1 systemd
DESCRIPTION="Automatic CPU speed & power optimizer for Linux"
HOMEPAGE="https://github.com/AdnanHodzic/auto-cpufreq"
SRC_URI="https://github.com/AdnanHodzic/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
LICENSE="GPL-3"
KEYWORDS="~amd64"
SLOT="0"
IUSE="systemd"
RDEPEND="
dev-python/psutil
dev-python/click
dev-python/distro
"
DEPEND="${RDEPEND}"
DOCS=( README.md )
PATCHES=( "${FILESDIR}/${PN}-remove-setuptools_git_versioning.patch" )
src_prepare() {
sed -i 's|usr/local|usr|g' "scripts/${PN}.service" "scripts/${PN}-openrc" auto_cpufreq/core.py || die
distutils-r1_src_prepare
}
python_install() {
distutils-r1_python_install
exeinto "/usr/share/${PN}/scripts"
doexe scripts/cpufreqctl.sh
if use systemd; then
systemd_douserunit "scripts/${PN}.service"
else
doinitd "scripts/${PN}-openrc"
mv "${D}/etc/init.d/${PN}-openrc" "${D}/etc/init.d/${PN}" || die
fi
}
pkg_postinst() {
touch /var/log/auto-cpufreq.log
elog ""
elog "Enable auto-cpufreq daemon service at boot:"
if use systemd; then
elog "systemctl enable --now auto-cpufreq"
else
elog "rc-update add auto-cpufreq default"
fi
elog ""
elog "To view live log, run:"
elog "auto-cpufreq --stats"
}
pkg_postrm() {
# Remove auto-cpufreq log file
if [ -f "/var/log/auto-cpufreq.log" ]; then
rm /var/log/auto-cpufreq.log || die
fi
# Remove auto-cpufreq's cpufreqctl binary
# it overwrites cpufreqctl.sh
if [ -f "/usr/bin/cpufreqctl" ]; then
rm /usr/bin/cpufreqctl || die
fi
# Restore original cpufreqctl binary if backup was made
if [ -f "/usr/bin/cpufreqctl.auto-cpufreq.bak" ]; then
mv /usr/bin/cpufreqctl.auto-cpufreq.bak /usr/bin/cpufreqctl || die
fi
}
|