diff options
author | Sandro <sandro.jaeckel@gmail.com> | 2021-01-25 00:49:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-25 00:49:30 +0100 |
commit | 67f544e68a8c357d9e551929bd0f28f6584ec613 (patch) | |
tree | a5de34098adffb941a96903375bf5261a91d8c47 /pkgs/tools | |
parent | b08546147319998ae98771d94de62521831325dc (diff) | |
parent | 32fa8449ef849e11a947b346740971cb7133f32e (diff) | |
download | nixlib-67f544e68a8c357d9e551929bd0f28f6584ec613.tar nixlib-67f544e68a8c357d9e551929bd0f28f6584ec613.tar.gz nixlib-67f544e68a8c357d9e551929bd0f28f6584ec613.tar.bz2 nixlib-67f544e68a8c357d9e551929bd0f28f6584ec613.tar.lz nixlib-67f544e68a8c357d9e551929bd0f28f6584ec613.tar.xz nixlib-67f544e68a8c357d9e551929bd0f28f6584ec613.tar.zst nixlib-67f544e68a8c357d9e551929bd0f28f6584ec613.zip |
Merge pull request #110697 from Technical27/update-auto-cpufreq
auto-cpufreq: 1.5.1 -> 1.5.3
Diffstat (limited to 'pkgs/tools')
-rw-r--r-- | pkgs/tools/system/auto-cpufreq/default.nix (renamed from pkgs/tools/system/autocpu-freq/default.nix) | 13 | ||||
-rw-r--r-- | pkgs/tools/system/auto-cpufreq/prevent-install-and-copy.patch (renamed from pkgs/tools/system/autocpu-freq/prevent-install-and-copy.patch) | 160 |
2 files changed, 81 insertions, 92 deletions
diff --git a/pkgs/tools/system/autocpu-freq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix index 7e23b8b5b0f7..5a94cff19e16 100644 --- a/pkgs/tools/system/autocpu-freq/default.nix +++ b/pkgs/tools/system/auto-cpufreq/default.nix @@ -2,26 +2,31 @@ python3Packages.buildPythonPackage rec { pname = "auto-cpufreq"; - version = "1.5.1"; + version = "1.5.3"; src = fetchFromGitHub { owner = "AdnanHodzic"; repo = pname; rev = "v${version}"; - sha256 = "uVhftO6AqFnZ0uaEYRAPvVskkouNOXPtNVYXx7WJKyw="; + sha256 = "sha256-NDIdQ4gUN2jG+VWXsv3fdUogZxOOiNtnbekD30+jx6M="; }; propagatedBuildInputs = with python3Packages; [ click distro psutil ]; doCheck = false; - pythonImportsCheck = [ "source" ]; + pythonImportsCheck = [ "auto_cpufreq" ]; # patch to prevent script copying and to disable install patches = [ ./prevent-install-and-copy.patch ]; postInstall = '' # copy script manually - cp ${src}/scripts/cpufreqctl.sh $out/bin/cpufreqctl + 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 + substituteInPlace $out/lib/systemd/system/auto-cpufreq.service --replace "/usr/local" $out ''; meta = with lib; { diff --git a/pkgs/tools/system/autocpu-freq/prevent-install-and-copy.patch b/pkgs/tools/system/auto-cpufreq/prevent-install-and-copy.patch index 28c524e1497c..232ac780341a 100644 --- a/pkgs/tools/system/autocpu-freq/prevent-install-and-copy.patch +++ b/pkgs/tools/system/auto-cpufreq/prevent-install-and-copy.patch @@ -1,100 +1,44 @@ -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 +diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py +index 482a544..d142013 100644 +--- a/auto_cpufreq/core.py ++++ b/auto_cpufreq/core.py +@@ -163,31 +163,13 @@ def get_current_gov(): + return print("Currently using:", getoutput("cpufreqctl.auto-cpufreq --governor").strip().split(" ")[0], "governor") - 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 -diff --git a/source/core.py b/source/core.py -index 531c0c4..2e27e65 100644 ---- a/source/core.py -+++ b/source/core.py -@@ -24,8 +24,6 @@ warnings.filterwarnings("ignore") - # - re-enable CPU fan speed display and make more generic and not only for thinkpad - # - replace get system/CPU load from: psutil.getloadavg() | available in 5.6.2) - --SCRIPTS_DIR = Path("/usr/local/share/auto-cpufreq/scripts/") -- - # from the highest performance to the lowest - ALL_GOVERNORS = ("performance", "ondemand", "conservative", "schedutil", "userspace", "powersave") - CPUS = os.cpu_count() -@@ -156,34 +154,16 @@ def cpufreqctl(): - """ - deploy cpufreqctl script - """ + def cpufreqctl(): +- """ +- deploy cpufreqctl script +- """ - - # detect if running on a SNAP - if os.getenv('PKG_MARKER') == "SNAP": - pass - else: -- # deploy cpufreqctl script (if missing) +- # deploy cpufreqctl.auto-cpufreq script - if os.path.isfile("/usr/bin/cpufreqctl"): -- shutil.copy("/usr/bin/cpufreqctl", "/usr/bin/cpufreqctl.auto-cpufreq.bak") -- shutil.copy(SCRIPTS_DIR / "cpufreqctl.sh", "/usr/bin/cpufreqctl") +- shutil.copy(SCRIPTS_DIR / "cpufreqctl.sh", "/usr/bin/cpufreqctl.auto-cpufreq") - else: -- shutil.copy(SCRIPTS_DIR / "cpufreqctl.sh", "/usr/bin/cpufreqctl") +- shutil.copy(SCRIPTS_DIR / "cpufreqctl.sh", "/usr/bin/cpufreqctl.auto-cpufreq") + # scripts are already in the correct place + pass def cpufreqctl_restore(): - """ - restore original cpufreqctl script - """ +- """ +- remove cpufreqctl.auto-cpufreq script +- """ - # detect if running on a SNAP - if os.getenv('PKG_MARKER') == "SNAP": - pass - else: -- # restore original cpufreqctl script -- if os.path.isfile("/usr/bin/cpufreqctl.auto-cpufreq.bak"): -- os.system("cp /usr/bin/cpufreqctl.auto-cpufreq.bak /usr/bin/cpufreqctl") -- os.remove("/usr/bin/cpufreqctl.auto-cpufreq.bak") -- # ToDo: implement mechanism to make sure cpufreqctl (auto-cpufreq) file is -- # restored if overwritten by system. But during tool removal to also remove it -- # in def cpufreqctl +- if os.path.isfile("/usr/bin/cpufreqctl.auto-cpufreq"): +- os.remove("/usr/bin/cpufreqctl.auto-cpufreq") + # no need to restore + pass - def footer(l=79): -@@ -209,71 +189,13 @@ def remove_complete_msg(): + print("\n" + "-" * l + "\n") +@@ -212,74 +194,12 @@ def remove_complete_msg(): def deploy_daemon(): @@ -116,7 +60,7 @@ index 531c0c4..2e27e65 100644 - except: - print("\nERROR:\nWas unable to turn off bluetooth on boot") - -- auto_cpufreq_log_file.touch(exist_ok=True) +- auto_cpufreq_log_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") @@ -125,10 +69,10 @@ index 531c0c4..2e27e65 100644 - shutil.copy(SCRIPTS_DIR / "auto-cpufreq-remove.sh", "/usr/bin/auto-cpufreq-remove") - - call("/usr/bin/auto-cpufreq-install", shell=True) +- + # prevent needless copying and system changes + pass - # remove auto-cpufreq daemon def remove(): - @@ -136,7 +80,7 @@ index 531c0c4..2e27e65 100644 - if not os.path.exists("/usr/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") @@ -159,8 +103,11 @@ index 531c0c4..2e27e65 100644 - os.remove("/usr/bin/auto-cpufreq-remove") - - # delete log file -- if auto_cpufreq_log_file.exists(): -- auto_cpufreq_log_file.unlink() +- if auto_cpufreq_log_path.exists(): +- if auto_cpufreq_log_file is not None: +- auto_cpufreq_log_file.close() +- +- auto_cpufreq_log_path.unlink() - - # restore original cpufrectl script - cpufreqctl_restore() @@ -169,10 +116,47 @@ index 531c0c4..2e27e65 100644 def gov_check(): for gov in get_avail_gov(): -@@ -798,4 +720,4 @@ def running_daemon(): - exit(1) - elif os.getenv("PKG_MARKER") == "SNAP" and dcheck == "enabled": - deploy_complete_msg() -- exit(1) -\ No newline at end of file -+ exit(1) +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 |