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.2.ebuild (7741B)


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