From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A79D9159C9B for ; Sun, 11 Aug 2024 18:42:57 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EC827E2C36; Sun, 11 Aug 2024 18:42:56 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D707DE2C36 for ; Sun, 11 Aug 2024 18:42:56 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0DFCB343143 for ; Sun, 11 Aug 2024 18:42:56 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2AD5F1ED7 for ; Sun, 11 Aug 2024 18:42:54 +0000 (UTC) From: "Michal Vu" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michal Vu" Message-ID: <1723401763.33f99484aa7eb2c02fe59d23c46d7cb10a17846e.saigon-tech@gentoo> Subject: [gentoo-commits] repo/proj/guru:dev commit in: sys-power/auto-cpufreq/ X-VCS-Repository: repo/proj/guru X-VCS-Files: sys-power/auto-cpufreq/auto-cpufreq-2.3.0.ebuild X-VCS-Directories: sys-power/auto-cpufreq/ X-VCS-Committer: saigon-tech X-VCS-Committer-Name: Michal Vu X-VCS-Revision: 33f99484aa7eb2c02fe59d23c46d7cb10a17846e X-VCS-Branch: dev Date: Sun, 11 Aug 2024 18:42:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: c21fbf92-5ff3-4351-b10e-52faddab3b07 X-Archives-Hash: 162bd1d711d7645e40d3195559123378 commit: 33f99484aa7eb2c02fe59d23c46d7cb10a17846e Author: Michal Vu tuta io> AuthorDate: Sun Aug 11 18:42:21 2024 +0000 Commit: Michal Vu tuta io> CommitDate: Sun Aug 11 18:42:43 2024 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=33f99484 sys-power/auto-cpufreq: Adding auto-cpufreq-2.3.0 Signed-off-by: Michal Vu tuta.io> sys-power/auto-cpufreq/auto-cpufreq-2.3.0.ebuild | 147 +++++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/sys-power/auto-cpufreq/auto-cpufreq-2.3.0.ebuild b/sys-power/auto-cpufreq/auto-cpufreq-2.3.0.ebuild new file mode 100644 index 000000000..fb159721e --- /dev/null +++ b/sys-power/auto-cpufreq/auto-cpufreq-2.3.0.ebuild @@ -0,0 +1,147 @@ +# Copyright 1999-2024 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( python3_{10..13} ) +DISTUTILS_USE_PEP517=poetry + +inherit distutils-r1 systemd xdg-utils 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="GPL-3" +SLOT="0" +KEYWORDS="~amd64" + +RDEPEND=" + dev-python/click[${PYTHON_USEDEP}] + dev-python/distro[${PYTHON_USEDEP}] + dev-python/psutil[${PYTHON_USEDEP}] + dev-python/pygobject[${PYTHON_USEDEP}] + dev-python/pyinotify[${PYTHON_USEDEP}] + dev-python/requests[${PYTHON_USEDEP}] +" +DEPEND="${RDEPEND}" +BDEPEND=" + dev-python/poetry-core[${PYTHON_USEDEP}] +" + +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_icon_cache_update + xdg_desktop_database_update + + elog "Updating XDG database" + + 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_icon_cache_update + xdg_desktop_database_update + + # Remove the polkit policy + if [ -f "/usr/share/polkit-1/actions/org.auto-cpufreq.pkexec.policy" ]; then + rm -rf /usr/share/polkit-1/actions/org.auto-cpufreq.pkexec.policy || die + fi + + # Remove the override.pickle file and directory + if [[ -d "/var/lib/auto-cpufreq" ]]; then + rm -rf /var/lib/auto-cpufreq + fi + + # 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 +}