logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

inn-2.6.4.ebuild (7656B)


  1. # Copyright 1999-2021 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. PYTHON_COMPAT=( python3_{7,8,9} )
  5. inherit autotools eutils multilib python-single-r1 toolchain-funcs
  6. DESCRIPTION="The Internet News daemon, fully featured NNTP server"
  7. HOMEPAGE="https://www.eyrie.org/~eagle/software/inn/"
  8. SRC_URI="https://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 ~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:0= )
  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. default
  32. }
  33. src_configure() {
  34. tc-export AR
  35. econf \
  36. --prefix=/usr/$(get_libdir)/news \
  37. --sysconfdir=/etc/news \
  38. --mandir=/usr/share/man \
  39. --infodir=/usr/share/info \
  40. --with-control-dir=/usr/$(get_libdir)/news/bin/control \
  41. --with-filter-dir=/usr/$(get_libdir)/news/bin/filter \
  42. --with-db-dir=/var/spool/news/db \
  43. --with-doc-dir=/usr/share/doc/${PF} \
  44. --with-spool-dir=/var/spool/news \
  45. --with-log-dir=/var/log/news \
  46. --with-run-dir=/run/news \
  47. --with-tmp-dir=/var/spool/news/tmp \
  48. --with-gnu-ld \
  49. --enable-setgid-inews \
  50. --enable-uucp-rnews \
  51. --with-sendmail=/usr/sbin/sendmail \
  52. $(use_with perl) \
  53. $(use_with python) \
  54. $(use_with sasl) \
  55. $(use_with ssl openssl) \
  56. $(use_enable !inntaggedhash largefiles) \
  57. $(use_enable inntaggedhash tagged-hash) \
  58. $(use_enable innkeywords keywords)
  59. }
  60. src_install() {
  61. emake DESTDIR="${D}/" P="" SPECIAL="" install
  62. chown -R root:0 \
  63. "${D}"/usr/$(get_libdir)/news/$(get_libdir) \
  64. "${D}"/usr/$(get_libdir)/news/include \
  65. "${D}"/usr/share/doc \
  66. "${D}"/usr/share/man \
  67. || die
  68. chmod 644 "${D}"/etc/news/* || die
  69. chmod 640 \
  70. "${D}"/etc/news/control.ctl \
  71. "${D}"/etc/news/expire.ctl \
  72. "${D}"/etc/news/incoming.conf \
  73. "${D}"/etc/news/innfeed.conf \
  74. "${D}"/etc/news/nntpsend.ctl \
  75. "${D}"/etc/news/passwd.nntp \
  76. "${D}"/etc/news/readers.conf \
  77. || die
  78. # Prevent old db/* files from being overwritten
  79. insinto /usr/share/inn/dbexamples
  80. newins site/active.minimal active
  81. newins site/newsgroups.minimal newsgroups
  82. keepdir \
  83. /var/log/news \
  84. /var/spool/news/archive \
  85. /var/spool/news/articles \
  86. /var/spool/news/db \
  87. /var/spool/news/incoming \
  88. /var/spool/news/incoming/bad \
  89. /var/spool/news/innfeed \
  90. /var/spool/news/outgoing \
  91. /var/spool/news/overview \
  92. /var/spool/news/tmp
  93. fowners news:news /var/log/news
  94. dodoc ChangeLog MANIFEST README* doc/checklist
  95. use ipv6 && dodoc doc/IPv6-info
  96. # So other programs can build against INN
  97. insinto /usr/$(get_libdir)/news/include
  98. doins include/*.h
  99. newinitd "${FILESDIR}"/innd-r1 innd
  100. }
  101. pkg_postinst() {
  102. for db_file in active newsgroups
  103. do
  104. [[ -f ${ROOT}var/spool/news/db/${db_file} ]] && continue
  105. if [[ -f ${ROOT}usr/share/inn/dbexamples/${db_file} ]]
  106. then
  107. cp "${ROOT}"usr/share/inn/dbexamples/${db_file} \
  108. "${ROOT}"var/spool/news/db/${db_file}
  109. else
  110. touch "${ROOT}"var/spool/news/db/${db_file}
  111. fi
  112. chown news:news "${ROOT}"var/spool/news/db/${db_file}
  113. chmod 664 "${ROOT}"var/spool/news/db/${db_file}
  114. done
  115. elog "It is recommended to run emerge --config ${CATEGORY}/${PN}"
  116. elog "now to finish setting up this package."
  117. elog
  118. elog "Do not forget to update your cron entries, and also run"
  119. elog "makedbz if you need to. If this is a first-time installation"
  120. elog "a minimal active file has been installed. You will need to"
  121. elog "touch history and run 'makedbz -i' to initialize the history"
  122. elog "database. See INSTALL for more information."
  123. elog
  124. elog "You need to assign a real shell to the news user, or else"
  125. elog "starting inn will fail. You can use 'usermod -s /bin/bash news'"
  126. elog "for this."
  127. }
  128. pkg_postrm() {
  129. elog
  130. elog "If you want your newsspool or altered configuration files"
  131. elog "to be removed, please do so now manually."
  132. elog
  133. }
  134. pkg_config() {
  135. NEWSSPOOL_DIR="${ROOT}var/spool/news"
  136. NEWS_SHELL="$( awk -F':' '/^news:/ {print $7;}' ${ROOT}etc/passwd )"
  137. NEWS_ERRFLAG="0"
  138. if [[ ${NEWS_SHELL} == /bin/false || ${NEWS_SHELL} == /dev/null ]]; then
  139. einfo "Changing shell to /bin/bash for user news..."
  140. usermod -s /bin/bash news
  141. else
  142. einfo "Shell for user news unchanged ('${NEWS_SHELL}')."
  143. if [[ ${NEWS_SHELL} != /bin/sh && ${NEWS_SHELL} != /bin/bash ]]; then
  144. ewarn "You might want to change it to '/bin/bash', though."
  145. fi
  146. fi
  147. if [[ ! -e ${NEWSSPOOL_DIR}/db/history ]]; then
  148. if [[ ! -f ${NEWSSPOOL_DIR}/db/history.dir \
  149. && ! -f ${NEWSSPOOL_DIR}/db/history.pag \
  150. && ! -f ${NEWSSPOOL_DIR}/db/history.hash \
  151. && ! -f ${NEWSSPOOL_DIR}/db/history.index ]]
  152. then
  153. einfo "Building history database ..."
  154. touch "${NEWSSPOOL_DIR}"/db/history
  155. chown news:news "${NEWSSPOOL_DIR}"/db/history
  156. chmod 644 "${NEWSSPOOL_DIR}"/db/history
  157. einfo "Running makedbz -i ..."
  158. su - news -c "/usr/$(get_libdir)/news/bin/makedbz -i"
  159. einfo "Moving files into place ..."
  160. [[ -f ${NEWSSPOOL_DIR}/db/history.n.dir ]] && \
  161. mv -vf "${NEWSSPOOL_DIR}"/db/history.n.dir \
  162. "${NEWSSPOOL_DIR}"/db/history.dir
  163. [[ -f ${NEWSSPOOL_DIR}/db/history.n.pag ]] && \
  164. mv -vf "${NEWSSPOOL_DIR}"/db/history.n.pag \
  165. "${NEWSSPOOL_DIR}"/db/history.pag
  166. [[ -f ${NEWSSPOOL_DIR}/db/history.n.hash ]] && \
  167. mv -vf "${NEWSSPOOL_DIR}"/db/history.n.hash \
  168. "${NEWSSPOOL_DIR}"/db/history.hash
  169. [[ -f ${NEWSSPOOL_DIR}/db/history.n.index ]] && \
  170. mv -vf "${NEWSSPOOL_DIR}"/db/history.n.index \
  171. "${NEWSSPOOL_DIR}"/db/history.index
  172. einfo "Running makehistory ..."
  173. su - news -c /usr/$(get_libdir)/news/bin/makehistory
  174. else
  175. NEWS_ERRFLAG="1"
  176. eerror "Your installation seems to be screwed up."
  177. eerror "${NEWSSPOOL_DIR}/db/history does not exist, but there's"
  178. eerror "one of the files history.dir, history.hash or history.index"
  179. eerror "within ${NEWSSPOOL_DIR}/db."
  180. eerror "Use your backup to restore the history database."
  181. fi
  182. else
  183. einfo "${NEWSSPOOL_DIR}/db/history found."
  184. einfo "Leaving history database as it is."
  185. fi
  186. INNCFG_INODES=$(
  187. sed /etc/news/inn.conf \
  188. -e '/innwatchspoolnodes/ ! d; s:[^ ]*[ ]*\([^ ]*\):\1:'
  189. )
  190. INNSPOOL_INODES=$(
  191. df -Pi ${NEWSSPOOL_DIR} | \
  192. sed -e 's:[^ ]*[ ]*\([^ ]*\).*:\1:; 1 d'
  193. )
  194. if [[ ${INNCFG_INODES} -gt ${INNSPOOL_INODES} ]]; then
  195. ewarn "Setting innwatchspoolinodes to zero, because the filesystem behind"
  196. ewarn "$NEWSSPOOL_DIR works without inodes."
  197. ewarn
  198. cp /etc/news/inn.conf /etc/news/inn.conf.OLD
  199. einfo "A copy of your old inn.conf has been saved to /etc/news/inn.conf.OLD."
  200. sed -i /etc/news/inn.conf \
  201. -e '/innwatchspoolnodes/ s:\([^ ]*\)\([ ]*\).*:\1\20:'
  202. chown news:news /etc/news/inn.conf
  203. chmod 644 /etc/news/inn.conf
  204. fi
  205. INNCHECK_LINES=$(
  206. su - news -c "/usr/$(get_libdir)/news/bin/inncheck | wc -l"
  207. )
  208. if [[ ${INNCHECK_LINES} -gt 0 ]]; then
  209. NEWS_ERRFLAG="1"
  210. ewarn "inncheck most certainly found an error."
  211. ewarn "Please check its output:"
  212. eerror "`su - news -c /usr/$(get_libdir)/news/bin/inncheck`"
  213. fi
  214. if [[ ${NEWS_ERRFLAG} -gt 0 ]]; then
  215. eerror "There were one or more errors/warnings checking your"
  216. eerror "configuration. Please read inn's documentation and"
  217. eerror "fix them accordingly."
  218. else
  219. einfo "INN configuration tests passed successfully."
  220. ewarn "Please ensure you have configured inn properly."
  221. fi
  222. }