depot/pkgs/by-name/au/auto-cpufreq/prevent-update.patch
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

135 lines
6.2 KiB
Diff

diff --git c/auto_cpufreq/bin/auto_cpufreq.py i/auto_cpufreq/bin/auto_cpufreq.py
index 7192366..0bf087e 100755
--- c/auto_cpufreq/bin/auto_cpufreq.py
+++ i/auto_cpufreq/bin/auto_cpufreq.py
@@ -149,41 +149,7 @@ def main(monitor, live, daemon, install, update, remove, force, config, stats, g
deploy_daemon()
deploy_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 IS_INSTALLED_WITH_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 IS_INSTALLED_WITH_AUR: 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")): 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 remove:
root_check()
if IS_INSTALLED_WITH_SNAP:
diff --git c/auto_cpufreq/core.py i/auto_cpufreq/core.py
index b51d55d..99eeed8 100755
--- c/auto_cpufreq/core.py
+++ i/auto_cpufreq/core.py
@@ -7,9 +7,8 @@ from math import isclose
from pathlib import Path
from pickle import dump, load
from re import search
-from requests import get, exceptions
from shutil import copy
-from subprocess import call, check_output, DEVNULL, getoutput, run
+from subprocess import call, DEVNULL, getoutput, run
from time import sleep
from warnings import filterwarnings
@@ -105,49 +104,7 @@ def app_version():
except Exception as e: print(repr(e))
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 = GITHUB.replace("github.com", "api.github.com/repos") + "/releases/latest"
- try:
- response = 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 (exceptions.ConnectionError, exceptions.Timeout,
- exceptions.RequestException, exceptions.HTTPError):
- 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((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
- # Handle the case where "tag_name" key doesn't exist
- else: 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 c/poetry.lock i/poetry.lock
index 0e6da84..b4936fe 100644
--- c/poetry.lock
+++ i/poetry.lock
@@ -1306,4 +1306,4 @@ test = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-it
[metadata]
lock-version = "2.0"
python-versions = "^3.8"
-content-hash = "cad3783d04e35b66b241352e76631d0a83c8df3d286b113979ba34a65847f06c"
+content-hash = "b21af52156d2d624602fe6941cf001abd7f8cf5b70b22ebfd7b7ad0dece1e39f"
diff --git c/pyproject.toml i/pyproject.toml
index 562a94b..cc44d8d 100644
--- c/pyproject.toml
+++ i/pyproject.toml
@@ -25,7 +25,6 @@ python = "^3.8"
psutil = "^6.0.0"
click = "^8.1.0"
distro = "^1.8.0"
-requests = "^2.32.3"
PyGObject = "^3.46.0"
pyinotify = {git = "https://github.com/shadeyg56/pyinotify-3.12"}