IGNOREPATH=/home:/var:/dev:/boot:/root:/tmp:/usr/local:/bin:/sbin:/mnt:/usr/src
STRIPLIB=y
STRIPBIN=y

VERSION=4.2.0
PROGNAME="ntp $VERSION"
DESC="\
ntp (Network Time Protocol daemon)                                     \n\
                                                                       \n\
The Network Time Protocol (NTP) is used to synchronize the time of a   \n\
computer client or server to another server or reference time source,  \n\
such as a radio or satellite receiver or modem. It provides client     \n\
accuracies typically within a millisecond on LANs and up to a few tens \n\
of milliseconds on WANs relative to a primary server synchronized to   \n\
Coordinated Universal Time (UTC) via a Global Positioning Service      \n\
(GPS) receiver, for example."

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=http://www.ntp.org/downloads.html
PKGNAME=ntp-$VERSION-s390-$BUILD
TAG=REC

compile() {
   tar -yxvf $CWD/ntp-$VERSION.tar.bz2
   cd ntp-$VERSION/
   chown -R root.root .
   find . -perm 664 -exec chmod 644 {} \;
   find . -perm 777 -exec chmod 755 {} \;
   find . -perm 2777 -exec chmod 755 {} \;
   find . -perm 775 -exec chmod 755 {} \;
   find . -perm 2755 -exec chmod 755 {} \;
   find . -perm 774 -exec chmod 644 {} \;
   CFLAGS=-O2 \
   ./configure --prefix=/usr \
               --localstatedir=/var \
               --sysconfdir=/etc \
               --bindir=/usr/sbin \
               --program-prefix= \
               --program-suffix= \
               --build=s390-slackware-linux \
               --host=s390-slackware-linux \
               --target=s390-slackware-linux
   make
}

install() {
   make install DESTDIR=/package-ntp

   mkdir -p /package-ntp/usr/doc/ntp-$VERSION
   cp -a COPYRIGHT ChangeLog INSTALL NEWS README* TODO WHERE-TO-START \
         *.y2kfixes clockstuff conf html scripts /package-ntp/usr/doc/ntp-$VERSION
   mkdir /package-ntp/usr/doc/ntp-$VERSION/util
   cp -a util/README /package-ntp/usr/doc/ntp-$VERSION/util
   mkdir /package-ntp/usr/doc/ntp-$VERSION/ntpdate
   cp -a ntpdate/README /package-ntp/usr/doc/ntp-$VERSION/ntpdate
   mkdir /package-ntp/usr/doc/ntp-$VERSION/ntptrace
# The ntptrace subdirectory doesn't really exist in the source package
#  cp -a ntptrace/README /package-ntp/usr/doc/ntp-$VERSION/ntptrace

   mkdir -p /package-ntp/etc/ntp
   cat $CWD/ntp.conf > /package-ntp/etc/ntp.conf.new
   cat $CWD/ntp.keys > /package-ntp/etc/ntp/ntp.keys.new
   touch /package-ntp/etc/ntp/step-tickers
}

attributes() {
   chown -R root.bin $PKG/package-ntp/usr/sbin

   chmod 600 $PKG/package-ntp/etc/ntp/ntp.keys.new
   ( cd $PKG/package-ntp/usr/doc/ntp-$VERSION/scripts
     chmod 755 calc_tickadj checktime freq_adj hpadjtime.sh mkver \
               ntp-close ntp-groper ntp-restart ntp-status ntp-wait \
               ntpsweep ntptrace* ntpver plot_summary summary
     cd stats/
     chmod 755 *.awk *.S *.sh loop_summary summary.sh
   )
}

special() {
   cd $PKG
   mv package-ntp/* ./
   rmdir package-ntp/

   cd $CTL
   cat $CWD/slack-desc > slack-desc

   sed -e s'%package-ntp/%%g' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new

   zcat $CWD/doinst.sh.gz >> doinst.sh
}
