inn-2.5.3-r3.ebuild 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. PYTHON_COMPAT=( python2_7 )
  5. inherit autotools eutils multilib python-single-r1 ssl-cert toolchain-funcs
  6. DESCRIPTION="The Internet News daemon, fully featured NNTP server"
  7. HOMEPAGE="https://www.isc.org/software/inn"
  8. SRC_URI="ftp://ftp.isc.org/isc/inn/${P}.tar.gz"
  9. # GPL-2 only for init script
  10. LICENSE="ISC GPL-2+ public-domain BSD-4 BSD-2 RSA BSD MIT GPL-2"
  11. SLOT="0"
  12. KEYWORDS="~amd64 ~ppc ~x86"
  13. IUSE="berkdb innkeywords inntaggedhash ipv6 kerberos perl python sasl ssl"
  14. REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
  15. DEPEND="
  16. virtual/mta
  17. dev-perl/MIME-tools
  18. sys-libs/pam
  19. sys-libs/zlib
  20. kerberos? ( virtual/krb5 )
  21. sasl? ( >=dev-libs/cyrus-sasl-2 )
  22. ssl? ( dev-libs/openssl )
  23. python? ( ${PYTHON_DEPS} )
  24. berkdb? ( sys-libs/db )
  25. "
  26. RDEPEND="${DEPEND}"
  27. pkg_setup() {
  28. use python && python-single-r1_pkg_setup
  29. }
  30. src_prepare() {
  31. epatch "${FILESDIR}"/${P}-ar.patch
  32. epatch "${FILESDIR}"/${P}-tests.patch
  33. sed -e 's: -B .OLD::' -i Makefile.global.in || die
  34. # Do not treat LDFLAGS as if it contained libraries to link to
  35. sed -e 's:LDFLAGS::g' -i m4/python.m4 || die
  36. # We do not have the biff service, but we do have comsat
  37. sed -e 's:"biff":"comsat":g' -i tests/lib/getnameinfo-t.c || die
  38. eautoreconf
  39. }
  40. src_configure() {
  41. tc-export AR
  42. econf \
  43. --prefix=/usr/$(get_libdir)/news \
  44. --sysconfdir=/etc/news \
  45. --mandir=/usr/share/man \
  46. --infodir=/usr/share/info \
  47. --with-control-dir=/usr/$(get_libdir)/news/bin/control \
  48. --with-filter-dir=/usr/$(get_libdir)/news/bin/filter \
  49. --with-db-dir=/var/spool/news/db \
  50. --with-doc-dir=/usr/share/doc/${PF} \
  51. --with-spool-dir=/var/spool/news \
  52. --with-log-dir=/var/log/news \
  53. --with-run-dir=/run/news \
  54. --with-tmp-dir=/var/spool/news/tmp \
  55. --disable-libtool \
  56. --with-gnu-ld \
  57. --enable-setgid-inews \
  58. --enable-uucp-rnews \
  59. $(use_with perl) \
  60. $(use_with python) \
  61. $(use_with kerberos kerberos /usr) \
  62. $(use_with sasl) \
  63. $(use_with ssl openssl) \
  64. $(use_with berkdb berkeleydb /usr) \
  65. $(use_enable ipv6) \
  66. $(use_enable !inntaggedhash largefiles) \
  67. $(use_enable inntaggedhash tagged-hash) \
  68. $(use_enable innkeywords keywords)
  69. }
  70. src_install() {
  71. emake DESTDIR="${D}/" P="" SPECIAL="" install
  72. chown -R root:0 \
  73. "${D}"/usr/$(get_libdir)/news/$(get_libdir) \
  74. "${D}"/usr/$(get_libdir)/news/include \
  75. "${D}"/usr/share/doc \
  76. "${D}"/usr/share/man \
  77. || die
  78. chmod 644 "${D}"/etc/news/* || die
  79. chmod 640 \
  80. "${D}"/etc/news/control.ctl \
  81. "${D}"/etc/news/expire.ctl \
  82. "${D}"/etc/news/incoming.conf \
  83. "${D}"/etc/news/innfeed.conf \
  84. "${D}"/etc/news/nntpsend.ctl \
  85. "${D}"/etc/news/passwd.nntp \
  86. "${D}"/etc/news/readers.conf \
  87. || die
  88. # Prevent old db/* files from being overwritten
  89. insinto /usr/share/inn/dbexamples
  90. newins site/active.minimal active
  91. newins site/newsgroups.minimal newsgroups
  92. keepdir \
  93. /var/log/news \
  94. /var/spool/news/archive \
  95. /var/spool/news/articles \
  96. /var/spool/news/db \
  97. /var/spool/news/incoming \
  98. /var/spool/news/incoming/bad \
  99. /var/spool/news/innfeed \
  100. /var/spool/news/outgoing \
  101. /var/spool/news/overview \
  102. /var/spool/news/tmp
  103. fowners news:news /var/log/news
  104. dodoc ChangeLog MANIFEST README* doc/checklist
  105. use ipv6 && dodoc doc/IPv6-info
  106. # So other programs can build against INN
  107. insinto /usr/$(get_libdir)/news/include
  108. doins include/*.h
  109. newinitd "${FILESDIR}"/innd-r1 innd
  110. }
  111. pkg_postinst() {
  112. for db_file in active newsgroups
  113. do
  114. [[ -f ${ROOT}var/spool/news/db/${db_file} ]] && continue
  115. if [[ -f ${ROOT}usr/share/inn/dbexamples/${db_file} ]]
  116. then
  117. cp "${ROOT}"usr/share/inn/dbexamples/${db_file} \
  118. "${ROOT}"var/spool/news/db/${db_file}
  119. else
  120. touch "${ROOT}"var/spool/news/db/${db_file}
  121. fi
  122. chown news:news "${ROOT}"var/spool/news/db/${db_file}
  123. chmod 664 "${ROOT}"var/spool/news/db/${db_file}
  124. done
  125. elog "It is recommended to run emerge --config ${CATEGORY}/${PN}"
  126. elog "now to finish setting up this package."
  127. elog
  128. elog "Do not forget to update your cron entries, and also run"
  129. elog "makedbz if you need to. If this is a first-time installation"
  130. elog "a minimal active file has been installed. You will need to"
  131. elog "touch history and run 'makedbz -i' to initialize the history"
  132. elog "database. See INSTALL for more information."
  133. elog
  134. elog "You need to assign a real shell to the news user, or else"
  135. elog "starting inn will fail. You can use 'usermod -s /bin/bash news'"
  136. elog "for this."
  137. if use ssl
  138. then
  139. install_cert /etc/news/cert/cert
  140. chown news:news \
  141. "${ROOT}"etc/news/cert/cert.{crt,csr,key,pem}
  142. elog
  143. elog "You may want to start nnrpd manually for native ssl support."
  144. elog "If you choose to do so, automating this with a bootscript might"
  145. elog "also be a good choice."
  146. elog "Have a look at man nnrpd for valid parameters."
  147. elog
  148. elog "The certificate location in /etc/news/sasl.conf has been changed"
  149. elog "to /etc/news/cert!"
  150. fi
  151. }
  152. pkg_postrm() {
  153. elog
  154. elog "If you want your newsspool or altered configuration files"
  155. elog "to be removed, please do so now manually."
  156. elog
  157. }
  158. pkg_config() {
  159. NEWSSPOOL_DIR="${ROOT}var/spool/news"
  160. NEWS_SHELL="$( awk -F':' '/^news:/ {print $7;}' ${ROOT}etc/passwd )"
  161. NEWS_ERRFLAG="0"
  162. if [[ ${NEWS_SHELL} == /bin/false || ${NEWS_SHELL} == /dev/null ]]; then
  163. einfo "Changing shell to /bin/bash for user news..."
  164. usermod -s /bin/bash news
  165. else
  166. einfo "Shell for user news unchanged ('${NEWS_SHELL}')."
  167. if [[ ${NEWS_SHELL} != /bin/sh && ${NEWS_SHELL} != /bin/bash ]]; then
  168. ewarn "You might want to change it to '/bin/bash', though."
  169. fi
  170. fi
  171. if [[ ! -e ${NEWSSPOOL_DIR}/db/history ]]; then
  172. if [[ ! -f ${NEWSSPOOL_DIR}/db/history.dir \
  173. && ! -f ${NEWSSPOOL_DIR}/db/history.pag \
  174. && ! -f ${NEWSSPOOL_DIR}/db/history.hash \
  175. && ! -f ${NEWSSPOOL_DIR}/db/history.index ]]
  176. then
  177. einfo "Building history database ..."
  178. touch "${NEWSSPOOL_DIR}"/db/history
  179. chown news:news "${NEWSSPOOL_DIR}"/db/history
  180. chmod 644 "${NEWSSPOOL_DIR}"/db/history
  181. einfo "Running makedbz -i ..."
  182. su - news -c "/usr/$(get_libdir)/news/bin/makedbz -i"
  183. einfo "Moving files into place ..."
  184. [[ -f ${NEWSSPOOL_DIR}/db/history.n.dir ]] && \
  185. mv -vf "${NEWSSPOOL_DIR}"/db/history.n.dir \
  186. "${NEWSSPOOL_DIR}"/db/history.dir
  187. [[ -f ${NEWSSPOOL_DIR}/db/history.n.pag ]] && \
  188. mv -vf "${NEWSSPOOL_DIR}"/db/history.n.pag \
  189. "${NEWSSPOOL_DIR}"/db/history.pag
  190. [[ -f ${NEWSSPOOL_DIR}/db/history.n.hash ]] && \
  191. mv -vf "${NEWSSPOOL_DIR}"/db/history.n.hash \
  192. "${NEWSSPOOL_DIR}"/db/history.hash
  193. [[ -f ${NEWSSPOOL_DIR}/db/history.n.index ]] && \
  194. mv -vf "${NEWSSPOOL_DIR}"/db/history.n.index \
  195. "${NEWSSPOOL_DIR}"/db/history.index
  196. einfo "Running makehistory ..."
  197. su - news -c /usr/$(get_libdir)/news/bin/makehistory
  198. else
  199. NEWS_ERRFLAG="1"
  200. eerror "Your installation seems to be screwed up."
  201. eerror "${NEWSSPOOL_DIR}/db/history does not exist, but there's"
  202. eerror "one of the files history.dir, history.hash or history.index"
  203. eerror "within ${NEWSSPOOL_DIR}/db."
  204. eerror "Use your backup to restore the history database."
  205. fi
  206. else
  207. einfo "${NEWSSPOOL_DIR}/db/history found."
  208. einfo "Leaving history database as it is."
  209. fi
  210. INNCFG_INODES=$(
  211. sed /etc/news/inn.conf \
  212. -e '/innwatchspoolnodes/ ! d; s:[^ ]*[ ]*\([^ ]*\):\1:'
  213. )
  214. INNSPOOL_INODES=$(
  215. df -Pi ${NEWSSPOOL_DIR} | \
  216. sed -e 's:[^ ]*[ ]*\([^ ]*\).*:\1:; 1 d'
  217. )
  218. if [[ ${INNCFG_INODES} -gt ${INNSPOOL_INODES} ]]; then
  219. ewarn "Setting innwatchspoolinodes to zero, because the filesystem behind"
  220. ewarn "$NEWSSPOOL_DIR works without inodes."
  221. ewarn
  222. cp /etc/news/inn.conf /etc/news/inn.conf.OLD
  223. einfo "A copy of your old inn.conf has been saved to /etc/news/inn.conf.OLD."
  224. sed -i /etc/news/inn.conf \
  225. -e '/innwatchspoolnodes/ s:\([^ ]*\)\([ ]*\).*:\1\20:'
  226. chown news:news /etc/news/inn.conf
  227. chmod 644 /etc/news/inn.conf
  228. fi
  229. INNCHECK_LINES=$(
  230. su - news -c "/usr/$(get_libdir)/news/bin/inncheck | wc -l"
  231. )
  232. if [[ ${INNCHECK_LINES} -gt 0 ]]; then
  233. NEWS_ERRFLAG="1"
  234. ewarn "inncheck most certainly found an error."
  235. ewarn "Please check its output:"
  236. eerror "`su - news -c /usr/$(get_libdir)/news/bin/inncheck`"
  237. fi
  238. if [[ ${NEWS_ERRFLAG} -gt 0 ]]; then
  239. eerror "There were one or more errors/warnings checking your"
  240. eerror "configuration. Please read inn's documentation and"
  241. eerror "fix them accordingly."
  242. else
  243. einfo "INN configuration tests passed successfully."
  244. ewarn "Please ensure you have configured inn properly."
  245. fi
  246. }