From nobody@FreeBSD.org  Tue May 16 18:07:29 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 55D6616AF5F
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 16 May 2006 18:07:29 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 1371343D7B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 16 May 2006 18:07:29 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k4GI7ScD089161
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 16 May 2006 18:07:28 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k4GI7Sit089160;
	Tue, 16 May 2006 18:07:28 GMT
	(envelope-from nobody)
Message-Id: <200605161807.k4GI7Sit089160@www.freebsd.org>
Date: Tue, 16 May 2006 18:07:28 GMT
From: Andreas Wiese <bzimage@gmx.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Update port: x11/fbpanel:  Patch for using CPU plugin
X-Send-Pr-Version: www-2.3

>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:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 16 18:10:20 GMT 2006
>Closed-Date:    Mon May 22 08:24:47 GMT 2006
>Last-Modified:  Mon May 22 08:24:47 GMT 2006
>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@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@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@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@2ka.mipt.ru>:) */
++/*
++ * A little bug fixed by Mykola <mykola@2ka.mipt.ru> :)
++ * FreeBSD support added by Andreas Wiese <aw@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:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Tue May 16 18:24:16 UTC 2006 
State-Changed-Why:  
Awaiting maintainers feedback 

http://www.freebsd.org/cgi/query-pr.cgi?pr=97357 

From: Tobias Roth <ports@fsck.ch>
To: bug-followup@FreeBSD.org
Cc: Edwin Groothuis <edwin@FreeBSD.org>,
	Andreas Wiese <bzimage@gmx.net>
Subject: Re: ports/97357: Update port: x11/fbpanel:  Patch for using CPU
 plugin
Date: Wed, 17 May 2006 10:22:30 +0200

 This looks and works well, thanks! I'll submit an updated version of
 the patch this weekend. This version will include some minor changes I
 want to do to the port.

From: Tobias Roth <ports@fsck.ch>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/97357: Update port: x11/fbpanel:  Patch for using CPU
 plugin
Date: Mon, 22 May 2006 09:58:22 +0200

 Please close this PR, the new patch can be found in 97575. I
 accidentally submitted it as a new PR instead of a follow-up.
 
 Thanks, Tobias
State-Changed-From-To: feedback->closed 
State-Changed-By: itetcu 
State-Changed-When: Mon May 22 08:24:43 UTC 2006 
State-Changed-Why:  
obsoleted by 97575 

http://www.freebsd.org/cgi/query-pr.cgi?pr=97357 
>Unformatted:
