Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sys-power/auto-cpufreq/Manifest
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DIST auto-cpufreq-2.3.0.tar.gz 216356 BLAKE2B ac4c0f293575d7e0deb7b31437674f06e614930eeff35cc7e57cca0088e8cf928b9401fcda72d48de12ccf158181cb9290a57dd49047fe3ae9ee182507dfab12 SHA512 46438401cfc662c8b26350e8e6d8ff147d87b49b65162dbdcced5c6e2d7a4762e8d732823c92ae6da80e2b4298999a3131ff574a3ec4293bd8b65979de36e688
DIST auto-cpufreq-2.4.0.tar.gz 217070 BLAKE2B c572f6665feb55d2fc62d7cb0ec1ec5a8fd382e6745a422ab276deacd1936a6fbd4af8191725877c07958c1b89cb2daaff8cfb9c8ecdbd7cd4047e7986ce82ec SHA512 42fbf2d1a0b97b76343546d1f67c6da25e912001b521a94b7d4e4170b0b5e8e5450a08535a9f22e289ffaccffcd8c8377b22b7bb07d3e139b602f1cb924bd301
DIST auto-cpufreq-2.6.0.tar.gz 226319 BLAKE2B 990c969c154416f3df36a4976931df818590330560bb557513b5edc68a409a871c16575d35408a3f0866cd5e910bdffe3c2a8f9089484b139aec00d5c48506ce SHA512 b05ee63f9480fb60c4adea642298259168a6137dd4fe81bcc6406a690ec27e26c0b5bb03d4d3331df4bf4c30cc8d267a4a2ab254f921d883123a656519639b54
DIST auto-cpufreq-3.0.0.tar.gz 228445 BLAKE2B b6c05529c29068ff9e58c56db0ac21348e3683a9c8727f24834f060489ccd70b39c838d9aa8eab2b82969c80fe07c4f597575120b632fa4aafaecacaa0c60cc4 SHA512 01f45295e5228187a473fb555b8165eaa5c90ea6c9d69fc081515a78fdb9e7f0b7bc271056b206802c654c3a10a520e6e77a5f7748a172382431c6813ea933f0
142 changes: 142 additions & 0 deletions sys-power/auto-cpufreq/auto-cpufreq-3.0.0.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{12,13} )
DISTUTILS_USE_PEP517=poetry

inherit distutils-r1 systemd xdg desktop

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="LGPL-3+"
SLOT="0"
KEYWORDS="~amd64"

RDEPEND="
dev-python/click[${PYTHON_USEDEP}]
dev-python/distro[${PYTHON_USEDEP}]
dev-python/psutil[${PYTHON_USEDEP}]
dev-python/pyasyncore[${PYTHON_USEDEP}]
dev-python/pygobject[${PYTHON_USEDEP}]
dev-python/pyinotify[${PYTHON_USEDEP}]
dev-python/requests[${PYTHON_USEDEP}]
dev-python/urwid[${PYTHON_USEDEP}]
"
DEPEND="${RDEPEND}"

DOCS=( README.md )

src_prepare() {
default
# Update pyproject.toml to avoid dynamic_versioning in poetry
sed -i 's/poetry_dynamic_versioning.backend/poetry.core.masonry.api/' pyproject.toml || die
# Replace /usr/local/ paths with /usr/ in the source code to adhere to Gentoo standards
sed -i 's|/usr/local/share|/usr/share|g' scripts/auto-cpufreq-install.sh || die
sed -i 's|usr/local|usr|g' "scripts/${PN}.service" "scripts/${PN}-openrc" auto_cpufreq/core.py || die
sed -i 's|usr/local|usr|g' "scripts/${PN}.service" "scripts/${PN}-openrc" auto_cpufreq/gui/app.py || die
# Modify the service file to launch auto-cpufreq natively without the need for virtual environment
sed -i 's|WorkingDirectory=/opt/auto-cpufreq/venv||g' scripts/auto-cpufreq.service || die
sed -i 's|Environment=PYTHONPATH=/opt/auto-cpufreq||g' scripts/auto-cpufreq.service || die
sed -i 's|ExecStart=/opt/auto-cpufreq/venv/bin/python /opt/auto-cpufreq/venv/bin/auto-cpufreq --daemon|ExecStart=/usr/bin/auto-cpufreq --daemon|g' scripts/auto-cpufreq.service || die
# Change the path in core.py
sed -i 's|/opt/auto-cpufreq/override.pickle|/var/lib/auto-cpufreq/override.pickle|g' auto_cpufreq/core.py || die
distutils-r1_src_prepare
}

python_install() {
distutils-r1_python_install

# Create the scripts directory if it doesn't exist
dodir "/usr/share/${PN}/scripts"

# Create the directory for override.pickle
dodir /var/lib/auto-cpufreq
keepdir /var/lib/auto-cpufreq
fowners root:root /var/lib/auto-cpufreq
fperms 0755 /var/lib/auto-cpufreq

# Copy all scripts from the 'scripts' directory
for script in scripts/*; do
if [[ -f "$script" ]]; then
case "${script##*/}" in
*.sh|*.py|auto-cpufreq-*|cpufreqctl.sh)
exeinto "/usr/share/${PN}/scripts"
doexe "$script"
;;
*)
insinto "/usr/share/${PN}/scripts"
doins "$script"
;;
esac
fi
done

# Copy images
insinto "/usr/share/${PN}/images"
doins images/*

# Install icon
doicon -s 128 images/icon.png

# Install polkit policy
insinto /usr/share/polkit-1/actions
doins scripts/org.auto-cpufreq.pkexec.policy

# Install desktop file
domenu scripts/auto-cpufreq-gtk.desktop

# Install systemd service file
systemd_dounit "scripts/${PN}.service"

# Install OpenRC init script
newinitd "scripts/${PN}-openrc" "${PN}"
}

pkg_postinst() {
xdg_pkg_postinst

elog "The auto-cpufreq override file will be stored in /var/lib/auto-cpufreq/override.pickle"

# Create log file
touch /var/log/auto-cpufreq.log
elog ""
elog "Enable auto-cpufreq daemon service at boot:"
elog "systemd: systemctl enable --now auto-cpufreq"
elog "openrc: rc-update add auto-cpufreq default"
elog ""
elog "To view live log, run:"
elog "auto-cpufreq --stats"
}

pkg_postrm() {
xdg_pkg_postrm

# Remove the override.pickle file and directory
if [[ -d "${EROOT}/var/lib/auto-cpufreq" ]]; then
rm -rf "${EROOT}"/var/lib/auto-cpufreq || die
fi

# Remove auto-cpufreq log file
if [[ -f "${EROOT}/var/log/auto-cpufreq.log" ]]; then
rm "${EROOT}"/var/log/auto-cpufreq.log || die
fi

# Remove auto-cpufreq-install script
if [[ -f "${EROOT}/usr/bin/auto-cpufreq-install" ]]; then
rm "${EROOT}"/usr/bin/auto-cpufreq-install || die
fi

# Restore original cpufreqctl binary if backup was made
if [[ -f "${EROOT}/usr/bin/cpufreqctl.auto-cpufreq.bak" ]]; then
mv "${EROOT}"/usr/bin/cpufreqctl.auto-cpufreq{.bak,} || die
fi
# Remove auto-cpufreq's cpufreqctl binary
# it overwrites cpufreqctl.sh
if [[ -f "${EROOT}/usr/bin/cpufreqctl" ]]; then
rm "${EROOT}"/usr/bin/cpufreqctl || die
fi
}