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.
This commit is contained in:
John Soo 2022-06-03 11:13:28 -07:00
parent 759cf488a8
commit d0cdd897c3
No known key found for this signature in database
GPG Key ID: D8A148F8CE4DDBC2
3 changed files with 50 additions and 15 deletions

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