1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-21 00:25:50 +00:00

Update sysutils/cpulimit to 2.2

- Update for stagedir
- Update WWW

PR:		ports/190284
Submitted by:	jesse (maintainer)
Reviewed by:	bapt
Approved by:	swills (mentor), eadler (mentor)
This commit is contained in:
Jonathan Chu 2014-05-30 07:24:52 +00:00
parent 8709c3e431
commit aca0726cef
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=355795
5 changed files with 26 additions and 68 deletions

View File

@ -2,24 +2,26 @@
# $FreeBSD$
PORTNAME= cpulimit
PORTVERSION= 1.4
PORTVERSION= 2.2
CATEGORIES= sysutils
MASTER_SITES= SF/limitcpu/limitcpu/
MAINTAINER= jessefrgsmith@yahoo.ca
COMMENT= A program to limit the CPU usage of a process
COMMENT= Limit the CPU usage of a process
LICENSE= GPLv2
CFLAGS+= -lkvm -Wall -O2
MANCOMPRESSED= yes
PLIST_FILES= bin/${PORTNAME}
MAN1= ${PORTNAME}.1
PLIST_FILES= bin/cpulimit \
man/man1/cpulimit.1.gz
NO_STAGE= yes
post-patch:
@${REINPLACE_CMD} -e 's|share/||g' ${WRKSRC}/Makefile
@${REINPLACE_CMD} -e 's|gcc|${CC}|g' ${WRKSRC}/Makefile
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/cpulimit ${STAGEDIR}${PREFIX}/bin/cpulimit
${INSTALL_MAN} ${WRKSRC}/cpulimit.1 ${STAGEDIR}${MANPREFIX}/man/man1/cpulimit.1
.include <bsd.port.mk>

View File

@ -1,2 +1,2 @@
SHA256 (cpulimit-1.4.tar.gz) = 48bb37801c83c926bf891ca66927c4c51ed1f2186bb3d61a70b19168d3c576df
SIZE (cpulimit-1.4.tar.gz) = 15950
SHA256 (cpulimit-2.2.tar.gz) = 3f64daa5c4ab9245fa6ae5b564a2ffb3ae60677785103a207fd5f9c5c4cc29e4
SIZE (cpulimit-2.2.tar.gz) = 22224

View File

@ -0,0 +1,15 @@
--- ./Makefile.orig 2014-05-26 17:50:50.639513964 -0300
+++ ./Makefile 2014-05-26 17:51:17.773388294 -0300
@@ -11,11 +11,8 @@
minix:
$(CC) -o cpulimit cpulimit.c $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
-freebsd:
- $(CC) -o cpulimit cpulimit.c -lrt -DFREEBSD $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
-
cpulimit: cpulimit.c
- $(CC) -o cpulimit cpulimit.c -lrt -DLINUX $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
+ $(CC) -o cpulimit cpulimit.c -lrt -lkvm -DFREEBSD $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
tests:
$(MAKE) -C test

View File

@ -1,59 +0,0 @@
--- ./cpulimit.c.orig 2011-08-12 19:35:36.000000000 -0300
+++ ./cpulimit.c 2011-08-12 21:31:58.000000000 -0300
@@ -35,6 +35,15 @@
#include <limits.h> // for compatibility
+#include <limits.h>
+#include <fcntl.h>
+#include <kvm.h>
+#include <paths.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+
+
//kernel time resolution (inverse of one jiffy interval) in Hertz
//i don't know how to detect it, then define to the default (not very clean!)
#define HZ 100
@@ -245,6 +254,31 @@
}
//get jiffies count from /proc filesystem
+int getjiffies(int pid)
+{
+ kvm_t *my_kernel = NULL;
+ struct kinfo_proc *process_data = NULL;
+ int processes;
+ int my_jiffies = -1;
+
+ my_kernel = kvm_open(0, 0, 0, O_RDONLY, "kvm_open");
+ if (! my_kernel)
+ {
+ printf("Error opening kernel vm. You should be running as root.\n");
+ return -1;
+ }
+
+ process_data = kvm_getprocs(my_kernel, KERN_PROC_PID, pid, &processes);
+ if ( (process_data) && (processes >= 1) )
+ my_jiffies = process_data->ki_runtime;
+
+ kvm_close(my_kernel);
+ if (my_jiffies >= 0)
+ my_jiffies /= 1000;
+ return my_jiffies;
+}
+
+/*
int getjiffies(int pid) {
static char stat[20];
static char buffer[1024];
@@ -271,6 +305,8 @@
// could not read info
return -1;
}
+*/
+
//process instant photo
struct process_screenshot {

View File

@ -2,4 +2,4 @@ The cpulimit program throttles back a process's CPU usage. This allows the
user to slow down jobs that would otherwise choke the processor. It is also
helpful on laptops where we want to avoid generating a lot of heat.
WWW: http://cpulimit.sourceforge.net/
WWW: http://limitcpu.sourceforge.net/