Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 May 2006 23:21:47 +0200 (CEST)
From:      Tobias Roth <ports@fsck.ch>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        Andreas Wiese <bzimage@gmx.net>, Edwin Groothuis <edwin@FreeBSD.org>
Subject:   ports/97575: [MAINTAINER] x11/fbpanel: make CPU plugin work on FreeBSD
Message-ID:  <200605212121.k4LLLlIG011151@secure.socket.ch>
Resent-Message-ID: <200605212130.k4LLUK47076740@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         97575
>Category:       ports
>Synopsis:       [MAINTAINER] x11/fbpanel: make CPU plugin work on FreeBSD
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 21 21:30:19 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Tobias Roth
>Release:        FreeBSD 6.1-STABLE i386
>Organization:
>Environment:
System: FreeBSD factory.fsck.ch 6.1-STABLE FreeBSD 6.1-STABLE #9: Fri May 19 17:29:59 CEST 2006
>Description:
Integrate patch written by Andreas Wiese <bzimage@gmx.net> from
BSD Crew Dresden, which ports the previously linux-only CPU plugin
to FreeBSD.

Thanks a lot Andreas!

Added file(s):
- files/patch-Makefile
- files/patch-cpu.c
- files/patch-plugin.c
- files/patch-plugin.h

Removed file(s):
- pkg-message

Generated with FreeBSD Port Tools 0.77
>How-To-Repeat:
>Fix:

--- fbpanel-4.3_3.patch begins here ---
Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/x11/fbpanel/Makefile,v
retrieving revision 1.9
diff -u -u -r1.9 Makefile
--- Makefile	11 Apr 2006 11:11:53 -0000	1.9
+++ Makefile	21 May 2006 20:37:00 -0000
@@ -7,7 +7,7 @@
 
 PORTNAME=	fbpanel
 PORTVERSION=	4.3
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	x11
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	${PORTNAME}
@@ -19,7 +19,7 @@
 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
 
@@ -29,9 +29,4 @@
 post-patch:
 	@${REINPLACE_CMD} -e 's|share/man|man|g' ${WRKSRC}/man/Makefile
 
-post-install:
-	@${ECHO_MSG} ""
-	@${CAT} ${PKGMESSAGE}
-	@${ECHO_MSG} ""
-
 .include <bsd.port.mk>
Index: pkg-message
===================================================================
RCS file: pkg-message
diff -N pkg-message
--- pkg-message	15 Dec 2004 06:34:35 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-Please note that the cpu plugin has not been built due to compatibility reasons.
Index: files/patch-Makefile
===================================================================
RCS file: files/patch-Makefile
diff -N files/patch-Makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-Makefile	21 May 2006 20:37:00 -0000
@@ -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 :=
Index: files/patch-cpu.c
===================================================================
RCS file: files/patch-cpu.c
diff -N files/patch-cpu.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-cpu.c	21 May 2006 20:37:00 -0000
@@ -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;
Index: files/patch-plugin.c
===================================================================
RCS file: files/patch-plugin.c
diff -N files/patch-plugin.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-plugin.c	21 May 2006 20:37:00 -0000
@@ -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();
+ }
+ 
Index: files/patch-plugin.h
===================================================================
RCS file: files/patch-plugin.h
diff -N files/patch-plugin.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-plugin.h	21 May 2006 20:37:00 -0000
@@ -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
--- fbpanel-4.3_3.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605212121.k4LLLlIG011151>