From 08f02759a0e1fac5e8f387bcc85a7ed5805d9100 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Fri, 25 Nov 2011 11:31:25 -0600
Subject: ddclient: Add back ddforeground client.  Without this ddclient will
 not work with runit. Not for sure why we are using ddclient again instead of
 indyn refs #797

---
 abs/extra/ddclient/PKGBUILD                  | 12 ++++---
 abs/extra/ddclient/__changelog               |  1 +
 abs/extra/ddclient/ddclient-foreground.patch | 47 ++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 5 deletions(-)
 create mode 100644 abs/extra/ddclient/__changelog
 create mode 100644 abs/extra/ddclient/ddclient-foreground.patch

diff --git a/abs/extra/ddclient/PKGBUILD b/abs/extra/ddclient/PKGBUILD
index 4942d7b..77be4a8 100644
--- a/abs/extra/ddclient/PKGBUILD
+++ b/abs/extra/ddclient/PKGBUILD
@@ -4,7 +4,7 @@
 
 pkgname=ddclient
 pkgver=3.8.0
-pkgrel=2
+pkgrel=4
 pkgdesc="Update dynamic DNS entries for accounts on many dynamic DNS services."
 arch=('any')
 url="http://ddclient.sourceforge.net/"
@@ -12,13 +12,11 @@ license=('GPL2')
 depends=('perl' 'perl-io-socket-ssl')
 backup=('etc/ddclient/ddclient.conf' 'etc/conf.d/ddclient')
 install=ddclient.install
-source=(http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.bz2 ddclient.rc ddclient.conf.d)
-md5sums=('6cac7a5eb1da781bfd4d98cef0b21f8e'
-         '7035bf8132f3517a59167f61ee5e8b90'
-         'b8f39c82827776da948b76ef83544d33')
+source=(http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.bz2 ddclient.rc ddclient.conf.d ddclient-foreground.patch)
 
 build() {
   cd ${srcdir}/ddclient-${pkgver}
+  patch < ${srcdir}/ddclient-foreground.patch
 
   # core files
   install -D -m755 ddclient ${pkgdir}/usr/sbin/ddclient
@@ -33,3 +31,7 @@ build() {
   install -D -m644 sample-etc_dhcpc_dhcpcd-eth0.exe ${pkgdir}/etc/ddclient/samples/sample-etc_dhcpc_dhcpcd-eth0.exe
   install -D -m644 sample-etc_ppp_ip-up.local ${pkgdir}/etc/ddclient/samples/sample-etc_ppp_ip-up.local
 }
+md5sums=('6cac7a5eb1da781bfd4d98cef0b21f8e'
+         '7035bf8132f3517a59167f61ee5e8b90'
+         'b8f39c82827776da948b76ef83544d33'
+         'd8ffc95f98f9afcb4a06a1e192220e35')
diff --git a/abs/extra/ddclient/__changelog b/abs/extra/ddclient/__changelog
new file mode 100644
index 0000000..64ae3f0
--- /dev/null
+++ b/abs/extra/ddclient/__changelog
@@ -0,0 +1 @@
+add ddclient-foreground.patch.  Without this ddclient will not work with runit
diff --git a/abs/extra/ddclient/ddclient-foreground.patch b/abs/extra/ddclient/ddclient-foreground.patch
new file mode 100644
index 0000000..a814ede
--- /dev/null
+++ b/abs/extra/ddclient/ddclient-foreground.patch
@@ -0,0 +1,47 @@
+--- ../ddclient-orig/ddclient	2009-10-19 22:45:15.000000000 +1030
++++ ddclient	2009-10-19 22:50:11.000000000 +1030
+@@ -307,6 +307,7 @@
+ my %variables = (
+     'global-defaults'    => {
+ 	'daemon'              => setv(T_DELAY, 0, 0, 1, 0,                    interval('60s')),
++	'foreground'          => setv(T_BOOL,  0, 0, 1, 0,                    undef),
+ 	'file'                => setv(T_FILE,  0, 0, 1, "$etc$program.conf",  undef),
+ 	'cache'               => setv(T_FILE,  0, 0, 1, "$cachedir$program.cache", undef),
+ 	'pid'                 => setv(T_FILE,  0, 0, 1, "",                   undef),
+@@ -535,6 +536,7 @@
+     "usage: ${program} [options]",
+     "options are:",
+     [ "daemon",      "=s", "-daemon delay         : run as a daemon, specify delay as an interval." ],
++    [ "foreground",  "!",  "-foreground           : do not fork" ],
+     [ "proxy",       "=s", "-proxy host           : use 'host' as the HTTP proxy" ],
+     [ "server",      "=s", "-server host          : update DNS information on 'host'" ],
+     [ "protocol",    "=s", "-protocol type        : update protocol used" ],
+@@ -623,7 +625,10 @@
+ $SIG{'HUP'}    = sub { $caught_hup  = 1; };
+ $SIG{'TERM'}   = sub { $caught_term = 1; };
+ $SIG{'KILL'}   = sub { $caught_kill = 1; };
+-if (opt('daemon') && !opt('force')) {
++# don't fork() if foreground or force is on
++if (opt('foreground') || opt('force')) {
++    ;
++} elsif (opt('daemon')) {
+     $SIG{'CHLD'}   = 'IGNORE';
+     my $pid = fork;
+     if ($pid < 0) {
+@@ -633,12 +638,15 @@
+ 	exit 0;
+     }
+     $SIG{'CHLD'}   = 'DEFAULT';
+-    $opt{'syslog'} = 1;
+     open(STDOUT, ">/dev/null");
+     open(STDERR, ">/dev/null");
+     open(STDIN,  "</dev/null");
++}
+ 
++# write out the pid file if we're daemon'ized
++if(opt('daemon')) {
+     write_pid();
++    $opt{'syslog'} = 1;
+ }
+ 
+ umask 077;
-- 
cgit v0.12