diff options
author | Yen-Ming Lee <leeym@FreeBSD.org> | 2010-06-25 22:38:17 +0000 |
---|---|---|
committer | Yen-Ming Lee <leeym@FreeBSD.org> | 2010-06-25 22:38:17 +0000 |
commit | efb351f724bb7ec9acf6d316ee19ca67fe0092f0 (patch) | |
tree | 1db04fdd6d9dedfe422e8fcaf4befb4130497f7c /sysutils/swapd | |
parent | 73d56dd4444b4670b0147d2f4197b072dad29b71 (diff) | |
download | ports-efb351f724bb7ec9acf6d316ee19ca67fe0092f0.tar.gz ports-efb351f724bb7ec9acf6d316ee19ca67fe0092f0.zip |
Notes
Diffstat (limited to 'sysutils/swapd')
-rw-r--r-- | sysutils/swapd/Makefile | 9 | ||||
-rw-r--r-- | sysutils/swapd/files/patch-configure | 36 | ||||
-rw-r--r-- | sysutils/swapd/files/patch-swapd.c | 94 | ||||
-rw-r--r-- | sysutils/swapd/files/patch-swapd.conf.5.in | 11 | ||||
-rw-r--r-- | sysutils/swapd/files/swapd_swapoff | 16 | ||||
-rw-r--r-- | sysutils/swapd/files/swapd_swapon | 16 | ||||
-rw-r--r-- | sysutils/swapd/pkg-plist | 2 |
7 files changed, 184 insertions, 0 deletions
diff --git a/sysutils/swapd/Makefile b/sysutils/swapd/Makefile index 896cf4a2cae1..84d6e909e84d 100644 --- a/sysutils/swapd/Makefile +++ b/sysutils/swapd/Makefile @@ -7,6 +7,7 @@ PORTNAME= swapd PORTVERSION= 1.0.3 +PORTREVISION= 1 CATEGORIES= sysutils MASTER_SITES= http://www.rkeene.org/files/oss/swapd/source/ @@ -22,4 +23,12 @@ USE_RC_SUBR= swapd MAN5= swapd.conf.5 MAN8= swapd.8 +post-patch: + @${REINPLACE_CMD} -e "s,%%PREFIX%%,${PREFIX},g" ${WRKSRC}/${CONFIGURE_SCRIPT} + +post-install: +.for f in swapd_swapon swapd_swapoff + ${INSTALL_SCRIPT} ${FILESDIR}/${f} ${PREFIX}/sbin +.endfor + .include <bsd.port.mk> diff --git a/sysutils/swapd/files/patch-configure b/sysutils/swapd/files/patch-configure new file mode 100644 index 000000000000..afa8164dbf96 --- /dev/null +++ b/sysutils/swapd/files/patch-configure @@ -0,0 +1,36 @@ +--- configure.orig 2005-02-18 20:34:16.000000000 -0800 ++++ configure 2010-06-25 00:26:06.000000000 -0700 +@@ -11435,6 +11435,7 @@ + rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + fi ++eval "$as_ac_var=no" + echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 + echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 + if test `eval echo '${'$as_ac_var'}'` = yes; then +@@ -11535,6 +11536,7 @@ + rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + fi ++ac_cv_func_swapon=no + echo "$as_me:$LINENO: result: $ac_cv_func_swapon" >&5 + echo "${ECHO_T}$ac_cv_func_swapon" >&6 + if test $ac_cv_func_swapon = yes; then +@@ -12170,6 +12172,17 @@ + _ACEOF + + ;; ++ freebsd*) ++ ++cat >>confdefs.h <<\_ACEOF ++#define SWAPD_SWAPON_CMDLINE "/usr/local/sbin/swapd_swapon \"%s\"" ++_ACEOF ++ ++cat >>confdefs.h <<\_ACEOF ++#define SWAPD_SWAPOFF_CMDLINE "/usr/local/sbin/swapd_swapoff \"%s\"" ++_ACEOF ++ ++ ;; + esac + + diff --git a/sysutils/swapd/files/patch-swapd.c b/sysutils/swapd/files/patch-swapd.c new file mode 100644 index 000000000000..eabf2cd11055 --- /dev/null +++ b/sysutils/swapd/files/patch-swapd.c @@ -0,0 +1,94 @@ +--- swapd.c.orig 2005-02-18 20:32:30.000000000 -0800 ++++ swapd.c 2010-06-25 12:16:07.000000000 -0700 +@@ -1,3 +1,6 @@ ++#include <syslog.h> ++#include <stdarg.h> ++#include <errno.h> + #include "compat.h" + + #ifdef HAVE_STDIO_H +@@ -187,15 +190,18 @@ + # ifdef SWAPON_TAKES_2_ARGS + /* Linux */ + swaponret = swapon(swapfile, 0); ++ syslog(LOG_NOTICE, "swapon(%s, 0) ret:%d errno:%d", swapfile, swaponret, errno); + # else + /* BSD */ + swaponret = swapon(swapfile); ++ syslog(LOG_NOTICE, "swapon(%s) ret:%d errno:%d", swapfile, swaponret, errno); + # endif + #else + # ifdef SWAPD_SWAPON_CMDLINE + char cmdline[1024] = {0}; + snprintf(cmdline, sizeof(cmdline) - 1, SWAPD_SWAPON_CMDLINE, swapfile); + swaponret = system(cmdline); ++ syslog(LOG_NOTICE, "swapon: %s ret:%d errno:%d", cmdline, swaponret, errno); + # else + # error Dont know how to swapon() on this platform! + # endif +@@ -286,7 +292,9 @@ + + int swapd_swapoff(swap_t *swapfile) { + int swapoffret = -1; ++#ifdef SWAPD_SWAPOFF_CMDLINE + char cmdline[1024] = {0}; ++#endif + + if (swapfile == NULL) { + return(-1); +@@ -299,11 +307,13 @@ + /* Prefer the swapoff() system call ... */ + #ifdef HAVE_SWAPOFF + swapoffret = swapoff(swapfile->pathname); ++ syslog(LOG_NOTICE, "swapoff(%s) ret:%d errno:%d", swapfile->pathname, swapoffret, errno); + #else + /* ... if that's not available, try some command.. */ + # ifdef SWAPD_SWAPOFF_CMDLINE + snprintf(cmdline, sizeof(cmdline) - 1, SWAPD_SWAPOFF_CMDLINE, swapfile->pathname); + swapoffret = system(cmdline); ++ syslog(LOG_NOTICE, "swapoff: %s ret:%d errno:%d", cmdline, swapoffret, errno); + # else + /* ... otherwise, issue a warning since we don't know what to do. */ + # warning Dont know how to swapoff on this platform +@@ -444,6 +454,8 @@ + int chdirret = 0, statret = 0; + int gfm_errorcount = 0; + ++ openlog("swapd", LOG_PID, LOG_DAEMON); ++ + if (!swapd_init_stats()) { + return(EXIT_FAILURE); + } +@@ -518,7 +530,7 @@ + + daemonize(); + +- dh = opendir("."); ++ dh = opendir(swapdir); + + if (dh != NULL) { + inactive_swaps = 0; +@@ -587,7 +599,7 @@ + } + } + +- swapinfo = swapd_mkswap(".", swapsize, swapfile); ++ swapinfo = swapd_mkswap(swapdir, swapsize, swapfile); + + if (swapfile != NULL) { + free(swapfile); +@@ -637,6 +649,7 @@ + if (swaps[i]->active == 0 && swaps[i]->pathname != NULL) { + inactive_swaps++; + if (inactive_swaps > max_inactive_swaps) { ++ syslog(LOG_NOTICE, "unlink(%s)", swaps[i]->pathname); + unlink(swaps[i]->pathname); + free(swaps[i]->pathname); + free(swaps[i]); +@@ -658,5 +671,6 @@ + + } + ++ closelog(); + return(EXIT_FAILURE); + } diff --git a/sysutils/swapd/files/patch-swapd.conf.5.in b/sysutils/swapd/files/patch-swapd.conf.5.in new file mode 100644 index 000000000000..8bff84f43253 --- /dev/null +++ b/sysutils/swapd/files/patch-swapd.conf.5.in @@ -0,0 +1,11 @@ +--- swapd.conf.5.in.orig 2010-06-24 16:22:44.000000000 -0700 ++++ swapd.conf.5.in 2010-06-24 16:22:57.000000000 -0700 +@@ -14,7 +14,7 @@ + maxfree 0 + swapsize 32m + swapdir /var/tmp +- maxunusedswap 5 ++ maxunusedswaps 5 + delay 30 + include_cache yes + .fi diff --git a/sysutils/swapd/files/swapd_swapoff b/sysutils/swapd/files/swapd_swapoff new file mode 100644 index 000000000000..5e0e52e08587 --- /dev/null +++ b/sysutils/swapd/files/swapd_swapoff @@ -0,0 +1,16 @@ +#!/bin/sh +swapfile=$1 +if [ -z "$swapfile" ]; then + echo "usage: $0 swapfile" + exit 1 +fi +if [ ! -f $swapfile ]; then + echo "$0: swapfile '$swapfile' not found" + exit 1 +fi +mdev=`/sbin/mdconfig -l -v | grep ${swapfile} | awk '{print $1}'` +if [ -z "$mdev" ]; then + echo "$0: swapfile '$swapfile' is not in use" + exit 1 +fi +/sbin/swapoff /dev/${mdev} && /sbin/mdconfig -d -u /dev/${mdev} diff --git a/sysutils/swapd/files/swapd_swapon b/sysutils/swapd/files/swapd_swapon new file mode 100644 index 000000000000..18ed94a43507 --- /dev/null +++ b/sysutils/swapd/files/swapd_swapon @@ -0,0 +1,16 @@ +#!/bin/sh +swapfile=$1 +if [ -z "$swapfile" ]; then + echo "usage: $0 swapfile" + exit 1 +fi +if [ ! -f $swapfile ]; then + echo "$0: swapfile '$swapfile' not found" + exit 1 +fi +mdev=`/sbin/mdconfig -a -t vnode -f ${swapfile}` +if [ -z "$mdev" ]; then + echo "$0: unable to create vnode for swapfile '$swapfile'" + exit 1 +fi +/sbin/swapon /dev/${mdev} diff --git a/sysutils/swapd/pkg-plist b/sysutils/swapd/pkg-plist index 885e5305f83e..339cdf1ebb59 100644 --- a/sysutils/swapd/pkg-plist +++ b/sysutils/swapd/pkg-plist @@ -1,4 +1,6 @@ sbin/swapd +sbin/swapd_swapon +sbin/swapd_swapoff @unexec if cmp -s %D/etc/swapd.conf %D/etc/swapd.conf.sample; then rm -f %D/etc/swapd.conf; fi etc/swapd.conf.sample @exec [ ! -f %B/swapd.conf ] && cp %B/%f %B/swapd.conf |