commit:     47d734b5d4acb322b1db5b57a45e59c936380b06
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  1 21:48:45 2018 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Fri Jun  1 21:51:46 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=47d734b5

net-misc/omnisync: fix bugs, allow multiple instances

Code bugs:
- Fix --help display
- Raise SHM unit limit
- getopt loop failed to apply stats_file setting.

Init improvement:
- allow multiple instances.
- write pidfile
- declare that we use DNS (in case it starts before local resolver)

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
Package-Manager: Portage-2.3.33, Repoman-2.3.9

 net-misc/omnisync/files/omnisync-1.0-help.patch    | 16 ++++++++
 net-misc/omnisync/files/omnisync-1.0-maxshm.patch  | 18 ++++++++
 .../omnisync/files/omnisync-1.0-statfile.patch     | 18 ++++++++
 net-misc/omnisync/files/omnisync.initd             | 11 ++++-
 net-misc/omnisync/omnisync-1.0-r1.ebuild           | 48 ++++++++++++++++++++++
 5 files changed, 109 insertions(+), 2 deletions(-)

diff --git a/net-misc/omnisync/files/omnisync-1.0-help.patch 
b/net-misc/omnisync/files/omnisync-1.0-help.patch
new file mode 100644
index 00000000000..47ff5201c03
--- /dev/null
+++ b/net-misc/omnisync/files/omnisync-1.0-help.patch
@@ -0,0 +1,16 @@
+main: fix help missing newline
+
+Signed-off-by: Robin H. Johnson <robb...@gentoo.org>
+
+diff -Nuar --exclude '*~' omnisync-1.0.orig/main.c omnisync-1.0/main.c
+--- omnisync-1.0.orig/main.c   2009-01-02 01:03:20.000000000 -0800
++++ omnisync-1.0/main.c        2018-06-01 14:31:25.720686155 -0700
+@@ -139,7 +139,7 @@
+       printf("-c x   community (snmp only)\n");
+       printf("-h x   host to connect to\n");
+       printf("-u x   ntpd shared memory unit\n");
+-      printf("-z x   do an initial step, to speed up syncing, parameter is 
number of samples");
++      printf("-z x   do an initial step, to speed up syncing, parameter is 
number of samples\n");
+       printf("-S x   write measurements to file x\n");
+       printf("-n     do NOT submit to NTPd/set clock, query only (use in 
combination with -v and -f)\n");
+       printf("-f     do not fork\n");

diff --git a/net-misc/omnisync/files/omnisync-1.0-maxshm.patch 
b/net-misc/omnisync/files/omnisync-1.0-maxshm.patch
new file mode 100644
index 00000000000..678c6e0072d
--- /dev/null
+++ b/net-misc/omnisync/files/omnisync-1.0-maxshm.patch
@@ -0,0 +1,18 @@
+main: raise SHM unit limit
+
+Signed-off-by: Robin H. Johnson <robb...@gentoo.org>
+
+diff -Nuar --exclude '*~' omnisync-1.0.orig/main.c omnisync-1.0/main.c
+--- omnisync-1.0.orig/main.c   2009-01-02 01:03:20.000000000 -0800
++++ omnisync-1.0/main.c        2018-06-01 14:32:34.630066839 -0700
+@@ -346,8 +346,8 @@
+                               unit_nr = atoi(optarg);
+                               if (unit_nr < 0)
+                                       error_exit("-u requires a positive 
value\n");
+-                              if (unit_nr > 3)
+-                                      error_exit("NTPd normally supports only 
4 shared memory devices, still continuing though\n");
++                              if (unit_nr > 254)
++                                      error_exit("NTPd normally supports only 
254 shared memory devices\n");
+                               break;
+ 
+                       case 'v':

diff --git a/net-misc/omnisync/files/omnisync-1.0-statfile.patch 
b/net-misc/omnisync/files/omnisync-1.0-statfile.patch
new file mode 100644
index 00000000000..972316a33bd
--- /dev/null
+++ b/net-misc/omnisync/files/omnisync-1.0-statfile.patch
@@ -0,0 +1,18 @@
+main: wire up stats_file variable
+
+Signed-off-by: Robin H. Johnson <robb...@gentoo.org>
+
+diff -Nuar --exclude '*~' omnisync-1.0.orig/main.c omnisync-1.0/main.c
+--- omnisync-1.0.orig/main.c   2009-01-02 01:03:20.000000000 -0800
++++ omnisync-1.0/main.c        2018-06-01 14:39:22.115229735 -0700
+@@ -358,6 +358,10 @@
+                               version();
+                               return 0;
+ 
++                      case 'S':
++                              stats_file = optarg;
++                              break;
++
+                       default:
+                               help();
+                               return 1;

diff --git a/net-misc/omnisync/files/omnisync.initd 
b/net-misc/omnisync/files/omnisync.initd
index 7820af6e94e..c71e63d4d3e 100644
--- a/net-misc/omnisync/files/omnisync.initd
+++ b/net-misc/omnisync/files/omnisync.initd
@@ -3,11 +3,18 @@
 # Distributed under the terms of the GNU General Public License v2
 
 depend() {
-       use net
+       use net dns
 }
 
+INSTANCE=${SVCNAME#*.}
+if [ -n "${INSTANCE}" ] && [ ${SVCNAME} != "omnisync" ]; then
+    pidfile="/var/run/omnisync.${INSTANCE}.pid"
+else
+    pidfile="/var/run/omnisync.pid"
+fi
+
 command="/usr/sbin/omnisync"
-command_args="-M ${OMNISYNC_MODE} ${OMNISYNC_ARGS}"
+command_args="-P ${pidfile} -M ${OMNISYNC_MODE} ${OMNISYNC_ARGS}"
 
 start_pre() {
        if [ -z "${OMNISYNC_MODE}" ] ; then

diff --git a/net-misc/omnisync/omnisync-1.0-r1.ebuild 
b/net-misc/omnisync/omnisync-1.0-r1.ebuild
new file mode 100644
index 00000000000..5875550ac80
--- /dev/null
+++ b/net-misc/omnisync/omnisync-1.0-r1.ebuild
@@ -0,0 +1,48 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit toolchain-funcs
+
+DESCRIPTION="A driver for NTPd for people who are firewall-challenged"
+HOMEPAGE="https://www.vanheusden.com/time/omnisync";
+LICENSE="GPL-2"
+SRC_URI="https://www.vanheusden.com/time/${PN}/${P}.tgz";
+
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="debug"
+
+RDEPEND="dev-libs/openssl:0= net-analyzer/net-snmp:="
+DEPEND="${RDEPEND}"
+DOCS=( readme.txt Changes )
+PATCHES=(
+       "${FILESDIR}"/omnisync-1.0-help.patch
+       "${FILESDIR}"/omnisync-1.0-maxshm.patch
+       "${FILESDIR}"/omnisync-1.0-statfile.patch
+)
+
+src_prepare() {
+       default
+       tc-export CC
+       sed -i \
+               -e 's/-O2 -Wall/-Wall/' \
+               -e 's/-lsnmp/-lnetsnmp/' \
+               "${S%/}/Makefile" || die
+       use debug ||  sed -i -e 's/$(DEBUG)//' "${S%/}/Makefile" || die
+}
+
+src_install() {
+       dosbin omnisync
+       newinitd "${FILESDIR%/}/${PN}.initd" ${PN}
+       newconfd "${FILESDIR%/}/${PN}.confd" ${PN}
+       einstalldocs
+}
+
+pkg_postinst() {
+       local isConfigured=$(grep 'OMNISYNC_MODE=""' 
"${ROOT%/}/etc/conf.d/${PN}")
+       if [[ -n "${isConfigured}" ]] ; then
+               elog "Be sure to configure ${PN} in ${ROOT%/}/etc/conf.d before 
trying to start the service"
+       fi
+}

Reply via email to