Index: head/sysutils/swapd/Makefile =================================================================== --- head/sysutils/swapd/Makefile (revision 434807) +++ head/sysutils/swapd/Makefile (revision 434808) @@ -1,28 +1,32 @@ # Created by: Yen-Ming Lee # $FreeBSD$ PORTNAME= swapd PORTVERSION= 1.0.5 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= sysutils MASTER_SITES= http://www.rkeene.org/files/oss/swapd/ MAINTAINER= ports@FreeBSD.org COMMENT= Daemon that watches free memory and manages swap files +LICENSE= GPLv2 +LICENSE_FILE= ${WRKSRC}/LICENSE + LIB_DEPENDS= libstatgrab.so:devel/libstatgrab USES= gmake pkgconfig GNU_CONFIGURE= yes USE_RC_SUBR= swapd post-patch: @${REINPLACE_CMD} -e "s,%%PREFIX%%,${PREFIX},g" ${WRKSRC}/${CONFIGURE_SCRIPT} post-install: + ${STRIP_CMD} ${STAGEDIR}${PREFIX}/sbin/${PORTNAME} .for f in swapd_swapon swapd_swapoff ${INSTALL_SCRIPT} ${FILESDIR}/${f} ${STAGEDIR}${PREFIX}/sbin .endfor .include Index: head/sysutils/swapd/files/patch-Makefile.in =================================================================== --- head/sysutils/swapd/files/patch-Makefile.in (revision 434807) +++ head/sysutils/swapd/files/patch-Makefile.in (revision 434808) @@ -1,22 +1,22 @@ ---- ./Makefile.in.orig 2004-10-18 06:05:24.000000000 +0100 -+++ ./Makefile.in 2013-11-22 22:33:19.141103774 +0000 -@@ -30,11 +30,11 @@ +--- Makefile.in.orig 2004-10-18 05:05:24 UTC ++++ Makefile.in +@@ -30,11 +30,11 @@ distclean: clean rm -f Makefile config.h config.status config.log swapd.8 swapd.conf.5 install: all - -$(INSTALL) -d $(sbindir) - -$(INSTALL) -d $(sysconfdir) - -$(INSTALL) -d $(mandir)/man8 - -$(INSTALL) -d $(mandir)/man5 - $(INSTALL) -m 755 swapd$(EXEEXT) $(sbindir)/swapd$(EXEEXT) - $(INSTALL) -m 644 swapd.conf $(sysconfdir)/swapd.conf - $(INSTALL) -m 644 swapd.8 $(mandir)/man8/swapd.8 - $(INSTALL) -m 644 swapd.conf.5 $(mandir)/man5/swapd.conf.5 + -$(INSTALL) -d $(DESTDIR)$(sbindir) + -$(INSTALL) -d $(DESTDIR)$(sysconfdir) + -$(INSTALL) -d $(DESTDIR)$(mandir)/man8 + -$(INSTALL) -d $(DESTDIR)$(mandir)/man5 + $(INSTALL) -m 755 swapd$(EXEEXT) $(DESTDIR)$(sbindir)/swapd$(EXEEXT) + $(INSTALL) -m 644 swapd.conf $(DESTDIR)$(sysconfdir)/swapd.conf.sample + $(INSTALL) -m 644 swapd.8 $(DESTDIR)$(mandir)/man8/swapd.8 + $(INSTALL) -m 644 swapd.conf.5 $(DESTDIR)$(mandir)/man5/swapd.conf.5 Index: head/sysutils/swapd/files/patch-configure =================================================================== --- head/sysutils/swapd/files/patch-configure (revision 434807) +++ head/sysutils/swapd/files/patch-configure (revision 434808) @@ -1,36 +1,36 @@ ---- ./configure.orig 2013-10-06 17:11:43.000000000 +0100 -+++ ./configure 2013-11-22 21:48:41.875104078 +0000 -@@ -4850,6 +4850,7 @@ +--- configure.orig 2013-10-06 16:11:43 UTC ++++ configure +@@ -4850,6 +4850,7 @@ fi for ac_func in swapoff do : ac_fn_c_check_func "$LINENO" "swapoff" "ac_cv_func_swapoff" +ac_cv_func_swapoff=no if test "x$ac_cv_func_swapoff" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SWAPOFF 1 -@@ -4861,6 +4862,7 @@ +@@ -4861,6 +4862,7 @@ done ac_fn_c_check_func "$LINENO" "swapon" "ac_cv_func_swapon" +ac_cv_func_swapon=no if test "x$ac_cv_func_swapon" = xyes; then : -@@ -5114,6 +5116,17 @@ +@@ -5114,6 +5116,17 @@ $as_echo "#define SWAPD_SWAP_PERMS 01600 $as_echo "#define SWAPD_SWAPOFF_CMDLINE \"/sbin/swapctl -d \\\"%s\\\"\"" >>confdefs.h ;; + 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 Index: head/sysutils/swapd/files/patch-swapd.c =================================================================== --- head/sysutils/swapd/files/patch-swapd.c (revision 434807) +++ head/sysutils/swapd/files/patch-swapd.c (revision 434808) @@ -1,94 +1,94 @@ ---- swapd.c.orig 2005-02-18 20:32:30.000000000 -0800 -+++ swapd.c 2010-06-25 12:16:07.000000000 -0700 +--- swapd.c.orig 2013-10-06 16:09:13 UTC ++++ swapd.c @@ -1,3 +1,6 @@ +#include +#include +#include #include "compat.h" #ifdef HAVE_STDIO_H -@@ -187,15 +190,18 @@ +@@ -188,15 +191,18 @@ int swapd_swapon(const char *swapfile) { # 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 @@ +@@ -287,7 +293,9 @@ swap_t *swapd_mkswap(const char *swapdir 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 @@ +@@ -300,11 +308,13 @@ int swapd_swapoff(swap_t *swapfile) { /* 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 @@ +@@ -445,6 +455,8 @@ int main(int argc, char **argv) { 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 @@ +@@ -519,7 +531,7 @@ int main(int argc, char **argv) { daemonize(); - dh = opendir("."); + dh = opendir(swapdir); if (dh != NULL) { inactive_swaps = 0; -@@ -587,7 +599,7 @@ +@@ -588,7 +600,7 @@ int main(int argc, char **argv) { } } - swapinfo = swapd_mkswap(".", swapsize, swapfile); + swapinfo = swapd_mkswap(swapdir, swapsize, swapfile); if (swapfile != NULL) { free(swapfile); -@@ -637,6 +649,7 @@ +@@ -638,6 +650,7 @@ int main(int argc, char **argv) { 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 @@ +@@ -659,5 +672,6 @@ int main(int argc, char **argv) { } + closelog(); return(EXIT_FAILURE); } Index: head/sysutils/swapd/files/patch-swapd.conf.5.in =================================================================== --- head/sysutils/swapd/files/patch-swapd.conf.5.in (revision 434807) +++ head/sysutils/swapd/files/patch-swapd.conf.5.in (revision 434808) @@ -1,11 +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 @@ +--- swapd.conf.5.in.orig 2005-02-19 04:22:44 UTC ++++ swapd.conf.5.in +@@ -14,7 +14,7 @@ at startup. The configuration file is i maxfree 0 swapsize 32m swapdir /var/tmp - maxunusedswap 5 + maxunusedswaps 5 delay 30 include_cache yes .fi