diff options
author | tomberek <tomberek@users.noreply.github.com> | 2024-05-31 19:11:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-31 19:11:01 -0700 |
commit | cc6d856e654f54d3d40994bb0420ec9003a9ac9b (patch) | |
tree | db3840c3bd081a3bd7dc9c94690dec893b9b84ad /pkgs | |
parent | 6491a4bc04b0a0ee40aaddc30477c1c77e3611ae (diff) | |
parent | aa31715677f0ff3d0c4b430d65c4a7ff8f0eb768 (diff) |
Merge pull request #315383 from isabelroses/auto-cpufreq
auto-cpufreq: 1.9.9 -> 2.3.0
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/by-name/au/auto-cpufreq/fix-version-output.patch (renamed from pkgs/tools/system/auto-cpufreq/fix-version-output.patch) | 22 | ||||
-rw-r--r-- | pkgs/by-name/au/auto-cpufreq/package.nix | 100 | ||||
-rw-r--r-- | pkgs/by-name/au/auto-cpufreq/prevent-install-and-copy.patch (renamed from pkgs/tools/system/auto-cpufreq/prevent-install-and-copy.patch) | 105 | ||||
-rw-r--r-- | pkgs/by-name/au/auto-cpufreq/prevent-update.patch | 152 | ||||
-rw-r--r-- | pkgs/tools/system/auto-cpufreq/default.nix | 49 | ||||
-rw-r--r-- | pkgs/tools/system/auto-cpufreq/prevent-update.patch | 60 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 2 |
7 files changed, 315 insertions, 175 deletions
diff --git a/pkgs/tools/system/auto-cpufreq/fix-version-output.patch b/pkgs/by-name/au/auto-cpufreq/fix-version-output.patch index fad9f091da40e..be21ca889081d 100644 --- a/pkgs/tools/system/auto-cpufreq/fix-version-output.patch +++ b/pkgs/by-name/au/auto-cpufreq/fix-version-output.patch @@ -1,19 +1,17 @@ diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py -index 99397a9..f3ef28f 100755 +index 58cedb7..89e77a4 100755 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py -@@ -144,26 +144,10 @@ except PermissionError: - +@@ -136,26 +136,8 @@ except PermissionError: + # display running version of auto-cpufreq def app_version(): -+ print("auto-cpufreq version: @version@") -+ print("Git commit: v@version@") - +- - print("auto-cpufreq version: ", end="") - +- - # snap package - if os.getenv("PKG_MARKER") == "SNAP": -- print(getoutput("echo \(Snap\) $SNAP_VERSION")) +- print(getoutput(r"echo \(Snap\) $SNAP_VERSION")) - # aur package - elif dist_name in ["arch", "manjaro", "garuda"]: - aur_pkg_check = call("pacman -Qs auto-cpufreq > /dev/null", shell=True) @@ -28,6 +26,8 @@ index 99397a9..f3ef28f 100755 - except Exception as e: - print(repr(e)) - pass - def verify_update(): - # Specify the repository and package name - # IT IS IMPORTANT TO THAT IF THE REPOSITORY STRUCTURE IS CHANGED, THE FOLLOWING FUNCTION NEEDS TO BE UPDATED ACCORDINGLY \ No newline at end of file ++ print("auto-cpufreq version: @version@") ++ print("Git commit: v@version@") + + def check_for_update(): + # returns True if a new release is available from the GitHub repo diff --git a/pkgs/by-name/au/auto-cpufreq/package.nix b/pkgs/by-name/au/auto-cpufreq/package.nix new file mode 100644 index 0000000000000..4121096359c83 --- /dev/null +++ b/pkgs/by-name/au/auto-cpufreq/package.nix @@ -0,0 +1,100 @@ +{ + lib, + python3Packages, + fetchFromGitHub, + substituteAll, + gobject-introspection, + wrapGAppsHook3, + gtk3, +}: +python3Packages.buildPythonPackage rec { + pname = "auto-cpufreq"; + version = "2.3.0"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "AdnanHodzic"; + repo = "auto-cpufreq"; + rev = "v${version}"; + hash = "sha256-Bet/WOVveLIA+0Mvly4AsielR+r/AJXIgHdWrtc7i/U="; + }; + + nativeBuildInputs = [ + gobject-introspection + wrapGAppsHook3 + ]; + + buildInputs = [ + gtk3 + python3Packages.poetry-core + ]; + + propagatedBuildInputs = with python3Packages; [ + click + distro + psutil + pygobject3 + poetry-dynamic-versioning + setuptools + pyinotify + ]; + + doCheck = false; + pythonImportsCheck = [ "auto_cpufreq" ]; + + patches = [ + # hardcodes version output + (substituteAll { + src = ./fix-version-output.patch; + inherit version; + }) + + # patch to prevent script copying and to disable install + ./prevent-install-and-copy.patch + # patch to prevent update + ./prevent-update.patch + ]; + + postPatch = '' + substituteInPlace auto_cpufreq/core.py \ + --replace-fail '/opt/auto-cpufreq/override.pickle' /var/run/override.pickle + substituteInPlace scripts/org.auto-cpufreq.pkexec.policy \ + --replace-fail "/opt/auto-cpufreq/venv/bin/auto-cpufreq" $out/bin/auto-cpufreq + substituteInPlace auto_cpufreq/gui/app.py auto_cpufreq/gui/objects.py \ + --replace-fail "/usr/local/share/auto-cpufreq/images/icon.png" $out/share/pixmaps/auto-cpufreq.png + substituteInPlace auto_cpufreq/gui/app.py \ + --replace-fail "/usr/local/share/auto-cpufreq/scripts/style.css" $out/share/auto-cpufreq/scripts/style.css + ''; + + postInstall = '' + # copy script manually + cp ${src}/scripts/cpufreqctl.sh $out/bin/cpufreqctl.auto-cpufreq + + # copy css file + mkdir -p $out/share/auto-cpufreq/scripts + cp scripts/style.css $out/share/auto-cpufreq/scripts/style.css + + # systemd service + mkdir -p $out/lib/systemd/system + cp ${src}/scripts/auto-cpufreq.service $out/lib/systemd/system + + # desktop icon + mkdir -p $out/share/applications + mkdir $out/share/pixmaps + cp scripts/auto-cpufreq-gtk.desktop $out/share/applications + cp images/icon.png $out/share/pixmaps/auto-cpufreq.python3Packages + + # polkit policy + mkdir -p $out/share/polkit-1/actions + cp scripts/org.auto-cpufreq.pkexec.policy $out/share/polkit-1/actions + ''; + + meta = { + mainProgram = "auto-cpufreq"; + homepage = "https://github.com/AdnanHodzic/auto-cpufreq"; + description = "Automatic CPU speed & power optimizer for Linux"; + license = lib.licenses.lgpl3Plus; + platforms = lib.platforms.linux; + maintainers = with lib.maintainers; [ Technical27 ]; + }; +} diff --git a/pkgs/tools/system/auto-cpufreq/prevent-install-and-copy.patch b/pkgs/by-name/au/auto-cpufreq/prevent-install-and-copy.patch index 9b5bffb5591ee..2b3c9de1b6b07 100644 --- a/pkgs/tools/system/auto-cpufreq/prevent-install-and-copy.patch +++ b/pkgs/by-name/au/auto-cpufreq/prevent-install-and-copy.patch @@ -1,8 +1,56 @@ +diff --git a/auto_cpufreq/bin/auto_cpufreq.py b/auto_cpufreq/bin/auto_cpufreq.py +index 4343b8d..dc286f6 100755 +--- a/auto_cpufreq/bin/auto_cpufreq.py ++++ b/auto_cpufreq/bin/auto_cpufreq.py +@@ -199,41 +199,9 @@ def main(config, daemon, debug, update, install, remove, live, log, monitor, sta + print("https://github.com/AdnanHodzic/auto-cpufreq/#donate") + footer() + elif install: +- if os.getenv("PKG_MARKER") == "SNAP": +- root_check() +- running_daemon_check() +- gnome_power_detect_snap() +- tlp_service_detect_snap() +- bluetooth_notif_snap() +- gov_check() +- run("snapctl set daemon=enabled", shell=True) +- run("snapctl start --enable auto-cpufreq", shell=True) +- deploy_complete_msg() +- else: +- root_check() +- running_daemon_check() +- gov_check() +- deploy_daemon() +- deploy_complete_msg() ++ print("install is disabled in the nix package") + elif remove: +- if os.getenv("PKG_MARKER") == "SNAP": +- root_check() +- run("snapctl set daemon=disabled", shell=True) +- run("snapctl stop --disable auto-cpufreq", shell=True) +- if auto_cpufreq_stats_path.exists(): +- if auto_cpufreq_stats_file is not None: +- auto_cpufreq_stats_file.close() +- +- auto_cpufreq_stats_path.unlink() +- # ToDo: +- # {the following snippet also used in --update, update it there too(if required)} +- # * undo bluetooth boot disable +- gnome_power_rm_reminder_snap() +- remove_complete_msg() +- else: +- root_check() +- remove_daemon() +- remove_complete_msg() ++ print("remove is disabled in the nix package") + elif update: + root_check() + custom_dir = "/opt/auto-cpufreq/source" diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py -index 99397a9..48a377a 100755 +index 58cedb7..c50b0e1 100755 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py -@@ -350,30 +334,13 @@ def get_current_gov(): +@@ -391,30 +391,13 @@ def get_current_gov(): def cpufreqctl(): @@ -37,7 +85,7 @@ index 99397a9..48a377a 100755 def footer(l=79): print("\n" + "-" * l + "\n") -@@ -400,30 +367,8 @@ def remove_complete_msg(): +@@ -441,30 +424,8 @@ def remove_complete_msg(): def deploy_daemon(): @@ -70,7 +118,7 @@ index 99397a9..48a377a 100755 def deploy_daemon_performance(): -@@ -463,40 +408,7 @@ def deploy_daemon_performance(): +@@ -504,40 +465,7 @@ def deploy_daemon_performance(): # remove auto-cpufreq daemon def remove_daemon(): @@ -112,52 +160,3 @@ index 99397a9..48a377a 100755 def gov_check(): - -diff --git a/bin/auto-cpufreq b/bin/auto-cpufreq -index b89d925..b73974c 100755 ---- a/bin/auto-cpufreq -+++ b/bin/auto-cpufreq -@@ -189,41 +189,9 @@ - print("https://github.com/AdnanHodzic/auto-cpufreq/#donate") - footer() - elif install: -- if os.getenv("PKG_MARKER") == "SNAP": -- root_check() -- running_daemon_check() -- gnome_power_detect_snap() -- tlp_service_detect_snap() -- bluetooth_notif_snap() -- gov_check() -- run("snapctl set daemon=enabled", shell=True) -- run("snapctl start --enable auto-cpufreq", shell=True) -- deploy_complete_msg() -- else: -- root_check() -- running_daemon_check() -- gov_check() -- deploy_daemon() -- deploy_complete_msg() -+ print("install is disabled in the nix package") - elif remove: -- if os.getenv("PKG_MARKER") == "SNAP": -- root_check() -- run("snapctl set daemon=disabled", shell=True) -- run("snapctl stop --disable auto-cpufreq", shell=True) -- if auto_cpufreq_stats_path.exists(): -- if auto_cpufreq_stats_file is not None: -- auto_cpufreq_stats_file.close() -- -- auto_cpufreq_stats_path.unlink() -- # ToDo: -- # {the following snippet also used in --update, update it there too(if required)} -- # * undo bluetooth boot disable -- gnome_power_rm_reminder_snap() -- remove_complete_msg() -- else: -- root_check() -- remove_daemon() -- remove_complete_msg() -+ print("remove is disabled in the nix package") - elif update: - root_check() - if os.getenv("PKG_MARKER") == "SNAP": \ No newline at end of file diff --git a/pkgs/by-name/au/auto-cpufreq/prevent-update.patch b/pkgs/by-name/au/auto-cpufreq/prevent-update.patch new file mode 100644 index 0000000000000..840c7230313d7 --- /dev/null +++ b/pkgs/by-name/au/auto-cpufreq/prevent-update.patch @@ -0,0 +1,152 @@ +diff --git a/auto_cpufreq/bin/auto_cpufreq.py b/auto_cpufreq/bin/auto_cpufreq.py +index 4343b8d..183c2e9 100755 +--- a/auto_cpufreq/bin/auto_cpufreq.py ++++ b/auto_cpufreq/bin/auto_cpufreq.py +@@ -235,47 +235,7 @@ def main(config, daemon, debug, update, install, remove, live, log, monitor, sta + remove_daemon() + remove_complete_msg() + elif update: +- root_check() +- custom_dir = "/opt/auto-cpufreq/source" +- for arg in sys.argv: +- if arg.startswith("--update="): +- custom_dir = arg.split("=")[1] +- sys.argv.remove(arg) +- +- if "--update" in sys.argv: +- update = True +- sys.argv.remove("--update") +- if len(sys.argv) == 2: +- custom_dir = sys.argv[1] +- +- if os.getenv("PKG_MARKER") == "SNAP": +- print("Detected auto-cpufreq was installed using snap") +- # refresh snap directly using this command +- # path wont work in this case +- +- print("Please update using snap package manager, i.e: `sudo snap refresh auto-cpufreq`.") +- #check for AUR +- elif subprocess.run(["bash", "-c", "command -v pacman >/dev/null 2>&1"]).returncode == 0 and subprocess.run(["bash", "-c", "pacman -Q auto-cpufreq >/dev/null 2>&1"]).returncode == 0: +- print("Arch-based distribution with AUR support detected. Please refresh auto-cpufreq using your AUR helper.") +- else: +- is_new_update = check_for_update() +- if not is_new_update: +- return +- ans = input("Do you want to update auto-cpufreq to the latest release? [Y/n]: ").strip().lower() +- if not os.path.exists(custom_dir): +- os.makedirs(custom_dir) +- if os.path.exists(os.path.join(custom_dir, "auto-cpufreq")): +- shutil.rmtree(os.path.join(custom_dir, "auto-cpufreq")) +- if ans in ['', 'y', 'yes']: +- remove_daemon() +- remove_complete_msg() +- new_update(custom_dir) +- print("enabling daemon") +- run(["auto-cpufreq", "--install"]) +- print("auto-cpufreq is installed with the latest version") +- run(["auto-cpufreq", "--version"]) +- else: +- print("Aborted") ++ print("update is disabled in the nix package") + + elif completions: + if completions == "bash": +diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py +index 58cedb7..8b44712 100755 +--- a/auto_cpufreq/core.py ++++ b/auto_cpufreq/core.py +@@ -17,8 +17,7 @@ import importlib.metadata + from math import isclose + from pathlib import Path + from shutil import which +-from subprocess import getoutput, call, run, check_output, DEVNULL +-import requests ++from subprocess import getoutput, call, run, DEVNULL + import re + + # execution timestamp used in countdown func +@@ -158,55 +157,7 @@ def app_version(): + pass + + def check_for_update(): +- # returns True if a new release is available from the GitHub repo +- +- # Specify the repository and package name +- # IT IS IMPORTANT TO THAT IF THE REPOSITORY STRUCTURE IS CHANGED, THE FOLLOWING FUNCTION NEEDS TO BE UPDATED ACCORDINGLY +- # Fetch the latest release information from GitHub API +- latest_release_url = f"https://api.github.com/repos/AdnanHodzic/auto-cpufreq/releases/latest" +- try: +- response = requests.get(latest_release_url) +- if response.status_code == 200: +- latest_release = response.json() +- else: +- message = response.json().get("message") +- print("Error fetching recent release!") +- if message is not None and message.startswith("API rate limit exceeded"): +- print("GitHub Rate limit exceeded. Please try again later within 1 hour or use different network/VPN.") +- else: +- print("Unexpected status code:", response.status_code) +- return False +- except (requests.exceptions.ConnectionError, requests.exceptions.Timeout, +- requests.exceptions.RequestException, requests.exceptions.HTTPError) as err: +- print("Error Connecting to server!") +- return False +- +- latest_version = latest_release.get("tag_name") +- +- if latest_version is not None: +- # Get the current version of auto-cpufreq +- # Extract version number from the output string +- output = check_output(['auto-cpufreq', '--version']).decode('utf-8') +- try: +- version_line = next((re.search(r'\d+\.\d+\.\d+', line).group() for line in output.split('\n') if line.startswith('auto-cpufreq version')), None) +- except AttributeError: +- print("Error Retrieving Current Version!") +- exit(1) +- installed_version = "v" + version_line +- #Check whether the same is installed or not +- # Compare the latest version with the installed version and perform update if necessary +- if latest_version == installed_version: +- print("auto-cpufreq is up to date") +- return False +- else: +- print(f"Updates are available,\nCurrent version: {installed_version}\nLatest version: {latest_version}") +- print("Note that your previous custom settings might be erased with the following update") +- return True +- else: +- # Handle the case where "tag_name" key doesn't exist +- print("Malformed Released data!\nReinstall manually or Open an issue on GitHub for help!") +- +- ++ pass + + def new_update(custom_dir): + os.chdir(custom_dir) +diff --git a/poetry.lock b/poetry.lock +index 2a99ca6..9bc26e2 100644 +--- a/poetry.lock ++++ b/poetry.lock +@@ -1,4 +1,4 @@ +-# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. ++# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. + + [[package]] + name = "attrs" +@@ -1300,4 +1300,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p + [metadata] + lock-version = "2.0" + python-versions = "^3.8" +-content-hash = "ee73b2db6a43cac87120f38c93d0a8a297bec52f1346b55bc0ca2992aa464482" ++content-hash = "1ba0c404ffea01a611e7c74f9c104de44a914b0a6fad2350470f15880931ae42" +diff --git a/pyproject.toml b/pyproject.toml +index 876d80c..7190356 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -25,7 +25,6 @@ python = "^3.8" + psutil = {git = "https://github.com/giampaolo/psutil.git", rev = "4cf56e08c1bc883ec89758834b50954380759858"} + click = "^8.1.0" + distro = "^1.8.0" +-requests = "^2.31.0" + PyGObject = "^3.46.0" + pyinotify = {git = "https://github.com/shadeyg56/pyinotify-3.12"} + diff --git a/pkgs/tools/system/auto-cpufreq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix deleted file mode 100644 index 4c15908eab191..0000000000000 --- a/pkgs/tools/system/auto-cpufreq/default.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ lib, python3Packages, fetchFromGitHub, substituteAll }: - -python3Packages.buildPythonPackage rec { - pname = "auto-cpufreq"; - version = "1.9.9"; - - src = fetchFromGitHub { - owner = "AdnanHodzic"; - repo = pname; - rev = "v${version}"; - sha256 = "sha256-D/5pwE2V+yXj92ECOUcl/dajMDbvVdz9YNJrl2Pzvts="; - }; - - propagatedBuildInputs = with python3Packages; [ setuptools-git-versioning click distro psutil ]; - - doCheck = false; - pythonImportsCheck = [ "auto_cpufreq" ]; - - patches = [ - # hardcodes version output - (substituteAll { - src = ./fix-version-output.patch; - inherit version; - }) - - # patch to prevent script copying and to disable install - ./prevent-install-and-copy.patch - # patch to prevent update - ./prevent-update.patch - ]; - - postInstall = '' - # copy script manually - cp ${src}/scripts/cpufreqctl.sh $out/bin/cpufreqctl.auto-cpufreq - - # systemd service - mkdir -p $out/lib/systemd/system - cp ${src}/scripts/auto-cpufreq.service $out/lib/systemd/system - ''; - - meta = with lib; { - mainProgram = "${pname}"; - homepage = "https://github.com/AdnanHodzic/auto-cpufreq"; - description = "Automatic CPU speed & power optimizer for Linux"; - license = licenses.lgpl3Plus; - platforms = platforms.linux; - maintainers = [ maintainers.Technical27 ]; - }; -} diff --git a/pkgs/tools/system/auto-cpufreq/prevent-update.patch b/pkgs/tools/system/auto-cpufreq/prevent-update.patch deleted file mode 100644 index 10da9fec97855..0000000000000 --- a/pkgs/tools/system/auto-cpufreq/prevent-update.patch +++ /dev/null @@ -1,60 +0,0 @@ -diff --git a/requirements.txt b/requirements.txt -index f492cac..e61d1a4 100755 ---- a/requirements.txt -+++ b/requirements.txt -@@ -2,4 +2,3 @@ - psutil - click - distro --requests - -diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py -index 99397a9..697fb68 100755 ---- a/auto_cpufreq/core.py -+++ b/auto_cpufreq/core.py -@@ -18,7 +18,6 @@ from math import isclose - from pathlib import Path - from shutil import which - from subprocess import getoutput, call, run, check_output, DEVNULL --import requests - import re - - # execution timestamp used in countdown func - -diff --git a/bin/auto-cpufreq b/bin/auto-cpufreq -index b89d925..b73974c 100755 ---- a/bin/auto-cpufreq -+++ b/bin/auto-cpufreq -@@ -193,31 +193,7 @@ - elif remove: - print("remove is disabled in the nix package") - elif update: -- root_check() -- if os.getenv("PKG_MARKER") == "SNAP": -- print("Detected auto-cpufreq was installed using snap") -- # refresh snap directly using this command -- -- print("Please update using snap package manager, i.e: `sudo snap refresh auto-cpufreq`.") -- #check for AUR -- elif subprocess.run(["bash", "-c", "command -v yay >/dev/null 2>&1"]).returncode == 0 or subprocess.run(["bash", "-c", "command -v pacman >/dev/null 2>&1"]).returncode == 0: -- print("Arch-based distribution with AUR support detected. Please refresh auto-cpufreq using your AUR helper.") -- else: -- verify_update() -- ans = input ("Do you want to update auto-cpufreq to the latest release? [y/n]: ") -- valid_options = ['y', 'Y', 'yes', 'YES', 'Yes'] -- if ans.lower() in valid_options: -- remove_daemon() -- remove_complete_msg() -- new_update() -- else: -- print("incorrect input\n") -- print("Aborted") -- print("enabling daemon") -- run(["auto-cpufreq", "--install"]) -- print("auto-cpufreq is installed with the latest version") -- app_version() -- -+ print("update is disabled in the nix package") - - - if __name__ == "__main__": \ No newline at end of file diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a08430fcb777c..217963aff883b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -40172,8 +40172,6 @@ with pkgs; ssh-tools = callPackage ../applications/misc/ssh-tools { }; - auto-cpufreq = callPackage ../tools/system/auto-cpufreq { }; - thermald = callPackage ../tools/system/thermald { }; therion = callPackage ../applications/misc/therion { }; |