# Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ DESCRIPTION="The InterNet News daemon, a fully featured NNTP server" HOMEPAGE="http://www.isc.org/products/INN" SRC_URI="ftp://ftp.isc.org/isc/inn/${P}.tar.gz" # mirror://gentoo/${P}.tar.gz" RESTRICT="nomirror" LICENSE="as-is BSD" SLOT="0" KEYWORDS="x86" IUSE="ssl tcltk perl python ipv6 berkdb bzip2 innlargefiles inntaggedhash innkeywords" LOCALUSEDESC="bzip2 The log files schould be compressed with bzip2 instead of gzip innlargefiles This must be activated to let INN operate on files larger than 2 GB inntaggedhash Use tagged hash table for history innkeywords Automatic keyword generation support" LOCALUSEDEFAULTS="+bzip2 -innlargefiles -inntaggedhash -innkeywords" # Anyone forgotten virtual/shell? DEPEND="virtual/glibc sys-apps/coreutils >=sys-apps/sed-4 || ( app-shells/ash app-shells/bash app-shells/csh app-shells/ccsh app-shells/tcsh app-shells/zsh app-shells/sash app-shells/psh app-shells/posh app-shells/pdksh app-shells/ksh app-shells/dash app-shells/dsh app-shells/esh ) kerberos? ( virtual/krb5 ) sasl? ( >=dev-libs/cyrus-sasl-2 ) tcltk? ( dev-lang/tcl ) ssl? ( dev-libs/openssl ) perl? ( dev-lang/perl ) python? ( dev-lang/python ) berkdb? ( sys-libs/db ) bzip2? ( app-arch/bzip2 ) !bzip2? ( app-arch/gzip )" RDEPEND="${DEPEND} app-crypt/gnupg virtual/mta" src_unpack() { unpack ${A} cd ${S} sed -i \ -e 's/\$(P) //' site/Makefile storage/Makefile \ || die "sed failed" } src_compile() { ./configure \ --prefix=/usr/lib/news \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --with-etc-dir=/etc/news \ --with-db-dir=/var/spool/news/db \ --with-spool-dir=/var/spool/news \ --with-log-dir=/var/log/news \ --with-run-dir=/var/run/news \ --with-tmp-dir=/var/spool/news/tmp \ --host=${CHOST} \ --enable-libtool \ --enable-setgid-inews \ --enable-uucp-rnews \ `if use kerberos ; then echo '--with-kerberos=/usr' fi` \ `use_with tcltk tcl` \ `use_with ssl openssl` \ `use_with perl perl` \ `use_with python python` \ `use_with sasl sasl` \ `use_enable ipv6 ipv6` \ `use_enable innlargefiles largefiles` \ `if use bzip2 ; then echo '--with-log-compress=bzip2' else echo '--with-log-compress=gzip' fi` \ `use_enable inntaggedhash tagged-hash` \ `use_enable innkeywords keywords` \ || die "configure died" if use berkdb ; then einfo 'BerkeleyDB support will not get compiled into INN yet.' echo '' fi emake -j1 || die "emake failed" } src_install() { make prefix=${D}/usr/lib/news \ PATHETC=${D}/etc/news \ PATHMAN=${D}/usr/share/man \ PATHLIB=${D}/usr/lib/news/lib \ PATHCONTROL=${D}/usr/lib/news/bin/control \ PATHFILTER=${D}/usr/lib/news/bin/filter \ PATHRUN=${D}/var/run/news \ PATHLOG=${D}/var/log/news \ PATHDB=${D}/var/spool/news/db \ PATHSPOOL=${D}/var/spool/news \ PATHTMP=${D}/var/spool/news/tmp \ PATHDOC=${D}/usr/doc/${P} \ MAN1=${D}/usr/share/man/man1 \ MAN3=${D}/usr/share/man/man3 \ MAN5=${D}/usr/share/man/man5 \ MAN8=${D}/usr/share/man/man8 \ install || die "make install failed" keepdir \ /var/spool/news/tmp/ \ /var/spool/news/outgoing/ \ /var/spool/news/overview/ \ /var/spool/news/innfeed/ \ /var/spool/news/articles/ \ /var/spool/news/incoming/bad/ \ /var/spool/news/archive/ \ /var/run/news/ \ /var/log/news/ # Change file permissions for cfg_file in control.ctl expire.ctl nntpsend.ctl readers.conf ; do if [ -f ${D}/etc/news/${cfg_file} ] then chmod 640 ${D}/etc/news/${cfg_file} fi done chown root:root ${D}/usr/lib/news/lib/*.{a,la,so*} chown -R root:root ${D}/usr/share/doc chown -R root:root ${D}/usr/share/man # Well, one can overwrite the old db and rebuild it afterwards, but it is better to save the time... dodir /usr/doc/${D}/dbexamples for db_file in active active.times distributions history newsgroups ; do chown news:news if [ -e ${D}/var/spool/news/db/${db_file} ] then if [ -e ${ROOT}/var/spool/news/db/${db_file} ] then insinto /usr/doc/${P}/dbexamples doins ${D}/var/spool/news/db/${db_file} rm -f ${D}/var/spool/news/db/${db_file} fi fi done # So other programs can build against INN. (eg. Newsstar or Suck) insinto /usr/lib/news/include doins include/*.h exeinto /etc/init.d newexe ${FILESDIR}/innd innd exeinto /usr/lib/news/bin newexe ${FILESDIR}/rebuild-database rebuild-database cd ${WORKDIR} doman send-uucp.pl.8.gz insinto /etc/news doins send-uucp.cf exeinto /usr/lib/news/bin newexe send-uucp.pl send-uucp.pl } pkg_postinst() { usermod -s /bin/sh news chown -R news:news ${ROOT}/var/spool/news chown -R news:news ${ROOT}/var/log/news/ echo '' einfo 'Do not forget to update your cron entries, and also run' einfo 'makedbz if you need to. If this is a first-time installation' einfo 'a minimal active file has been installed. You will need to' einfo 'touch history and run "makedbz -i" to initialize the history' einfo 'database. See /usr/doc/inn-2.4.1/ and especially INSTALL for' einfo 'more information.' echo '' einfo 'For a quick configuration check use "ebuild inn-2.4.1 config".' echo '' if [ -n "`use ssl`" ] then einfo 'You may want to start nnrpd manually for native ssl support.' einfo 'If you choose to do so, automating this with a bootscript might' einfo 'also be a good choice.' einfo 'Have a look at nnrpd(8) for valid parameters.' echo '' fi } pkg_postrm() { echo '' einfo 'If you want your newsspool or altered configuration files' einfo 'to be removed, please do so now manually.' echo '' } pkg_config() { NEWSSPOOL_DIR=/var/spool/news NEWS_SHELL=`sed -e '/^news:/ ! d' /etc/passwd | sed -e '/^news:/ s/[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*/\1/'` NEWS_ERRFLAG=0 if [ "${NEWS_SHELL}" == "/bin/false" -o "${NEWS_SHELL}" == "/dev/null" ] then if [ ${UID} -eq 0 ] then einfo 'Changing shell to /bin/sh for user news...' usermod -s /bin/sh news else NEWS_ERRFLAG=1 eerror '' eerror 'Could not change shell for user news.' eerror 'Please run "usermod -s /bin/bash news" as root.' fi else einfo "Shell for user news unchanged ('${NEWS_SHELL}')." if [ "${NEWS_SHELL}" != "/bin/sh" -a "${NEWS_SHELL}" != "/bin/bash" ] then ewarn "You might want to change it to '/bin/bash', though." fi fi echo '' if [ -n "`use ssl`" ] then if [ ! -f /usr/lib/news/lib/cert.pem ] then einfo 'Generating x509 certificate...' openssl req -new -x509 -nodes \ -out /usr/lib/news/lib/cert.pem \ -keyout /usr/lib/news/lib/cert.pem chown news:news /usr/lib/news/lib/cert.pem chmod 600 /usr/lib/news/lib/cert.pem else einfo 'Leaving existing x509 certificate untouched...' fi echo '' fi if [ ! -e $NEWSSPOOL_DIR/db/history ] then if [ ! -e $NEWSSPOOL_DIR/db/history.dir \ -a ! -e $NEWSSPOOL_DIR/db/history.hash \ -a ! -e $NEWSSPOOL_DIR/db/history.index ] then einfo 'Building history database...' touch $NEWSSPOOL_DIR/db/history chown news.news $NEWSSPOOL_DIR/db/history chmod 644 $NEWSSPOOL_DIR/db/history su - news -c "/usr/lib/news/bin/makedbz -i" mv $NEWSSPOOL_DIR/db/history.n.dir $NEWSSPOOL_DIR/db/history.dir mv $NEWSSPOOL_DIR/db/history.n.hash $NEWSSPOOL_DIR/db/history.hash mv $NEWSSPOOL_DIR/db/history.n.index $NEWSSPOOL_DIR/db/history.index su - news -c "/usr/lib/news/bin/makehistory" else eerror '' eerror 'Your installation seems to be screwed up. Will rebuild database.' /usr/lib/news/bin/rebuild-database fi else einfo '${NEWSSPOOL_DIR}/db/history found. Leaving history database as it is.' einfo 'In case your database is broken and we did not detect it you should run ' einfo '/usr/lib/news/bin/rebuild-database.' fi echo '' # Replacement does not need awk and/or grep # Now automatically repairs wrong inn.conf's INNCFG_INODES=`sed -e '/innwatchspoolnodes/ ! d' /etc/news/inn.conf | sed -e 's/[^ ]*[ ]*\([^ ]*\)/\1/'` INNSPOOL_INODES=`df -Pi ${NEWSSPOOL_DIR} | sed -e 's/[^ ]*[ ]*\([^ ]*\).*/\1/' | sed -e '1 d'` if [ ${INNCFG_INODES} -gt ${INNSPOOL_INODES} ] then ewarn 'Setting innwatchspoolinodes to zero, because the filesystem behind' ewarn "$NEWSSPOOL_DIR works without inodes." ewarn '' cp /etc/news/inn.conf /etc/news/inn.conf.OLD einfo 'A copy of your old inn.conf has been saved to /etc/news/inn.conf.OLD.' sed -e '/innwatchspoolnodes/ s/\([^ ]*\)\([ ]*\).*/\1\20/' /etc/news/inn.conf > /etc/news/in_.conf mv /etc/news/in_.conf /etc/news/inn.conf chown news:news /etc/news/inn.conf chmod 640 /etc/news/inn.conf echo '' fi INNCHECK_LINES=`su - news -c "/usr/lib/news/bin/inncheck|wc -l"` if [ ${INNCHECK_LINES} -gt 0 ] then NEWS_ERRFLAG=1 ewarn 'inncheck most certainly found an error.' ewarn 'Please check its output:' eerror "`su - news -c \"/usr/lib/news/bin/inncheck\"`" echo '' fi if [ ${NEWS_ERRFLAG} -gt 0 ] then eerror 'There were one or more errors/warnings checking your configuration.' eerror "Please read inn's documentation and fix them accordingly." echo '' else einfo 'Inn configuration tests passed successfully.' einfo '' ewarn 'Please ensure you configured inn properly.' echo '' fi }