* Drop debian/dirs, create /usr/bin directly from debian/rules.
* Set debhelper compatibility level to 6.
* debian/rules: remove configure and configure-stamp targets.
+ * Switch patch system from dpatch to quilt.
-- gregor herrmann <gregor+debian@comodo.priv.at> Thu, 13 Mar 2008 23:57:20 +0100
Priority: optional
Maintainer: gregor herrmann <gregor+debian@comodo.priv.at>
Uploaders: tony mancill <tmancill@debian.org>
-Build-Depends: debhelper (>= 6), dpatch
+Build-Depends: debhelper (>= 6), quilt (>= 0.40)
Standards-Version: 3.7.3
Homepage: http://cpulimit.sourceforge.net/
Vcs-Svn: http://svn.toastfreeware.priv.at/debian/cpulimit/trunk/
+++ /dev/null
-01_priority
+++ /dev/null
-#! /bin/sh /usr/share/dpatch/dpatch-run
-## 01_priority.dpatch by <gregor+debian@comodo.priv.at>
-##
-## All lines beginning with `## DP:' are a description of the patch.
-## DP: only drop priority if it can be raised too.
-## DP: and implement RLIMIT_NICE option.
-
-@DPATCH@
-diff -urNad cpulimit~/cpulimit.c cpulimit/cpulimit.c
---- cpulimit~/cpulimit.c 2006-04-03 22:33:07.000000000 +0200
-+++ cpulimit/cpulimit.c 2007-03-03 22:06:14.000000000 +0100
-@@ -42,6 +42,7 @@
- #include <dirent.h>
- #include <errno.h>
- #include <string.h>
-+#include <limits.h> //for INT_MAX, could also hardcode some large number
-
- //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!)
-@@ -59,6 +60,8 @@
- int verbose=0;
- //lazy mode
- int lazy=0;
-+//is higher priority nice possible?
-+int nice_lim;
-
- //reverse byte search
- void *memrchr(const void *s, int c, size_t n);
-@@ -71,7 +74,7 @@
-
- int waitforpid(int pid) {
- //switch to low priority
-- if (setpriority(PRIO_PROCESS,getpid(),19)!=0) {
-+ if (nice_lim < INT_MAX && setpriority(PRIO_PROCESS,getpid(),19)!=0) {
- printf("Warning: cannot renice\n");
- }
-
-@@ -127,8 +130,8 @@
- done:
- printf("Process %d detected\n",pid);
- //now set high priority, if possible
-- if (setpriority(PRIO_PROCESS,getpid(),-20)!=0) {
-- printf("Warning: cannot renice.\nTo work better you should run this program as root.\n");
-+ if (nice_lim < INT_MAX && setpriority(PRIO_PROCESS,getpid(),nice_lim)!=0) {
-+ printf("Warning: cannot renice.\n");
- }
- return 0;
-
-@@ -143,7 +146,7 @@
- int getpidof(const char *process) {
-
- //set low priority
-- if (setpriority(PRIO_PROCESS,getpid(),19)!=0) {
-+ if (nice_lim < INT_MAX && setpriority(PRIO_PROCESS,getpid(),19)!=0) {
- printf("Warning: cannot renice\n");
- }
-
-@@ -219,8 +222,8 @@
- done:
- printf("Process %d detected\n",pid);
- //now set high priority, if possible
-- if (setpriority(PRIO_PROCESS,getpid(),-20)!=0) {
-- printf("Warning: cannot renice.\nTo work better you should run this program as root.\n");
-+ if (nice_lim < INT_MAX && setpriority(PRIO_PROCESS,getpid(),nice_lim)!=0) {
-+ printf("Warning: cannot renice.\n");
- }
- return pid;
-
-@@ -373,6 +376,7 @@
- int pid_ok=0;
- int process_ok=0;
- int limit_ok=0;
-+ struct rlimit maxlimit;
-
- do {
- next_option = getopt_long (argc, argv, short_options,long_options, NULL);
-@@ -437,6 +441,35 @@
- signal(SIGINT,quit);
- signal(SIGTERM,quit);
-
-+ //now test high priority
-+ if (setpriority(PRIO_PROCESS,getpid(),-20)!=0) {
-+ //if that failed, check if we have a limit by how much we can raise the priority
-+#ifdef RLIMIT_NICE //check if non-root can even make changes (ifdef because it's only available in linux >= 2.6.13)
-+ nice_lim=getpriority(PRIO_PROCESS,getpid());
-+ getrlimit(RLIMIT_NICE, &maxlimit);
-+
-+ if( (20 - (signed)maxlimit.rlim_cur) < nice_lim && //if we can do better then current
-+ setpriority(PRIO_PROCESS,getpid(),20 - (signed)maxlimit.rlim_cur)==0 //and it actually works
-+ ) {
-+
-+ //if we can do better, but not by much, warn about it
-+ if( (nice_lim - (20 - (signed)maxlimit.rlim_cur)) < 9) {
-+ printf("Warning, can only increase priority by %d.\n", nice_lim - (20 - (signed)maxlimit.rlim_cur));
-+ }
-+
-+ nice_lim = 20 - (signed)maxlimit.rlim_cur; //our new limit
-+
-+ } else //otherwise don't try to change priority. The below will also run if it's not possible for non-root to change priority
-+#endif
-+ {
-+ printf("Warning: cannot renice.\nTo work better you should run this program as root, or adjust RLIMIT_NICE.\nFor example in /etc/security/limits.conf add a line with: * - nice -10\n\n");
-+ nice_lim=INT_MAX;
-+ }
-+ } else {
-+ nice_lim=-20;
-+ }
-+ //don't bother putting setpriority back down, since getpidof and waitforpid twiddle it anyway
-+
- //time quantum in microseconds. it's splitted in a working period and a sleeping one
- int period=100000;
- struct timespec twork,tsleep; //working and sleeping intervals
--- /dev/null
+Author: Ariel <asdebian@dsgml.com>
+Description: only drop priority if it can be raised too
+ and implement RLIMIT_NICE option.
+Bugs: #412421
+
+--- cpulimit-1.1.orig/cpulimit.c
++++ cpulimit-1.1/cpulimit.c
+@@ -42,6 +42,7 @@
+ #include <dirent.h>
+ #include <errno.h>
+ #include <string.h>
++#include <limits.h> //for INT_MAX, could also hardcode some large number
+
+ //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!)
+@@ -59,6 +60,8 @@
+ int verbose=0;
+ //lazy mode
+ int lazy=0;
++//is higher priority nice possible?
++int nice_lim;
+
+ //reverse byte search
+ void *memrchr(const void *s, int c, size_t n);
+@@ -71,7 +74,7 @@
+
+ int waitforpid(int pid) {
+ //switch to low priority
+- if (setpriority(PRIO_PROCESS,getpid(),19)!=0) {
++ if (nice_lim < INT_MAX && setpriority(PRIO_PROCESS,getpid(),19)!=0) {
+ printf("Warning: cannot renice\n");
+ }
+
+@@ -127,8 +130,8 @@
+ done:
+ printf("Process %d detected\n",pid);
+ //now set high priority, if possible
+- if (setpriority(PRIO_PROCESS,getpid(),-20)!=0) {
+- printf("Warning: cannot renice.\nTo work better you should run this program as root.\n");
++ if (nice_lim < INT_MAX && setpriority(PRIO_PROCESS,getpid(),nice_lim)!=0) {
++ printf("Warning: cannot renice.\n");
+ }
+ return 0;
+
+@@ -143,7 +146,7 @@
+ int getpidof(const char *process) {
+
+ //set low priority
+- if (setpriority(PRIO_PROCESS,getpid(),19)!=0) {
++ if (nice_lim < INT_MAX && setpriority(PRIO_PROCESS,getpid(),19)!=0) {
+ printf("Warning: cannot renice\n");
+ }
+
+@@ -219,8 +222,8 @@
+ done:
+ printf("Process %d detected\n",pid);
+ //now set high priority, if possible
+- if (setpriority(PRIO_PROCESS,getpid(),-20)!=0) {
+- printf("Warning: cannot renice.\nTo work better you should run this program as root.\n");
++ if (nice_lim < INT_MAX && setpriority(PRIO_PROCESS,getpid(),nice_lim)!=0) {
++ printf("Warning: cannot renice.\n");
+ }
+ return pid;
+
+@@ -373,6 +376,7 @@
+ int pid_ok=0;
+ int process_ok=0;
+ int limit_ok=0;
++ struct rlimit maxlimit;
+
+ do {
+ next_option = getopt_long (argc, argv, short_options,long_options, NULL);
+@@ -437,6 +441,35 @@
+ signal(SIGINT,quit);
+ signal(SIGTERM,quit);
+
++ //now test high priority
++ if (setpriority(PRIO_PROCESS,getpid(),-20)!=0) {
++ //if that failed, check if we have a limit by how much we can raise the priority
++#ifdef RLIMIT_NICE //check if non-root can even make changes (ifdef because it's only available in linux >= 2.6.13)
++ nice_lim=getpriority(PRIO_PROCESS,getpid());
++ getrlimit(RLIMIT_NICE, &maxlimit);
++
++ if( (20 - (signed)maxlimit.rlim_cur) < nice_lim && //if we can do better then current
++ setpriority(PRIO_PROCESS,getpid(),20 - (signed)maxlimit.rlim_cur)==0 //and it actually works
++ ) {
++
++ //if we can do better, but not by much, warn about it
++ if( (nice_lim - (20 - (signed)maxlimit.rlim_cur)) < 9) {
++ printf("Warning, can only increase priority by %d.\n", nice_lim - (20 - (signed)maxlimit.rlim_cur));
++ }
++
++ nice_lim = 20 - (signed)maxlimit.rlim_cur; //our new limit
++
++ } else //otherwise don't try to change priority. The below will also run if it's not possible for non-root to change priority
++#endif
++ {
++ printf("Warning: cannot renice.\nTo work better you should run this program as root, or adjust RLIMIT_NICE.\nFor example in /etc/security/limits.conf add a line with: * - nice -10\n\n");
++ nice_lim=INT_MAX;
++ }
++ } else {
++ nice_lim=-20;
++ }
++ //don't bother putting setpriority back down, since getpidof and waitforpid twiddle it anyway
++
+ //time quantum in microseconds. it's splitted in a working period and a sleeping one
+ int period=100000;
+ struct timespec twork,tsleep; //working and sleeping intervals
--- /dev/null
+01_priority.patch
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
-include /usr/share/dpatch/dpatch.make
+include /usr/share/quilt/quilt.make
CFLAGS = -Wall -g
endif
build: build-stamp
-build-stamp: $(DPATCH_STAMPFN)
+build-stamp: $(QUILT_STAMPFN)
dh_testdir
$(MAKE)
touch $@