IGNOREPATH=/etc:/tmp:/proc:/dev:/root:/var:/usr/src
STRIPLIB=y
STRIPBIN=y

VERSION=2.4.1
PROGNAME="INN $VERSION"
DESC="\
inn (InterNetNews news server)                                         \n\
                                                                       \n\
Rich Salz's InterNetNews news transport system.  The core part of the  \n\
package is a single long-running daemon that handles all incoming NNTP \n\
connections.  It files the articles and arranges for them to be        \n\
forwarded to downstream sites."

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=http://www.isc.org/products/INN
PKGNAME=inn-$VERSION-s390-$BUILD
TAG=OPT

compile() {
   ### download the latest FAQ
   wget -m -A html http://blank.org/innfaq/

   ### build inn
   tar -yxvf $CWD/inn-$VERSION.tar.bz2
   cd inn-$VERSION/

   # This is mostly obsolete, and nobody else includes it anymore, but as long
   # as the INN people leave it in the source, I'll keep fixing it...
   zcat $CWD/ckpasswd.diff.gz | patch -p1 --verbose --backup --suffix=.orig
#  cat $CWD/makefile.diff | patch -p1 --verbose --backup --suffix=.orig

   LDFLAGS="-s" CFLAGS="-O2 -pipe" BERKELEY_DB_LIB="-ldb" \
   ./configure --enable-tagged-hash \
               --with-perl \
               --disable-shared \
               --with-sendmail=/usr/sbin/sendmail \
               --prefix=/usr/lib/news \
               --mandir=/usr/man \
               --with-news-user=news \
               --with-news-group=news \
               --with-news-master=news \
               --with-db-dir=/var/lib/news \
               --with-etc-dir=/etc/news \
               --with-log-dir=/var/log/news \
               --with-run-dir=/var/lib/news/run \
               --with-spool-dir=/var/spool/news \
               --with-tmp-path=/var/lib/news/tmp \
               --with-berkeleydb \
               s390-slackware-linux
   make
}

install() {
   # There is something _really_ strange about the inn package, in that
   # the "make install" command seems to invoke an "install" command itself.
   # That sets up a nice infinite loop with this routine, so the first thing
   # we are going to do is do an unset for this install routine.
   unset install

   make install DESTDIR=/package-inn

   # Add some default files:
   mkdir -p /package-inn/etc/rc.d
   ( cd /package-inn/etc/rc.d
     rm -rf rc.news ; ln -sf /usr/lib/news/bin/rc.news . 
   )
   mkdir -p /package-inn/usr/bin
   ( cd /package-inn/usr/bin
     rm -rf inews ; ln -sf /usr/lib/news/bin/inews .
   )

   # Still listed in include/paths.h:
   touch /package-inn/var/lib/news/subscriptions

   install -m 644 -o news -g news $CWD/distributions \
           /package-inn/var/lib/news/distributions

   rm -f /package-inn/var/lib/news/history
   touch /package-inn/var/lib/news/history

   touch /package-inn/var/lib/news/.news.daily

   install -m 644 -o news -g news $CWD/history.dir \
           /package-inn/var/lib/news/history.dir

   install -m 644 -o news -g news $CWD/history.pag \
           /package-inn/var/lib/news/history.pag

   ( cd /package-inn/var/log/news/
     touch news.notice news.crit news.err
   )

   ### install documentation
   mkdir -p /package-inn/usr/doc/inn-$VERSION
   cp -a CONTRIBUTORS HACKING INSTALL LICENSE MANIFEST NEWS README* \
       /package-inn/usr/doc/inn-$VERSION
   cp -a $TMP/blank.org/innfaq /package-inn/usr/doc/inn-$VERSION

   ( cd /package-inn/usr/man
     for dir in 1 3 5 8; do
       ( cd man$dir
         rm -f *.gz
         gzip -9 *.$dir
       )
     done
   )

   mkdir -p /package-inn/var/lib/news/tmp/
}

attributes() {
   chown -R root.bin $PKG/package-inn/usr/bin/
   chown -R news.news $PKG/package-inn/etc/news \
                      $PKG/package-inn/usr/lib/news \
                      $PKG/package-inn/var/lib/news \
                      $PKG/package-inn/var/log/news \
                      $PKG/package-inn/var/spool/news

   chown root.news $PKG/package-inn/usr/lib/news/bin/inndstart \
                   $PKG/package-inn/usr/lib/news/bin/startinnfeed
   chown uucp.news $PKG/package-inn/usr/lib/news/bin/rnews
   chmod 4550 $PKG/package-inn/usr/lib/news/bin/inndstart \
              $PKG/package-inn/usr/lib/news/bin/startinnfeed \
              $PKG/package-inn/usr/lib/news/bin/rnews
   chmod 750 $PKG/package-inn/var/lib/news/run
   chmod 664 $PKG/package-inn/var/log/news/news.*
   chmod 664 $PKG/package-inn/var/lib/news/active* \
             $PKG/package-inn/var/lib/news/newsgroups
}

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

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

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

