From d0cdd897c347d73f98031f5143b0cd872e57874f Mon Sep 17 00:00:00 2001 From: John Soo Date: Fri, 3 Jun 2022 11:13:28 -0700 Subject: [PATCH] cpulimit: use github sources at 0.2 The sourceforge page of limitCPU says the following: > Update: Mr Marletta has re-launched his CPUlimit project, adding new > features and improving OS X support. The new project is a re-write > and should not be considered drop-in compatible with this > project. The source code of the new CPUlimit project can be found on > github. We here at the LimitCPU project will continue to work with > downstream projects and with the resurrected CPUlimit project so > that both projects may grow and improve. --- pkgs/tools/misc/cpulimit/default.nix | 32 ++++++++++--------- .../misc/cpulimit/get-missing-basename.patch | 12 +++++++ .../misc/cpulimit/remove-sys-sysctl.h.patch | 21 ++++++++++++ 3 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 pkgs/tools/misc/cpulimit/get-missing-basename.patch create mode 100644 pkgs/tools/misc/cpulimit/remove-sys-sysctl.h.patch diff --git a/pkgs/tools/misc/cpulimit/default.nix b/pkgs/tools/misc/cpulimit/default.nix index 7fdaa319619d..a0ee76ec46fa 100644 --- a/pkgs/tools/misc/cpulimit/default.nix +++ b/pkgs/tools/misc/cpulimit/default.nix @@ -1,27 +1,29 @@ -{lib, stdenv, fetchurl}: +{ lib, stdenv, fetchFromGitHub }: stdenv.mkDerivation rec { pname = "cpulimit"; - version = "2.7"; + version = "0.2"; - src = fetchurl { - url = "mirror://sourceforge/limitcpu/${pname}-${version}.tar.gz"; - sha256 = "sha256-HeBApPikDf6MegJf6YB1ZzRo+8P8zMvCMbx0AvYuxKA="; + src = fetchFromGitHub { + owner = "opsengine"; + repo = "cpulimit"; + rev = "v${version}"; + sha256 = "1dz045yhcsw1rdamzpz4bk8mw888in7fyqk1q1b3m1yk4pd1ahkh"; }; - buildFlags = with stdenv; [ ( - if isDarwin then "osx" - else if isFreeBSD then "freebsd" - else "cpulimit" - ) ]; + patches = [ ./remove-sys-sysctl.h.patch ./get-missing-basename.patch ]; - installFlags = [ "PREFIX=$(out)" ]; + + installPhase = '' + mkdir -p $out/bin + cp src/cpulimit $out/bin + ''; meta = with lib; { - homepage = "http://limitcpu.sourceforge.net/"; - description = "A tool to throttle the CPU usage of programs"; - platforms = with platforms; linux ++ freebsd; + homepage = "https://github.com/opsengine/cpulimit"; + description = "CPU usage limiter"; + platforms = platforms.unix; license = licenses.gpl2; - maintainers = [maintainers.rycee]; + maintainers = [ maintainers.jsoo1 ]; }; } diff --git a/pkgs/tools/misc/cpulimit/get-missing-basename.patch b/pkgs/tools/misc/cpulimit/get-missing-basename.patch new file mode 100644 index 000000000000..d27eda0b6fa9 --- /dev/null +++ b/pkgs/tools/misc/cpulimit/get-missing-basename.patch @@ -0,0 +1,12 @@ +diff --git a/src/process_group.c b/src/process_group.c +index 06d73a6..3ca66b0 100644 +--- a/src/process_group.c ++++ b/src/process_group.c +@@ -20,6 +20,7 @@ + */ + + #include ++#include + #include + #include + #include diff --git a/pkgs/tools/misc/cpulimit/remove-sys-sysctl.h.patch b/pkgs/tools/misc/cpulimit/remove-sys-sysctl.h.patch new file mode 100644 index 000000000000..a152cab3acc7 --- /dev/null +++ b/pkgs/tools/misc/cpulimit/remove-sys-sysctl.h.patch @@ -0,0 +1,21 @@ +Remove references to sys/sysctl.h which were deprecated long ago. + +diff --git a/src/cpulimit.c b/src/cpulimit.c +index 50eabea..eba4615 100644 +--- a/src/cpulimit.c ++++ b/src/cpulimit.c +@@ -38,7 +38,9 @@ + #include + #include + #include ++#ifdef __APPLE__ + #include ++#endif + #include + #include + #include + +-#ifdef __APPLE__ || __FREEBSD__ ++#if defined(__APPLE__) || defined(__FREEBSD__) + #include + #endif \ No newline at end of file