[meta-oe] cpulimit: introduce support for this package

Message ID 20220501034533.8342-1-stephensportia@gmail.com
State New
Headers show
Series [meta-oe] cpulimit: introduce support for this package | expand

Commit Message

Portia May 1, 2022, 3:45 a.m. UTC
Now, cpulimit recipe is put under recipes-support. Binary will be
installed  by the recipe under /usr/sbin

         # cpulimit -h
         Usage: cpulimit [OPTIONS...] TARGET
                 OPTIONS
                 -l, --limit=N          percentage of cpu allowed from 0
to 100
(required)
                 -v, --verbose          show control statistics
                 -z, --lazy             exit if there is no target
process, or
if it dies
                 -i, --include-children limit also the children
processes
                 -h, --help             display this help and exit
                 TARGET must be exactly one of these:
                 -p, --pid=N            pid of the process (implies -z)
                 -e, --exe=FILE         name of the executable program
file or
path name
                 COMMAND [ARGS]         run this command and limit it
(implies
-z)

                 Report bugs to <marlon...@hotmail.com>.

Signed-off-by: Bassem Boubaker <bassem.boubaker@actia.fr>
[ Changes by Portia
 - Fix build issue, deprecated and missing includes
 - Add branch to git repo in SRC_URI
 - Update LICENSE to GPL-2.0-or-later
]
Signed-off-by: Portia <stephensportia@gmail.com>
---
 ...l.h-and-add-missing-libgen.h-include.patch | 41 +++++++++++++++++++
 .../recipes-support/cpulimit/cpulimit_0.2.bb  | 22 ++++++++++
 2 files changed, 63 insertions(+)
 create mode 100644 meta-oe/recipes-support/cpulimit/cpulimit/0001-Remove-sys-sysctl.h-and-add-missing-libgen.h-include.patch
 create mode 100644 meta-oe/recipes-support/cpulimit/cpulimit_0.2.bb

Patch

diff --git a/meta-oe/recipes-support/cpulimit/cpulimit/0001-Remove-sys-sysctl.h-and-add-missing-libgen.h-include.patch b/meta-oe/recipes-support/cpulimit/cpulimit/0001-Remove-sys-sysctl.h-and-add-missing-libgen.h-include.patch
new file mode 100644
index 000000000..50d0342ec
--- /dev/null
+++ b/meta-oe/recipes-support/cpulimit/cpulimit/0001-Remove-sys-sysctl.h-and-add-missing-libgen.h-include.patch
@@ -0,0 +1,41 @@ 
+From 41cfba0840f58555593fd4bee07db77221043e0b 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()
+
+Upstream-Status: Inactive-Upstream [2015]
+Signed-off-by: Portia <stephensportia@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 50eabea..5b0ec49 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 06d73a6..d4f6fab 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
diff --git a/meta-oe/recipes-support/cpulimit/cpulimit_0.2.bb b/meta-oe/recipes-support/cpulimit/cpulimit_0.2.bb
new file mode 100644
index 000000000..3ee2b5c23
--- /dev/null
+++ b/meta-oe/recipes-support/cpulimit/cpulimit_0.2.bb
@@ -0,0 +1,22 @@ 
+SUMMARY = "cpulimit is a tool which limits the CPU usage of a process"
+HOMEPAGE = "http://cpulimit.sourceforge.net"
+LICENSE = "GPL-2.0-or-later"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=86c1c0d961a437e529db93aa3bb32dc4"
+SRCREV ?= "f4d2682804931e7aea02a869137344bb5452a3cd"
+
+SRC_URI = "git://g...@github.com/opsengine/cpulimit.git;protocol=https;branch=master \
+           file://0001-Remove-sys-sysctl.h-and-add-missing-libgen.h-include.patch \
+           "
+
+S = "${WORKDIR}/git"
+
+do_compile() {
+    oe_runmake all
+}
+do_install() {
+    install -d ${D}${sbindir}
+    install -m 0755 ${B}/src/${PN} ${D}${sbindir}/
+}
+
+CFLAGS += "${LDFLAGS}"
+