git: 8921a9619400 - main - sysutils/wmcpuload: revive and update to 1.1.1

From: Rene Ladan <rene_at_FreeBSD.org>
Date: Thu, 14 Oct 2021 12:00:17 UTC
The branch main has been updated by rene:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8921a96194000bc7891ed5d04053b5d5ebaf956c

commit 8921a96194000bc7891ed5d04053b5d5ebaf956c
Author:     Boris Korzun <drtr0jan@yandex.ru>
AuthorDate: 2021-10-14 11:54:57 +0000
Commit:     Rene Ladan <rene@FreeBSD.org>
CommitDate: 2021-10-14 11:58:48 +0000

    sysutils/wmcpuload: revive and update to 1.1.1
    
    Pass maintainership to submitter.
    
    PR:             254397
---
 MOVED                                             |  1 -
 sysutils/Makefile                                 |  1 +
 sysutils/wmcpuload/Makefile                       | 32 +++++++++++++
 sysutils/wmcpuload/distinfo                       |  3 ++
 sysutils/wmcpuload/files/patch-src_cpu__freebsd.c | 57 +++++++++++++++++++++++
 sysutils/wmcpuload/pkg-descr                      |  4 ++
 6 files changed, 97 insertions(+), 1 deletion(-)

diff --git a/MOVED b/MOVED
index 3f08725ee375..cdc33649495c 100644
--- a/MOVED
+++ b/MOVED
@@ -14799,7 +14799,6 @@ sysutils/tmate-slave||2020-05-05|Has expired: Broken for more than 6 months
 sysutils/tss||2020-05-05|Has expired: Broken for more than 6 months
 sysutils/vstrip||2020-05-05|Has expired: Broken for more than 6 months
 sysutils/watchdog||2020-05-05|Has expired: Broken for more than 6 months
-sysutils/wmcpuload||2020-05-05|Has expired: Broken for more than 6 months
 sysutils/wtail||2020-05-05|Has expired: Broken for more than 6 months
 textproc/csv2latex||2020-05-05|Has expired: Broken for more than 6 months
 textproc/da-hyphen||2020-05-05|Has expired: Broken for more than 6 months
diff --git a/sysutils/Makefile b/sysutils/Makefile
index dd95b1febebe..e835799e41a5 100644
--- a/sysutils/Makefile
+++ b/sysutils/Makefile
@@ -1518,6 +1518,7 @@
     SUBDIR += wmbluecpu
     SUBDIR += wmbsdbatt
     SUBDIR += wmcube
+    SUBDIR += wmcpuload
     SUBDIR += wmdiskmon
     SUBDIR += wmflame
     SUBDIR += wmmemfree
diff --git a/sysutils/wmcpuload/Makefile b/sysutils/wmcpuload/Makefile
new file mode 100644
index 000000000000..d788e4baecc6
--- /dev/null
+++ b/sysutils/wmcpuload/Makefile
@@ -0,0 +1,32 @@
+# Created by: Soeren Boll Overgaard <boll@tolkien.dk>
+
+PORTNAME=	wmcpuload
+DISTVERSION=	1.1.1
+
+CATEGORIES=	sysutils windowmaker
+MASTER_SITES=	https://www.dockapps.net/download/
+
+MAINTAINER=	drtr0jan@yandex.ru
+COMMENT=	"lcd" dockapp for windowmaker, which displays the current cpuload
+LICENSE=	GPLv2
+
+USES=		xorg
+USE_XORG+=	x11 xext xpm
+GNU_CONFIGURE=	yes
+
+PORTDOCS=	ChangeLog README
+PLIST_FILES=	"@(,kmem,2555) bin/wmcpuload" \
+		man/man1/wmcpuload.1.gz
+
+OPTIONS_DEFINE=	DOCS
+
+post-patch:
+	@${REINPLACE_CMD} '/SETGID_FLAGS=/d' ${WRKSRC}/configure
+
+post-install:
+	@${MKDIR} ${STAGEDIR}${DOCSDIR}
+.for file in ${PORTDOCS}
+	${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${DOCSDIR}
+.endfor
+
+.include <bsd.port.mk>
diff --git a/sysutils/wmcpuload/distinfo b/sysutils/wmcpuload/distinfo
new file mode 100644
index 000000000000..45403e11b1f2
--- /dev/null
+++ b/sysutils/wmcpuload/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1634212712
+SHA256 (wmcpuload-1.1.1.tar.gz) = 8f08b2b937db105b677a9e4df2a67259d2580071e28456c0e6cd77db15f0648c
+SIZE (wmcpuload-1.1.1.tar.gz) = 167751
diff --git a/sysutils/wmcpuload/files/patch-src_cpu__freebsd.c b/sysutils/wmcpuload/files/patch-src_cpu__freebsd.c
new file mode 100644
index 000000000000..058a807aee01
--- /dev/null
+++ b/sysutils/wmcpuload/files/patch-src_cpu__freebsd.c
@@ -0,0 +1,57 @@
+--- src/cpu_freebsd.c.orig	2016-10-20 13:55:48 UTC
++++ src/cpu_freebsd.c
+@@ -16,7 +16,8 @@
+ #include <string.h>
+ #include "cpu.h"
+ 
+-#include <kvm.h>
++#include <sys/sysctl.h>
++#include <sys/types.h>
+ #include <fcntl.h>
+ 
+ #include <sys/param.h>
+@@ -27,27 +28,21 @@
+ #   include <sys/resource.h>
+ #endif /* __FreeBSD_version < 500101 */
+ 
+-static kvm_t *kd = NULL;
+-static struct nlist nlst[] = { {"_cp_time"}, {0} };
++static int sysctl_mib[2] = { -1, -1 };
++static size_t sysctl_len;
+ 
+ void
+ cpu_init(void)
+ {
+ 
+-    kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open");
++    sysctl_len = 2;
++    sysctlnametomib("kern.cp_time", sysctl_mib, &sysctl_len);
+ 
+-    if (kd == NULL) {
+-	fprintf(stderr, "can't open kernel virtual memory");
++    if (sysctl_mib[0] == -1) {
++	fprintf(stderr, "unknown sysctl kern.cp_time");
+ 	exit(1);
+     }
+ 
+-    kvm_nlist(kd, nlst);
+-
+-    if (nlst[0].n_type == 0) {
+-	fprintf(stderr, "error extracting symbols");
+-	exit(1);
+-    }
+-
+     /* drop setgid & setuid (the latter should not be there really) */
+     seteuid(getuid());
+     setegid(getgid());
+@@ -66,8 +61,8 @@ cpu_get_usage(cpu_options *opts)
+     int used, total, result;
+     unsigned long int cpu_time[CPUSTATES];
+ 
+-    if (kvm_read(kd, nlst[0].n_value, &cpu_time, sizeof(cpu_time)) !=
+-	sizeof(cpu_time))
++    sysctl_len = sizeof(cpu_time);
++    if (sysctl(sysctl_mib, 2, &cpu_time, &sysctl_len, NULL, 0) == -1)
+ 	return 0;
+ 
+     /* calculate usage */
diff --git a/sysutils/wmcpuload/pkg-descr b/sysutils/wmcpuload/pkg-descr
new file mode 100644
index 000000000000..f52440126a82
--- /dev/null
+++ b/sysutils/wmcpuload/pkg-descr
@@ -0,0 +1,4 @@
+This is a port of wmcpuload, which displays the current cpu-load in a
+simulated lcd-display, which supports background lighting.
+
+WWW: https://www.dockapps.net/wmcpuload