mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 15:11:25 +00:00
auto-cpufreq: 1.7.1 -> 1.9.9 (#253595)
* auto-cpufreq: 1.7.1 -> 1.9.9 * fix test * set `meta.buildDocsInSandbox = false` required because description depends on restricted module argument pkgs
This commit is contained in:
parent
8feb7fa2a5
commit
7f2ec624dd
@ -15,8 +15,7 @@ in {
|
||||
description = lib.mdDoc ''
|
||||
Configuration for `auto-cpufreq`.
|
||||
|
||||
See its [example configuration file] for supported settings.
|
||||
[example configuration file]: https://github.com/AdnanHodzic/auto-cpufreq/blob/master/auto-cpufreq.conf-example
|
||||
The available options can be found in [the example configuration file](https://github.com/AdnanHodzic/auto-cpufreq/blob/v${pkgs.auto-cpufreq.version}/auto-cpufreq.conf-example).
|
||||
'';
|
||||
|
||||
default = {};
|
||||
@ -35,6 +34,7 @@ in {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = with pkgs; [ bash coreutils ];
|
||||
|
||||
serviceConfig.WorkingDirectory = "";
|
||||
serviceConfig.ExecStart = [
|
||||
""
|
||||
"${lib.getExe pkgs.auto-cpufreq} --daemon --config ${cfgFile}"
|
||||
@ -42,4 +42,7 @@ in {
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# uses attributes of the linked package
|
||||
meta.buildDocsInSandbox = false;
|
||||
}
|
||||
|
@ -2,16 +2,16 @@
|
||||
|
||||
python3Packages.buildPythonPackage rec {
|
||||
pname = "auto-cpufreq";
|
||||
version = "1.7.1";
|
||||
version = "1.9.9";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "AdnanHodzic";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
sha256 = "1r27ydv258c6pc82za0wq8q8fj0j3r50c8wxc6r7dwr6wx8q3asx";
|
||||
sha256 = "sha256-D/5pwE2V+yXj92ECOUcl/dajMDbvVdz9YNJrl2Pzvts=";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = with python3Packages; [ click distro psutil ];
|
||||
propagatedBuildInputs = with python3Packages; [ setuptools-git-versioning click distro psutil ];
|
||||
|
||||
doCheck = false;
|
||||
pythonImportsCheck = [ "auto_cpufreq" ];
|
||||
@ -25,6 +25,8 @@ python3Packages.buildPythonPackage rec {
|
||||
|
||||
# patch to prevent script copying and to disable install
|
||||
./prevent-install-and-copy.patch
|
||||
# patch to prevent update
|
||||
./prevent-update.patch
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
@ -34,15 +36,14 @@ python3Packages.buildPythonPackage rec {
|
||||
# systemd service
|
||||
mkdir -p $out/lib/systemd/system
|
||||
cp ${src}/scripts/auto-cpufreq.service $out/lib/systemd/system
|
||||
substituteInPlace $out/lib/systemd/system/auto-cpufreq.service --replace "/usr/local" $out
|
||||
'';
|
||||
|
||||
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 ];
|
||||
mainProgram = "auto-cpufreq";
|
||||
};
|
||||
}
|
||||
|
@ -1,37 +1,33 @@
|
||||
diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py
|
||||
index 99397a9..f3ef28f 100755
|
||||
--- a/auto_cpufreq/core.py
|
||||
+++ b/auto_cpufreq/core.py
|
||||
@@ -68,32 +68,8 @@ dist_name = distro.id()
|
||||
@@ -144,26 +144,10 @@ except PermissionError:
|
||||
|
||||
# display running version of auto-cpufreq
|
||||
def app_version():
|
||||
-
|
||||
- print("auto-cpufreq 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("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)
|
||||
- if aur_pkg_check == 1:
|
||||
- print(
|
||||
- "Git commit:",
|
||||
- check_output(["git", "describe", "--always"]).strip().decode(),
|
||||
- )
|
||||
- print(get_formatted_version())
|
||||
- else:
|
||||
- print(getoutput("pacman -Qi auto-cpufreq | grep Version"))
|
||||
- else:
|
||||
- # source code (auto-cpufreq-installer)
|
||||
- try:
|
||||
- print(
|
||||
- "Git commit:",
|
||||
- check_output(["git", "describe", "--always"]).strip().decode(),
|
||||
- )
|
||||
- print(get_formatted_version())
|
||||
- except Exception as e:
|
||||
- print(repr(e))
|
||||
- pass
|
||||
+ print("auto-cpufreq version: @version@")
|
||||
+ print("Git commit: v@version@")
|
||||
|
||||
|
||||
def app_res_use():
|
||||
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
|
@ -1,8 +1,8 @@
|
||||
diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py
|
||||
index 83d0d64..04b5035 100644
|
||||
index 99397a9..48a377a 100755
|
||||
--- a/auto_cpufreq/core.py
|
||||
+++ b/auto_cpufreq/core.py
|
||||
@@ -204,35 +204,13 @@ def get_current_gov():
|
||||
@@ -350,30 +334,13 @@ def get_current_gov():
|
||||
|
||||
|
||||
def cpufreqctl():
|
||||
@ -15,14 +15,8 @@ index 83d0d64..04b5035 100644
|
||||
- pass
|
||||
- else:
|
||||
- # deploy cpufreqctl.auto-cpufreq script
|
||||
- if os.path.isfile("/usr/bin/cpufreqctl"):
|
||||
- shutil.copy(
|
||||
- SCRIPTS_DIR / "cpufreqctl.sh", "/usr/bin/cpufreqctl.auto-cpufreq"
|
||||
- )
|
||||
- else:
|
||||
- shutil.copy(
|
||||
- SCRIPTS_DIR / "cpufreqctl.sh", "/usr/bin/cpufreqctl.auto-cpufreq"
|
||||
- )
|
||||
- if not os.path.isfile("/usr/local/bin/cpufreqctl.auto-cpufreq"):
|
||||
- shutil.copy(SCRIPTS_DIR / "cpufreqctl.sh", "/usr/local/bin/cpufreqctl.auto-cpufreq")
|
||||
+ # scripts are already in the correct place
|
||||
+ pass
|
||||
|
||||
@ -35,14 +29,15 @@ index 83d0d64..04b5035 100644
|
||||
- if os.getenv("PKG_MARKER") == "SNAP":
|
||||
- pass
|
||||
- else:
|
||||
- if os.path.isfile("/usr/bin/cpufreqctl.auto-cpufreq"):
|
||||
- os.remove("/usr/bin/cpufreqctl.auto-cpufreq")
|
||||
- if os.path.isfile("/usr/local/bin/cpufreqctl.auto-cpufreq"):
|
||||
- os.remove("/usr/local/bin/cpufreqctl.auto-cpufreq")
|
||||
-
|
||||
+ # no need to restore
|
||||
+ pass
|
||||
|
||||
|
||||
def footer(l=79):
|
||||
@@ -276,76 +254,13 @@ def remove_complete_msg():
|
||||
print("\n" + "-" * l + "\n")
|
||||
@@ -400,30 +367,8 @@ def remove_complete_msg():
|
||||
|
||||
|
||||
def deploy_daemon():
|
||||
@ -51,62 +46,58 @@ index 83d0d64..04b5035 100644
|
||||
- # deploy cpufreqctl script func call
|
||||
- cpufreqctl()
|
||||
-
|
||||
- print("* Turn off bluetooth on boot")
|
||||
- btconf = Path("/etc/bluetooth/main.conf")
|
||||
- try:
|
||||
- orig_set = "AutoEnable=true"
|
||||
- change_set = "AutoEnable=false"
|
||||
- with btconf.open(mode="r+") as f:
|
||||
- content = f.read()
|
||||
- f.seek(0)
|
||||
- f.truncate()
|
||||
- f.write(content.replace(orig_set, change_set))
|
||||
- except Exception as e:
|
||||
- print(f"\nERROR:\nWas unable to turn off bluetooth on boot\n{repr(e)}")
|
||||
- # turn off bluetooth on boot
|
||||
- bluetooth_disable()
|
||||
-
|
||||
- auto_cpufreq_stats_path.touch(exist_ok=True)
|
||||
-
|
||||
- print("\n* Deploy auto-cpufreq install script")
|
||||
- shutil.copy(
|
||||
- SCRIPTS_DIR / "auto-cpufreq-install.sh", "/usr/bin/auto-cpufreq-install"
|
||||
- )
|
||||
- shutil.copy(SCRIPTS_DIR / "auto-cpufreq-install.sh", "/usr/local/bin/auto-cpufreq-install")
|
||||
-
|
||||
- print("\n* Deploy auto-cpufreq remove script")
|
||||
- shutil.copy(SCRIPTS_DIR / "auto-cpufreq-remove.sh", "/usr/bin/auto-cpufreq-remove")
|
||||
- shutil.copy(SCRIPTS_DIR / "auto-cpufreq-remove.sh", "/usr/local/bin/auto-cpufreq-remove")
|
||||
-
|
||||
- call("/usr/bin/auto-cpufreq-install", shell=True)
|
||||
- # output warning if gnome power profile is running
|
||||
- gnome_power_detect_install()
|
||||
- gnome_power_svc_disable()
|
||||
-
|
||||
- # output warning if TLP service is detected
|
||||
- tlp_service_detect()
|
||||
-
|
||||
- call("/usr/local/bin/auto-cpufreq-install", shell=True)
|
||||
+ # prevent needless copying and system changes
|
||||
+ pass
|
||||
|
||||
|
||||
def deploy_daemon_performance():
|
||||
@@ -463,40 +408,7 @@ def deploy_daemon_performance():
|
||||
|
||||
# remove auto-cpufreq daemon
|
||||
def remove():
|
||||
def remove_daemon():
|
||||
-
|
||||
- # check if auto-cpufreq is installed
|
||||
- if not os.path.exists("/usr/bin/auto-cpufreq-remove"):
|
||||
- if not os.path.exists("/usr/local/bin/auto-cpufreq-remove"):
|
||||
- print("\nauto-cpufreq daemon is not installed.\n")
|
||||
- sys.exit(1)
|
||||
-
|
||||
- print("\n" + "-" * 21 + " Removing auto-cpufreq daemon " + "-" * 22 + "\n")
|
||||
-
|
||||
- print("* Turn on bluetooth on boot")
|
||||
- btconf = "/etc/bluetooth/main.conf"
|
||||
- try:
|
||||
- orig_set = "AutoEnable=true"
|
||||
- change_set = "AutoEnable=false"
|
||||
- with open(btconf, "r+") as f:
|
||||
- content = f.read()
|
||||
- f.seek(0)
|
||||
- f.truncate()
|
||||
- f.write(content.replace(change_set, orig_set))
|
||||
- except Exception as e:
|
||||
- print(f"\nERROR:\nWas unable to turn on bluetooth on boot\n{repr(e)}")
|
||||
- # turn on bluetooth on boot
|
||||
- bluetooth_enable()
|
||||
-
|
||||
- # run auto-cpufreq daemon install script
|
||||
- call("/usr/bin/auto-cpufreq-remove", shell=True)
|
||||
- # output warning if gnome power profile is stopped
|
||||
- gnome_power_rm_reminder()
|
||||
- gnome_power_svc_enable()
|
||||
-
|
||||
- # run auto-cpufreq daemon remove script
|
||||
- call("/usr/local/bin/auto-cpufreq-remove", shell=True)
|
||||
-
|
||||
- # remove auto-cpufreq-remove
|
||||
- os.remove("/usr/bin/auto-cpufreq-remove")
|
||||
- os.remove("/usr/local/bin/auto-cpufreq-remove")
|
||||
-
|
||||
- # delete override pickle if it exists
|
||||
- if os.path.exists(governor_override_state):
|
||||
- os.remove(governor_override_state)
|
||||
-
|
||||
- # delete stats file
|
||||
- if auto_cpufreq_stats_path.exists():
|
||||
@ -117,52 +108,56 @@ index 83d0d64..04b5035 100644
|
||||
-
|
||||
- # restore original cpufrectl script
|
||||
- cpufreqctl_restore()
|
||||
-
|
||||
+ pass
|
||||
|
||||
def gov_check():
|
||||
for gov in get_avail_gov():
|
||||
diff --git a/scripts/cpufreqctl.sh b/scripts/cpufreqctl.sh
|
||||
index 63a2b5b..e157efe 100755
|
||||
--- a/scripts/cpufreqctl.sh
|
||||
+++ b/scripts/cpufreqctl.sh
|
||||
@@ -467,35 +467,21 @@ fi
|
||||
|
||||
if [ $OPTION = "--install" ]
|
||||
then
|
||||
- echo 'installing helpers...'
|
||||
- cp $0 /usr/bin/
|
||||
- echo 'installing policy...'
|
||||
- cp $(dirname "$(readlink -f "$0")")/konkor.cpufreq.policy /usr/share/polkit-1/actions/
|
||||
- echo 'installing fonts...'
|
||||
- mkdir -p /usr/share/fonts/truetype/cpufreq
|
||||
- cp $(dirname "$(readlink -f "$0")")/fonts/cpufreq.ttf /usr/share/fonts/truetype/cpufreq/
|
||||
- echo "done"
|
||||
+ echo "install is disabled in the nix package"
|
||||
exit
|
||||
fi
|
||||
if [ $OPTION = "--update-fonts" ]
|
||||
then
|
||||
- fc-cache -f
|
||||
+ echo "update-fonts is disabled in the nix package"
|
||||
exit
|
||||
fi
|
||||
if [ $OPTION = "--uninstall" ]
|
||||
then
|
||||
- echo 'uninstalling cpufreqctl helper...'
|
||||
- rm /usr/bin/cpufreqctl
|
||||
- echo 'uninstalling policy...'
|
||||
- rm /usr/share/polkit-1/actions/konkor.cpufreq.policy
|
||||
- echo 'uninstalling fonts...'
|
||||
- rm -rf /usr/share/fonts/truetype/cpufreq
|
||||
- echo "done"
|
||||
+ echo "uninstall is disabled in the nix package"
|
||||
exit
|
||||
fi
|
||||
if [ $OPTION = "--reset" ]
|
||||
then
|
||||
- echo 'reset to default values...'
|
||||
- dconf reset -f "/org/gnome/shell/extensions/cpufreq/"
|
||||
+ echo "reset is disabled in the nix package"
|
||||
exit
|
||||
fi
|
||||
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":
|
60
pkgs/tools/system/auto-cpufreq/prevent-update.patch
Normal file
60
pkgs/tools/system/auto-cpufreq/prevent-update.patch
Normal file
@ -0,0 +1,60 @@
|
||||
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__":
|
Loading…
Reference in New Issue
Block a user