From a8d1b366d0b6f8f8a8876d010a7768e45580be74 Mon Sep 17 00:00:00 2001
From: Cecil Hugh Watson <knoppmyth@gmail.com>
Date: Sat, 4 Sep 2010 21:29:05 -0700
Subject: ntp:Bumped/Updated for LinHES 7.

---
 abs/core-testing/ntp/PKGBUILD                 |  97 +++++++++++---
 abs/core-testing/ntp/fix-ipv6.patch           |  10 ++
 abs/core-testing/ntp/ntp-4.2.4-html2man.patch | 183 ++++++++++++++++++++++++++
 abs/core-testing/ntp/ntp-4.2.4_p7-nano.patch  |  20 +++
 abs/core-testing/ntp/ntp-client.conf          |   4 +
 abs/core-testing/ntp/ntp.conf                 |  80 +++++------
 abs/core-testing/ntp/ntpd                     |   3 +-
 7 files changed, 332 insertions(+), 65 deletions(-)
 create mode 100644 abs/core-testing/ntp/fix-ipv6.patch
 create mode 100644 abs/core-testing/ntp/ntp-4.2.4-html2man.patch
 create mode 100644 abs/core-testing/ntp/ntp-4.2.4_p7-nano.patch

diff --git a/abs/core-testing/ntp/PKGBUILD b/abs/core-testing/ntp/PKGBUILD
index 83e77ad..772e0bf 100755
--- a/abs/core-testing/ntp/PKGBUILD
+++ b/abs/core-testing/ntp/PKGBUILD
@@ -1,30 +1,89 @@
+# $Id: PKGBUILD 75563 2010-04-01 20:42:21Z giovanni $
+# Maintainer: dorphell <dorphell@archlinux.org>
+
 pkgname=ntp
 pkgver=4.2.6p2
-pkgrel=1
+pkgrel=3
 pkgdesc="NTP (Network Time Protocol) tries to keep servers in sync"
 arch=(i686 x86_64)
+license=('custom')
 url="http://www.ntp.org/"
-depends=('openssl' 'readline' )
-backup=('etc/ntp.conf' 'conf.d/ntp-client.conf')
-source=(http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-${pkgver}.tar.gz \
-         ntp.conf ntp-client.conf ntpd ntpdate )
+depends=('openssl' 'readline' 'libcap')
+makedepends=('perl-html-parser')
+backup=('etc/ntp.conf' 'etc/conf.d/ntp-client.conf')
+options=('!emptydirs')
+source=(http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-${pkgver}.tar.gz
+        ntp-4.2.4_p7-nano.patch
+	fix-ipv6.patch
+	ntp-4.2.4-html2man.patch
+        ntp.conf
+        ntp-client.conf
+        ntpd
+        ntpdate)
+sha1sums=('a1f21b23c8c80f35801d59e30ba30779f2025a72' '4de6cd3fad1946146107f86d1f161eb835fbb2d3'\
+         '3632f8a00838f48e484bca24de06db443cc14fff' '7f8783e243e23c8853a9f9fb5b36f467aab8dc15'\
+         '3625ed2aa71d9e0dd04634f32e65d83b76cfe780' 'c8e388f2577b4329da5e77f0455083db6dd97fa8'\
+         'd9b09de9d718a864270e9330e20109e182dfbdd9' '6dfc3b6996f591123ee8938fd0fe7c27eb5c7552')
 
 build() {
-  cd $startdir/src/$pkgname-$pkgver
-  ./configure --prefix=/usr 
+  cd "$srcdir/$pkgname-$pkgver" || return 1
+  # fix glibc build issue
+  patch -Np1 -i ../ntp-4.2.4_p7-nano.patch || return 1
+  # fix ipv6 support
+  patch -Np1 -i ../fix-ipv6.patch || return 1
+  # fix man page generation
+  patch -Np1 -i ../ntp-4.2.4-html2man.patch || return 1
+  # configure
+  export LDFLAGS="${LDFLAGS//-Wl,--as-needed}"
+  libtoolize --copy  --force || return 1
+  ac_cv_header_dns_sd_h=0 ./configure --prefix=/usr --mandir=/usr/share/man --enable-linux-caps || return 1
+
+  # build and install
   make || return 1
-  make prefix=$startdir/pkg/usr install
-  mkdir -p $startdir/pkg/usr/share/ntp/ $startdir/pkg/usr/man/man1/
-  install -D -m644 conf/* $startdir/pkg/usr/share/ntp/
-  install -D -m755 $startdir/ntpd $startdir/pkg/etc/rc.d/ntpd
-  install -D -m755 $startdir/ntpdate $startdir/pkg/etc/rc.d/ntpdate
-  install -D -m644 $startdir/src/man/* $startdir/pkg/usr/man/man1/
-  install -D -m644 $startdir/ntp-client.conf $startdir/pkg/etc/conf.d/ntp-client.conf
-  install -D -m644 $startdir/ntp.conf $startdir/pkg/etc/ntp.conf
-}
+  make DESTDIR="$pkgdir" install || return 1
+
+  # install conf files
+  mkdir -p "$pkgdir/usr/share/ntp" || return 1
+  install -D -m644 conf/* "$pkgdir/usr/share/ntp/" || return 1
+
+  # install launch scripts 
+  mkdir -p "$pkgdir/etc/rc.d" || return 1
+  install -D -m755 "$srcdir"/{ntpd,ntpdate} "$pkgdir/etc/rc.d/" || return 1
 
+  # install man pages
+  cd html
+  ../scripts/html2man || return 1
+  sed -i 's/^[\t\ ]*$//;/./,/^$/!d' man/man*/*.[58] || return 1
+  install -d "$pkgdir"/usr/share/man/man{5,8}
+  install -m644 man/man5/* "$pkgdir/usr/share/man/man5/" || return 1
+  install -m644 man/man8/* "$pkgdir/usr/share/man/man8/" || return 1
+  mv "$pkgdir/usr/share/man/man8/ntpd.8" "$pkgdir/usr/share/man/man8/ntp-ntpd.8" || return 1
+  cd ..
+
+  # install sample configs
+  install -D -m644 "$srcdir/ntp.conf" "$pkgdir/etc/ntp.conf" || return 1
+  install -D -m644 "$srcdir/ntp-client.conf" \
+  	"$pkgdir/etc/conf.d/ntp-client.conf" || return 1
+
+  # create /var/lib/ntp
+  mkdir -p "$pkgdir/var/lib/ntp" || return 1
+  touch "$pkgdir/var/lib/ntp/.placeholder" || return 1
+
+  install -Dm644 "$srcdir/$pkgname-$pkgver/COPYRIGHT" "$pkgdir/usr/share/licenses/$pkgname/COPYRIGHT"
+}
 md5sums=('cf73cd85f248232c62f8029e6eb05938'
-         '833c9d699765bd60825b5713670be460'
-         '25eb8d2176fe642b488e4b9fa03179ac'
-         'b1a1798b9cd1907d65a7fc794294d6ce'
+         '36c5711228cb0cf48966daa993e06f55'
+         '9dabdbc6b8cd020f2205515df7972c21'
+         '1b04e888717bb31479a6087632981723'
+         '5bd3924f5720b97837969ec4ec4d5e09'
+         'c7f50632b69bd4f32cf052d0b1848463'
+         '46118a8ec2c4f5bbfafd730af21b7c03'
          '140855352baeb89da0c6c1c475c18b57')
+sha1sums=('04b5e3c3755fe9e5bcec5bd5d29255cfef2102c4'
+          '4de6cd3fad1946146107f86d1f161eb835fbb2d3'
+          '3632f8a00838f48e484bca24de06db443cc14fff'
+          '7f8783e243e23c8853a9f9fb5b36f467aab8dc15'
+          '3625ed2aa71d9e0dd04634f32e65d83b76cfe780'
+          'c8e388f2577b4329da5e77f0455083db6dd97fa8'
+          'd9b09de9d718a864270e9330e20109e182dfbdd9'
+          '6dfc3b6996f591123ee8938fd0fe7c27eb5c7552')
diff --git a/abs/core-testing/ntp/fix-ipv6.patch b/abs/core-testing/ntp/fix-ipv6.patch
new file mode 100644
index 0000000..eecd766
--- /dev/null
+++ b/abs/core-testing/ntp/fix-ipv6.patch
@@ -0,0 +1,10 @@
+--- ntp-4.2.4p7-orig/configure.ac	2009-06-18 14:48:12.151346763 +0200
++++ ntp-4.2.4p7/configure.ac	2009-06-18 14:50:07.054692531 +0200
+@@ -4456,6 +4456,7 @@
+ 		[
+ 		    AC_LANG_PROGRAM(
+ 			[
++                            #define _GNU_SOURCE
+ 			    #include <sys/types.h>
+ 			    #include <sys/socket.h>
+ 			    #include <netinet/in.h>
diff --git a/abs/core-testing/ntp/ntp-4.2.4-html2man.patch b/abs/core-testing/ntp/ntp-4.2.4-html2man.patch
new file mode 100644
index 0000000..333d452
--- /dev/null
+++ b/abs/core-testing/ntp/ntp-4.2.4-html2man.patch
@@ -0,0 +1,183 @@
+--- ntp-4.2.4/scripts/html2man.in.html2man	2006-06-06 22:17:10.000000000 +0200
++++ ntp-4.2.4/scripts/html2man.in	2007-01-08 12:47:31.000000000 +0100
+@@ -23,10 +23,10 @@
+ 	     'ntpq' => ['ntpq', 8, 'ntpd(8), ntpdc(8)'],
+ 	     'ntpdate' => ['ntpdate', 8, 'ntpd(8)'],
+ 	     'ntpdc' => ['ntpdc', 8, 'ntpd(8)'],
+-	     'ntptime' => ['ntpdtime', 8, 'ntpd(8), ntpdate(8)'],
++	     'ntptime' => ['ntptime', 8, 'ntpd(8), ntpdate(8)'],
+ 	     'ntptrace' => ['ntptrace', 8, 'ntpd(8)'],
+ 	     'keygen' => ['ntp-keygen', 8, 'ntpd(8), ntp_auth(5)'],
+-	     'confopt' => ['ntp.conf', 5, 'ntpd(8)'],
++	     'confopt' => ['ntp.conf', 5, 'ntpd(8), ntp_auth(5), ntp_mon(5), ntp_acc(5), ntp_clock(5), ntp_misc(5)'],
+ 	     'authopt' => ['ntp_auth', 5, 'ntp.conf(5), ntpd(8)'],
+ 	     'monopt' => ['ntp_mon', 5, 'ntp.conf(5)'],
+ 	     'accopt' => ['ntp_acc', 5, 'ntp.conf(5)'],
+@@ -34,17 +34,8 @@
+ 	     'miscopt' => ['ntp_misc', 5, 'ntp.conf(5)']);
+ 
+ # Disclaimer to go in SEE ALSO section of the man page
+-$seealso_disclaimer = 'These man pages are automatically hacked from the main NTP ' .
+-    'documentation pages, which are maintained in HTML format.  These files are ' .
+-    'included in the NTP source distribution.  If you installed NTP from a binary ' .
+-    'package, or it came pre-installed on your system, chances are the documentation ' .
+-    'was also included in the usual place for your system.  The HTML files are more ' .
+-    'correct and complete than these man pages, which are provided for your reference ' .
+-    'only.';
+-
+-# Disclaimer to go right at the top
+-$top_disclaimer = 'This file was automatically generated from HTML source, and may be ' .
+-    'incorrect.  See the SEE ALSO section at the end of this file for more info';
++$seealso_disclaimer = "Primary source of documentation: /usr/share/doc/ntp-*\n\n" .
++    "This file was automatically generated from HTML source.\n";
+ 
+ mkdir $MANDIR, 0777;
+ mkdir "$MANDIR/man8", 0777;
+@@ -64,7 +55,8 @@
+     $fileinfo = $manfiles{$filename};
+ 
+     $p = HTML::TokeParser->new("$filename.html") || die "Can't open $filename.html: $!";
+-    open(MANOUT, ">$MANDIR/man$fileinfo->[1]/$fileinfo->[0].$fileinfo->[1]")
++    $fileout = "$MANDIR/man$fileinfo->[1]/$fileinfo->[0].$fileinfo->[1]";
++    open(MANOUT, ">$fileout")
+ 	|| die "Can't open: $!";
+ 
+     $p->get_tag("title");
+@@ -73,7 +65,6 @@
+ 
+     # Setup man header
+     print MANOUT ".TH " . $fileinfo->[0] . " " . $fileinfo->[1] .  "\n";
+-    print MANOUT ".UC 4\n";
+     print MANOUT ".SH NAME\n";
+     $pat = $fileinfo->[0];
+     if ($name =~ /$pat/) {
+@@ -81,10 +72,12 @@
+ 	# Add the manpage name, if not in the HTML title already
+ 	print MANOUT "$fileinfo->[0] - ";
+     }
+-    print MANOUT "$name\n\n";
+-
+-    print MANOUT "$top_disclaimer\n";
++    print MANOUT "$name\n.SH \\ \n\n";
+ 
++    @fontstack = ();
++    $deflevel = 0;
++    $pre = 0;
++    $ignore = 0;
+     # Now start scanning.  We basically print everything after translating some tags.
+     # $token->[0] has "T", "S", "E" for Text, Start, End
+     # $token->[1] has the tag name, or text (for "T" case)
+@@ -92,19 +85,37 @@
+     while (my $token = $p->get_token) {
+ 	if($token->[0] eq "T") {
+ 	    my $text = $token->[1];
+-	    if($tag) {
+-		$text =~ s/^[\n ]*//;
+-		$text =~ s/[\n ]*$/ /;
++	    if (!$pre) {
++		if($tag) {
++		    $text =~ s/^[\n\t ]*//;
++		}
++		$text =~ s/^[\n\t ][\n\t ]+$//;
++		$text =~ s/[\n\t ]+/ /g;
++		$text =~ s/&nbsp\;/ /g;
++		$text =~ s/&gt\;/>/g;
++		$text =~ s/&lt\;/</g;
++		$text =~ s/&quot\;/"/g;
++		$text =~ s/&amp\;/&/g;
++		$text =~ s/^\./\\[char46]/;
+ 	    }
+-	    $text =~ s/&nbsp\;/ /g;
+-	    $text =~ s/^\./\\./;
+ 	    print MANOUT "$text";
+ 	    $tag = 0;
+ 	}
+ 	if($token->[0] eq "S") {
+ 	    if($token->[1] eq "h4") {
+ 		my $text = uc($p->get_trimmed_text("/h4"));
+-		print MANOUT ".SH $text\n";
++		# ignore these two sections in ntpd.html
++		if ($filename eq "ntpd" &&
++		    ($text eq "FILES" || $text eq "CONFIGURATION OPTIONS")) {
++			$ignore = 1;
++			close(MANOUT);
++			open(MANOUT, ">/dev/null");
++		} elsif ($ignore) {
++		    $ignore = 0;
++		    close(MANOUT);
++		    open(MANOUT, ">>$fileout");
++		}
++		print MANOUT "\n\n.SH $text\n";
+ 	    }
+ 	    if($token->[1] eq "tt") {
+ 		push @fontstack, "tt";
+@@ -118,22 +129,30 @@
+ 		my $text = $p->get_trimmed_text("/address");
+ 		print MANOUT "\n.SH AUTHOR\n$text\n";
+ 	    }
+-	    if($token->[1] eq "dt") {
+-		$tmp = $deflevel-4;
+-		print MANOUT "\n.RS $tmp\n";
++	    if($token->[1] eq "dt" || $token->[1] eq "br" && $deflevel > 0) {
++		print MANOUT "\n.TP 8\n";
+ 		$tag = 1;
+ 	    }
+ 	    if($token->[1] eq "dd") {
+-		print MANOUT "\n.RS $deflevel\n";
++		print MANOUT "\n";
+ 		$tag = 1;
+ 	    }
+ 	    if($token->[1] eq "dl") {
+-		$deflevel+=4;
++		$deflevel+=1;
++		if ($deflevel > 0) {
++		    print MANOUT "\n.RS ", $deflevel > 1 ? 8 : 0;
++		}
++	    }
++	    if($token->[1] eq "p") {
++		print MANOUT "\n";
++	    }
++	    if($token->[1] eq "pre") {
++		print MANOUT "\n.nf";
++		$pre = 1;
+ 	    }
+ 	}
+ 	elsif($token->[0] eq "E") {
+-	    if($token->[1] eq "dd") {
+-		print MANOUT "\n.RE\n";
++	    if($token->[1] eq "h4") {
+ 		$tag = 1;
+ 	    }
+ 	    if($token->[1] eq "tt") {
+@@ -157,15 +176,27 @@
+ 		print MANOUT "$fontswitch";
+ 	    }
+ 	    if($token->[1] eq "dl") {
+-		$deflevel-=4;
++		if ($deflevel > 0) {
++		    print MANOUT "\n.RE";
++		}
++		print MANOUT "\n";
++		$deflevel-=1;
+ 	    }
+-	    if($token->[1] eq "dt") {
+-		print MANOUT "\n.RE";
++	    if($token->[1] eq "p") {
++		print MANOUT "\n";
+ 		$tag = 1;
+ 	    }
++	    if($token->[1] eq "pre") {
++		print MANOUT "\n.fi";
++		$pre = 0;
++	    }
+ 	}
+     }
+-    print MANOUT ".SH SEE ALSO\n\n";
++    if ($ignore) {
++	close(MANOUT);
++	open(MANOUT, ">>$fileout");
++    }
++    print MANOUT "\n.SH SEE ALSO\n\n";
+     print MANOUT "$fileinfo->[2]\n\n";
+     print MANOUT "$seealso_disclaimer\n";
+     close(MANOUT);
diff --git a/abs/core-testing/ntp/ntp-4.2.4_p7-nano.patch b/abs/core-testing/ntp/ntp-4.2.4_p7-nano.patch
new file mode 100644
index 0000000..b31ea0a
--- /dev/null
+++ b/abs/core-testing/ntp/ntp-4.2.4_p7-nano.patch
@@ -0,0 +1,20 @@
+http://bugs.gentoo.org/270483
+
+ripped from fedora
+
+--- ntp-4.2.4p7/include/ntp_syscall.h
++++ ntp-4.2.4p7/include/ntp_syscall.h
+@@ -14,5 +14,13 @@
+ # include <sys/timex.h>
+ #endif
+ 
++#if defined(ADJ_NANO) && !defined(MOD_NANO)
++#define MOD_NANO ADJ_NANO
++#endif
++
++#if defined(ADJ_TAI) && !defined(MOD_TAI)
++#define MOD_TAI ADJ_TAI
++#endif
++
+ #ifndef NTP_SYSCALLS_LIBC
+ #ifdef NTP_SYSCALLS_STD
diff --git a/abs/core-testing/ntp/ntp-client.conf b/abs/core-testing/ntp/ntp-client.conf
index ace4daf..a0463b7 100755
--- a/abs/core-testing/ntp/ntp-client.conf
+++ b/abs/core-testing/ntp/ntp-client.conf
@@ -1,7 +1,11 @@
 # change this to a server closer to your location
 NTP_CLIENT_SERVER="pool.ntp.org"
+
 # client options
 NTP_CLIENT_OPTION="-b -u"
 
 # timeout for the ntp-client
 NTPCLIENT_TIMEOUT=10
+
+# arguments passed to ntpd when started
+NTPD_ARGS="-g"
diff --git a/abs/core-testing/ntp/ntp.conf b/abs/core-testing/ntp/ntp.conf
index 9411643..93fc919 100755
--- a/abs/core-testing/ntp/ntp.conf
+++ b/abs/core-testing/ntp/ntp.conf
@@ -1,57 +1,47 @@
-# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
+# NOTES:
+#  - you should only have to update the server line below
+#  - if you start getting lines like 'restrict' and 'fudge'
+#    and you didnt add them, AND you run dhcpcd on your
+#    network interfaces, be sure to add '-Y -N' to the
+#    dhcpcd_ethX variables in /etc/conf.d/net
 
-#driftfile /var/lib/ntp/ntp.drift
-driftfile /etc/ntp.drift
+# Name of the servers ntpd should sync with
+# Please respect the access policy as stated by the responsible person.
+#server		ntp.example.tld		iburst
 
+server pool.ntp.org
 
-# Enable this if you want statistics to be logged.
-#statsdir /var/log/ntpstats/
-
-statistics loopstats peerstats clockstats
-filegen loopstats file loopstats type day enable
-filegen peerstats file peerstats type day enable
-filegen clockstats file clockstats type day enable
-
+##
+# A list of available servers can be found here:
+# http://www.pool.ntp.org/
+# http://www.pool.ntp.org/#use
+# A good way to get servers for your machine is:
+# netselect -s 3 pool.ntp.org
+##
 
-# You do need to talk to an NTP server or two (or three).
-#server ntp.your-provider.example
+# you should not need to modify the following paths
+driftfile	/var/lib/ntp/ntp.drift
 
-# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
-# pick a different set every time it starts up.  Please consider joining the
-# pool: <http://www.pool.ntp.org/join.html>
-server pool.ntp.org
-server 0.us.pool.ntp.org iburst
-server 1.us.pool.ntp.org iburst
-server 2.us.pool.ntp.org iburst
-server 3.us.pool.ntp.org iburst
+#server ntplocal.example.com prefer 
+#server timeserver.example.org 
 
+# Warning: Using default NTP settings will leave your NTP
+# server accessible to all hosts on the Internet.
 
-# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
-# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
-# might also be helpful.
-#
-# Note that "restrict" applies to both servers and clients, so a configuration
-# that might be intended to block requests from certain clients could also end
-# up blocking replies from your own upstream servers.
+# If you want to deny all machines (including your own)
+# from accessing the NTP server, uncomment:
+#restrict default ignore
 
-# By default, exchange time with everybody, but don't allow configuration.
-restrict -4 default kod notrap nomodify nopeer noquery
-restrict -6 default kod notrap nomodify nopeer noquery
 
-# Local users may interrogate the ntp server more closely.
+# To deny other machines from changing the
+# configuration but allow localhost:
+restrict default nomodify nopeer
 restrict 127.0.0.1
-restrict ::1
-
-# Clients from this (example!) subnet have unlimited access, but only if
-# cryptographically authenticated.
-#restrict 192.168.123.0 mask 255.255.255.0 notrust
 
 
-# If you want to provide time to your local subnet, change the next line.
-# (Again, the address is an example only.)
-#broadcast 192.168.123.255
-
-# If you want to listen to time broadcasts on your local subnet, de-comment the
-# next lines.  Please do this only if you trust everybody on the network!
-#disable auth
-#broadcastclient
\ No newline at end of file
+# To allow machines within your network to synchronize
+# their clocks with your server, but ensure they are
+# not allowed to configure the server or used as peers
+# to synchronize against, uncomment this line.
+#
+#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap
diff --git a/abs/core-testing/ntp/ntpd b/abs/core-testing/ntp/ntpd
index bb39123..56f6248 100755
--- a/abs/core-testing/ntp/ntpd
+++ b/abs/core-testing/ntp/ntpd
@@ -2,13 +2,14 @@
 
 . /etc/rc.conf
 . /etc/rc.d/functions
+. /etc/conf.d/ntp-client.conf
 
 PID=`pidof -o %PPID /usr/bin/ntpd`
 case "$1" in
   start)
     stat_busy "Starting NTP Daemon"
     if [ -z "$PID" ]; then 
-       /usr/bin/ntpd -g &
+       /usr/bin/ntpd $NTPD_ARGS &
     fi
     if [ ! -z "$PID" -o $? -gt 0 ]; then
       stat_fail
-- 
cgit v0.12

