Merge pull request #176139 from jsoo1/jsoo1/limitcpu

This commit is contained in:
Sandro 2022-07-07 15:53:23 +02:00 committed by GitHub
commit ed474bf685
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 85 additions and 15 deletions

View file

@ -6329,6 +6329,12 @@
github = "jsimonetti";
githubId = 5478838;
};
jsoo1 = {
email = "jsoo1@asu.edu";
github = "jsoo1";
name = "John Soo";
githubId = 10039785;
};
jtcoolen = {
email = "jtcoolen@pm.me";
name = "Julien Coolen";

View file

@ -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 ];
};
}

View file

@ -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 <string.h>
+#include <libgen.h>
#include <stdlib.h>
#include <limits.h>
#include <sys/time.h>

View file

@ -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 <string.h>
#include <sys/stat.h>
#include <sys/time.h>
+#ifdef __APPLE__
#include <sys/sysctl.h>
+#endif
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/wait.h>
-#ifdef __APPLE__ || __FREEBSD__
+#if defined(__APPLE__) || defined(__FREEBSD__)
#include <libgen.h>
#endif

View file

@ -0,0 +1,27 @@
{lib, stdenv, fetchurl}:
stdenv.mkDerivation rec {
pname = "limitcpu";
version = "2.7";
src = fetchurl {
url = "mirror://sourceforge/limitcpu/cpulimit-${version}.tar.gz";
sha256 = "sha256-HeBApPikDf6MegJf6YB1ZzRo+8P8zMvCMbx0AvYuxKA=";
};
buildFlags = with stdenv; [ (
if isDarwin then "osx"
else if isFreeBSD then "freebsd"
else "cpulimit"
) ];
installFlags = [ "PREFIX=$(out)" ];
meta = with lib; {
homepage = "http://limitcpu.sourceforge.net/";
description = "A tool to throttle the CPU usage of programs";
platforms = with platforms; linux ++ freebsd;
license = licenses.gpl2;
maintainers = [maintainers.rycee];
};
}

View file

@ -4054,6 +4054,8 @@ with pkgs;
lifeograph = callPackage ../applications/editors/lifeograph { };
limitcpu = callPackage ../tools/misc/limitcpu { };
link-grammar = callPackage ../tools/text/link-grammar { };
linuxptp = callPackage ../os-specific/linux/linuxptp { };