#!/bin/sh
# This is a shell archive
echo x wmcpuload
mkdir -p wmcpuload > /dev/null 2>&1
echo x wmcpuload/files
mkdir -p wmcpuload/files > /dev/null 2>&1
echo x wmcpuload/pkg-descr
sed 's/^X//' > wmcpuload/pkg-descr << 'SHAR_END'
XThis is a port of wmcpuload, which displays the current cpu-load in a
Xsimulated lcd-display, which supports background lighting.
X
XWWW: http://seiichisato.jp/dockapps/#wmcpuload
SHAR_END
echo x wmcpuload/Makefile
sed 's/^X//' > wmcpuload/Makefile << 'SHAR_END'
X# Created by: Soeren Boll Overgaard <boll@tolkien.dk>
X# $FreeBSD$
X
XPORTNAME=	wmcpuload
XPORTVERSION=	1.1.1
X
XCATEGORIES=	sysutils windowmaker
XMASTER_SITES=	https://www.dockapps.net/download/
X
XMAINTAINER=	xride@FreeBSD.org
XCOMMENT=	"lcd" dockapp for windowmaker, which displays the current cpuload
XLICENSE=	GPLv2
X
XUSES=		xorg
XUSE_XORG+=	x11 xext xpm
XGNU_CONFIGURE=	yes
X
XPLIST_FILES=	"@(,kmem,2555) bin/wmcpuload" \
X		man/man1/wmcpuload.1.gz
XPORTDOCS=	ChangeLog README
X
XOPTIONS_DEFINE=	DOCS
X
Xpost-patch:
X	@${REINPLACE_CMD} '/SETGID_FLAGS=/d' ${WRKSRC}/configure
X
Xpost-install:
X	@${MKDIR} ${STAGEDIR}${DOCSDIR}
X.for file in ${PORTDOCS}
X	${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${DOCSDIR}
X.endfor
X
X.include <bsd.port.mk>
SHAR_END
echo x wmcpuload/distinfo
sed 's/^X//' > wmcpuload/distinfo << 'SHAR_END'
XSHA256 (wmcpuload-1.1.1.tar.gz) = 8f08b2b937db105b677a9e4df2a67259d2580071e28456c0e6cd77db15f0648c
XSIZE (wmcpuload-1.1.1.tar.gz) = 167751
SHAR_END
echo x wmcpuload/files/patch-src_cpu__freebsd.c
sed 's/^X//' > wmcpuload/files/patch-src_cpu__freebsd.c << 'SHAR_END'
X--- src/cpu_freebsd.c.orig	2016-10-20 13:55:48 UTC
X+++ src/cpu_freebsd.c
X@@ -16,7 +16,8 @@
X #include <string.h>
X #include "cpu.h"
X 
X-#include <kvm.h>
X+#include <sys/sysctl.h>
X+#include <sys/types.h>
X #include <fcntl.h>
X 
X #include <sys/param.h>
X@@ -27,27 +28,21 @@
X #   include <sys/resource.h>
X #endif /* __FreeBSD_version < 500101 */
X 
X-static kvm_t *kd = NULL;
X-static struct nlist nlst[] = { {"_cp_time"}, {0} };
X+static int sysctl_mib[2] = { -1, -1 };
X+static size_t sysctl_len;
X 
X void
X cpu_init(void)
X {
X 
X-    kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open");
X+    sysctl_len = 2;
X+    sysctlnametomib("kern.cp_time", sysctl_mib, &sysctl_len);
X 
X-    if (kd == NULL) {
X-	fprintf(stderr, "can't open kernel virtual memory");
X+    if (sysctl_mib[0] == -1) {
X+	fprintf(stderr, "unknown sysctl kern.cp_time");
X 	exit(1);
X     }
X 
X-    kvm_nlist(kd, nlst);
X-
X-    if (nlst[0].n_type == 0) {
X-	fprintf(stderr, "error extracting symbols");
X-	exit(1);
X-    }
X-
X     /* drop setgid & setuid (the latter should not be there really) */
X     seteuid(getuid());
X     setegid(getgid());
X@@ -66,8 +61,8 @@ cpu_get_usage(cpu_options *opts)
X     int used, total, result;
X     unsigned long int cpu_time[CPUSTATES];
X 
X-    if (kvm_read(kd, nlst[0].n_value, &cpu_time, sizeof(cpu_time)) !=
X-	sizeof(cpu_time))
X+    sysctl_len = sizeof(cpu_time);
X+    if (sysctl(sysctl_mib, 2, &cpu_time, &sysctl_len, NULL, 0) == -1)
X 	return 0;
X 
X     /* calculate usage */
SHAR_END
exit
