ports/97357: Update port: x11/fbpanel: Patch for using CPU plugin
Andreas Wiese
bzimage at gmx.net
Tue May 16 18:10:37 UTC 2006
>Number: 97357
>Category: ports
>Synopsis: Update port: x11/fbpanel: Patch for using CPU plugin
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Tue May 16 18:10:20 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: Andreas Wiese
>Release: 6.0-RELEASE
>Organization:
BSD Crew Dresden
>Environment:
FreeBSD schroeder.lan.instandbesetzt.net 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Thu Nov 3 09:36:13 UTC 2005 root at x64.samsco.home:/usr/obj/usr/src/sys/GENERIC i386
>Description:
I've ported the cpu-Plugin of fbpanel to FreeBSD:
diff -urN fbpanel.orig/Makefile fbpanel/Makefile
--- fbpanel.orig/Makefile Tue Apr 11 13:11:53 2006
+++ fbpanel/Makefile Tue May 16 19:48:29 2006
@@ -2,7 +2,7 @@
# Date created: Sat Jun 26 13:43:50 CEST 2004
# Whom: Tobias Roth <ports at fsck.ch>
#
-# $FreeBSD: ports/x11/fbpanel/Makefile,v 1.9 2006/04/11 11:11:53 ehaupt Exp $
+# $FreeBSD$
#
PORTNAME= fbpanel
@@ -16,13 +16,23 @@
MAINTAINER= ports at fsck.ch
COMMENT= A desktop panel that includes a taskbar, pager, launchbar and mo
re
+OPTIONS= PLUGIN_CPU "Build CPU plugin" on
+
USE_X_PREFIX= yes
USE_GNOME= gtk20
HAS_CONFIGURE= yes
-CONFIGURE_ARGS= --prefix=${PREFIX} --cpu=off
+CONFIGURE_ARGS= --prefix=${PREFIX}
CFLAGS+= -I${WRKSRC}
USE_GMAKE= yes
+.include <bsd.port.pre.mk>
+
+.if defined(WITH_PLUGIN_CPU)
+CONFIGURE_ARGS+= --cpu=on
+.else
+CONFIGURE_ARGS+= --cpu=off
+.endif
+
MAN1= fbpanel.1
MANCOMPRESSED= yes
@@ -34,4 +44,4 @@
@${CAT} ${PKGMESSAGE}
@${ECHO_MSG} ""
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff -urN fbpanel.orig/files/patch-Makefile fbpanel/files/patch-Makefile
--- fbpanel.orig/files/patch-Makefile Thu Jan 1 01:00:00 1970
+++ fbpanel/files/patch-Makefile Tue May 16 19:48:07 2006
@@ -0,0 +1,13 @@
+--- Makefile~ Tue May 16 19:28:38 2006
++++ Makefile Tue May 16 19:14:24 2006
+@@ -24,6 +24,10 @@
+ -include $(DEP)
+ endif
+
++ifeq ($(PLUGIN_CPU),on)
++override CFLAGS += -DPLUGIN_CPU
++endif
++
+ TARGET := fbpanel
+
+ EXTRAOBJ :=
diff -urN fbpanel.orig/files/patch-cpu.c fbpanel/files/patch-cpu.c
--- fbpanel.orig/files/patch-cpu.c Thu Jan 1 01:00:00 1970
+++ fbpanel/files/patch-cpu.c Tue May 16 19:48:07 2006
@@ -0,0 +1,92 @@
+--- plugins/cpu.c~ Tue May 16 19:23:18 2006
++++ plugins/cpu.c Tue May 16 19:00:07 2006
+@@ -18,14 +18,24 @@
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+-/*A little bug fixed by Mykola <mykola at 2ka.mipt.ru>:) */
++/*
++ * A little bug fixed by Mykola <mykola at 2ka.mipt.ru> :)
++ * FreeBSD support added by Andreas Wiese <aw at instandbesetzt.net>
++ */
+
+
+ #include <string.h>
+ #include <sys/time.h>
+ #include <time.h>
+-#include <sys/sysinfo.h>
++#ifdef __FreeBSD__
++# include <sys/types.h>
++# include <sys/resource.h>
++# include <sys/sysctl.h>
++#else
++# include <sys/sysinfo.h>
++#endif
+ #include <stdlib.h>
++#include <stdio.h>
+
+ #include "plugin.h"
+ #include "panel.h"
+@@ -60,6 +70,37 @@
+ struct cpu_stat cpu_anterior;
+ } cpu_t;
+
++#ifdef __FreeBSD__
++static void
++get_procstat(unsigned long *u, unsigned long *n, unsigned long *s,
++ unsigned long *i)
++{
++ static int mib[2] = { -1, -1 }, init = 0, j, realhz;
++ long ct[CPUSTATES];
++
++
++ if(init == 0) {
++ struct clockinfo ci;
++ j = sizeof(ci);
++ sysctlbyname("kern.clockrate", &ci, &j, NULL, 0);
++ realhz = ci.stathz ? ci.stathz : ci.hz;
++
++ j = 2;
++ sysctlnametomib("kern.cp_time", mib, &j);
++
++ init = 1;
++ j = sizeof(ct);
++ }
++
++ sysctl(mib, 2, ct, &j, NULL, 0);
++ *u = ct[CP_USER] / realhz;
++ *n = ct[CP_NICE] / realhz;
++ *s = ct[CP_SYS] / realhz;
++ *i = ct[CP_IDLE] / realhz;
++
++ return;
++}
++#endif
+
+ static int
+ cpu_update(cpu_t *c)
+@@ -67,18 +108,24 @@
+ int cpu_u=0, cpu_s=0, cpu_n=0, cpu_i=100;
+ unsigned int i;
+ struct cpu_stat cpu, cpu_r;
++#ifndef __FreeBSD__
+ FILE *stat;
++#endif
+ float total;
+
+ ENTER;
+ if(!c->pixmap)
+ RET(TRUE);
+
++#ifdef __FreeBSD__
++ get_procstat(&cpu.u, &cpu.n, &cpu.s, &cpu.i);
++#else
+ stat = fopen("/proc/stat", "r");
+ if(!stat)
+ RET(TRUE);
+ fscanf(stat, "cpu %lu %lu %lu %lu", &cpu.u, &cpu.n, &cpu.s, &cpu.i);
+ fclose(stat);
++#endif
+
+ cpu_r.u = cpu.u - c->cpu_anterior.u;
+ cpu_r.n = cpu.n - c->cpu_anterior.n;
diff -urN fbpanel.orig/files/patch-plugin.c fbpanel/files/patch-plugin.c
--- fbpanel.orig/files/patch-plugin.c Thu Jan 1 01:00:00 1970
+++ fbpanel/files/patch-plugin.c Tue May 16 19:48:07 2006
@@ -0,0 +1,15 @@
+--- plugin.c~ Tue May 16 19:22:41 2006
++++ plugin.c Tue May 16 19:16:29 2006
+@@ -98,7 +98,11 @@
+ #ifdef STATIC_DESKNO
+ REGISTER_PLUGIN_CLASS(deskno_plugin_class, 0);
+ #endif
+-
++
++#if defined(STATIC_CPU) && defined(PLUGIN_CPU)
++ REGISTER_PLUGIN_CLASS(cpu_plugin_class, 0);
++#endif
++
+ RET();
+ }
+
diff -urN fbpanel.orig/files/patch-plugin.h fbpanel/files/patch-plugin.h
--- fbpanel.orig/files/patch-plugin.h Thu Jan 1 01:00:00 1970
+++ fbpanel/files/patch-plugin.h Tue May 16 19:48:07 2006
@@ -0,0 +1,11 @@
+--- plugin.h~ Tue May 16 19:22:49 2006
++++ plugin.h Tue May 16 19:00:09 2006
+@@ -61,7 +61,7 @@
+ #define STATIC_SPACE
+ #define STATIC_ICONS
+ #define STATIC_DESKNO
++#define STATIC_CPU
+ #endif
+-
+
+ #endif
See also: http://www.inf.tu-dresden.de/~s0310141/fbpanel-cpu-patch
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list