@@ -965,6 +965,9 @@ N: Filip Skoneczny <fskoneczny@gmail.com>
F: board/sinovoip/m1-plus
F: configs/bananapi_m1_plus_defconfig
+N: Florian Fainelli <f.fainelli@gmail.com>
+F: package/cpulimit/
+
N: Floris Bos <bos@je-eigen-domein.nl>
F: package/ipmitool/
F: package/odhcploc/
@@ -2522,6 +2522,7 @@ menu "System tools"
source "package/circus/Config.in"
source "package/containerd/Config.in"
source "package/coreutils/Config.in"
+ source "package/cpulimit/Config.in"
source "package/cpuload/Config.in"
source "package/daemon/Config.in"
source "package/dc3dd/Config.in"
new file mode 100644
@@ -0,0 +1,56 @@
+From d1f42082590bed42cbf6ef1bf37e936df1afbf6b Mon Sep 17 00:00:00 2001
+From: Tobias Tangemann <tobias@tangemann.org>
+Date: Thu, 9 Jul 2015 23:51:07 +0200
+Subject: [PATCH] Fix crash (and compiler warnings)
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+---
+ src/cpulimit.c | 2 +-
+ src/process_group.c | 4 ++++
+ tests/process_iterator_test.c | 2 +-
+ 3 files changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/src/cpulimit.c b/src/cpulimit.c
+index 50eabeacf214..42d7ca280738 100644
+--- a/src/cpulimit.c
++++ b/src/cpulimit.c
+@@ -43,7 +43,7 @@
+ #include <sys/types.h>
+ #include <sys/wait.h>
+
+-#ifdef __APPLE__ || __FREEBSD__
++#if defined(__APPLE__) || defined(__FREEBSD__)
+ #include <libgen.h>
+ #endif
+
+diff --git a/src/process_group.c b/src/process_group.c
+index 06d73a6f3541..c9e148cd1b60 100644
+--- a/src/process_group.c
++++ b/src/process_group.c
+@@ -25,6 +25,10 @@
+ #include <sys/time.h>
+ #include <signal.h>
+
++#if defined(__APPLE__) || defined(__FREEBSD__)
++#include <libgen.h>
++#endif
++
+ #include <assert.h>
+
+ #include "process_iterator.h"
+diff --git a/tests/process_iterator_test.c b/tests/process_iterator_test.c
+index 16151967eb24..1bfc167ba895 100644
+--- a/tests/process_iterator_test.c
++++ b/tests/process_iterator_test.c
+@@ -28,7 +28,7 @@
+ #include <signal.h>
+ #include <string.h>
+
+-#ifdef __APPLE__ || __FREEBSD__
++#if defined(__APPLE__) || defined(__FREEBSD__)
+ #include <libgen.h>
+ #endif
+
+--
+2.25.1
+
new file mode 100644
@@ -0,0 +1,41 @@
+From 4c1e021037550c437c7da3a276b95b5bf79e967e Mon Sep 17 00:00:00 2001
+From: Portia <stephensportia@gmail.com>
+Date: Sun, 1 May 2022 12:43:35 +1000
+Subject: [PATCH] Remove sys/sysctl.h and add missing libgen.h include
+
+- sys/sysctl.h has been deprecated and should be removed
+- Adds missing libgen.h include when calling basename()
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+---
+ src/cpulimit.c | 1 -
+ src/process_group.c | 1 +
+ 2 files changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/cpulimit.c b/src/cpulimit.c
+index 50eabeacf214..5b0ec4978f02 100644
+--- a/src/cpulimit.c
++++ b/src/cpulimit.c
+@@ -38,7 +38,6 @@
+ #include <string.h>
+ #include <sys/stat.h>
+ #include <sys/time.h>
+-#include <sys/sysctl.h>
+ #include <sys/resource.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
+diff --git a/src/process_group.c b/src/process_group.c
+index 06d73a6f3541..d4f6fab3385c 100644
+--- a/src/process_group.c
++++ b/src/process_group.c
+@@ -24,6 +24,7 @@
+ #include <limits.h>
+ #include <sys/time.h>
+ #include <signal.h>
++#include <libgen.h>
+
+ #include <assert.h>
+
+--
+2.25.1
+
new file mode 100644
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_CPULIMIT
+ bool "cpulimit"
+ help
+ Cpulimit is a tool which limits the CPU usage of a process
+ (expressed in percentage, not in CPU time)
+
+ https://github.com/opsengine/cpulimit
new file mode 100644
@@ -0,0 +1,3 @@
+# sha256sum locally computed:
+sha256 64312f9ac569ddcadb615593cd002c94b76e93a0d4625d3ce1abb49e08e2c2da cpulimit-0.2.tar.gz
+sha256 920489ca9da706d842870701155e70a101315ba0783cff39765d7e15e0916a4a LICENSE
new file mode 100644
@@ -0,0 +1,23 @@
+################################################################################
+#
+# cpulimit
+#
+################################################################################
+
+CPULIMIT_VERSION = 0.2
+CPULIMIT_SITE = $(call github,opsengine,cpulimit,v$(CPULIMIT_VERSION))
+CPULIMIT_LICENSE = GPL-2.0+
+CPULIMIT_LICENSE_FILES = LICENSE
+
+define CPULIMIT_BUILD_CMDS
+ $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) \
+ CFLAGS="$(TARGET_CFLAGS) -D_GNU_SOURCE" \
+ LDLIBS="$(TARGET_LDFLAGS)"
+endef
+
+define CPULIMIT_INSTALL_TARGET_CMDS
+ $(INSTALL) -D -m 0755 $(@D)/src/cpulimit \
+ $(TARGET_DIR)/usr/bin/cpulimit
+endef
+
+$(eval $(generic-package))
Cpulimit is a tool which limits the CPU usage of a process (expressed in percentage, not in CPU time). It is useful to control batch jobs, when you don't want them to eat too many CPU cycles. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> --- Changes in v3: - dropped CPULIMIT_SOURCE - dropped 'v' from CPULIMIT_VERSION - updated hash file with new tarball name Changes in v2: - added DEVELOPERS entry - back ported 2 patches from upstream project pull requests to address build warnings - added _GNU_SOURCE to the CFLAGS - added hash file - corrected check-package warnings DEVELOPERS | 3 + package/Config.in | 1 + ...0001-Fix-crash-and-compiler-warnings.patch | 56 +++++++++++++++++++ ...l.h-and-add-missing-libgen.h-include.patch | 41 ++++++++++++++ package/cpulimit/Config.in | 7 +++ package/cpulimit/cpulimit.hash | 3 + package/cpulimit/cpulimit.mk | 23 ++++++++ 7 files changed, 134 insertions(+) create mode 100644 package/cpulimit/0001-Fix-crash-and-compiler-warnings.patch create mode 100644 package/cpulimit/0002-Remove-sys-sysctl.h-and-add-missing-libgen.h-include.patch create mode 100644 package/cpulimit/Config.in create mode 100644 package/cpulimit/cpulimit.hash create mode 100644 package/cpulimit/cpulimit.mk