logo

overlay

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

unrealircd-4.2.0.ebuild (5384B)


  1. # Copyright 1999-2018 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. SSL_CERT_MANDATORY=1
  5. inherit eapi7-ver ssl-cert user
  6. DESCRIPTION="An advanced Internet Relay Chat daemon"
  7. HOMEPAGE="https://www.unrealircd.org/"
  8. SRC_URI="https://www.unrealircd.org/${PN}$(ver_cut 1)/${P}.tar.gz"
  9. LICENSE="GPL-2"
  10. SLOT="0"
  11. KEYWORDS="~amd64 ~ppc ~x86 ~x86-fbsd ~amd64-linux"
  12. IUSE="class-nofakelag curl +extban-stacking +operoverride operoverride-verify +prefixaq
  13. showlistmodes shunnotices topicisnuhost +usermod"
  14. RDEPEND="
  15. dev-libs/openssl:0=
  16. dev-libs/libpcre2
  17. dev-libs/tre
  18. >=net-dns/c-ares-1.7:=
  19. sys-libs/zlib
  20. curl? ( net-misc/curl[adns] )
  21. "
  22. DEPEND="${RDEPEND}
  23. virtual/pkgconfig
  24. "
  25. DOCS=( doc/{Authors,Donation,RELEASE-NOTES{,.old},tao.of.irc,technical/,translations.txt} )
  26. pkg_pretend() {
  27. local v
  28. for v in ${REPLACING_VERSIONS}; do
  29. ver_test "${v}" -ge 4 && continue
  30. ewarn "The configuration file format has changed since ${v}."
  31. ewarn "Please be prepared to manually update them and visit:"
  32. ewarn "https://www.unrealircd.org/docs/Upgrading_from_3.2.x"
  33. break
  34. done
  35. }
  36. pkg_setup() {
  37. enewuser unrealircd
  38. }
  39. src_prepare() {
  40. # QA check against bundled pkgs
  41. rm -r extras || die
  42. if use class-nofakelag; then
  43. sed -i -e 's:#undef\( FAKELAG_CONFIGURABLE\):#define\1:' include/config.h || die
  44. fi
  45. # By default looks in /etc/unrealircd/ssl/curl-ca-bundle.crt. Fix
  46. # that to look for ca-certificates-provided file instead. %s is
  47. # CONFDIR. #618066
  48. sed -i -e 's:%s/ssl/curl-ca-bundle.crt:%s/../ssl/certs/ca-certificates.crt:' src/s_conf.c || die
  49. eapply_user
  50. }
  51. src_configure() {
  52. # Default value for privatelibdir adds a build path to -Wl,-rpath.
  53. econf \
  54. --with-bindir="${EPREFIX}"/usr/bin \
  55. --with-cachedir="${EPREFIX}"/var/lib/${PN} \
  56. --with-confdir="${EPREFIX}"/etc/${PN} \
  57. --with-datadir="${EPREFIX}"/var/lib/${PN} \
  58. --with-docdir="${EPREFIX}"/usr/share/doc/${PF} \
  59. --with-logdir="${EPREFIX}"/var/log/${PN} \
  60. --with-modulesdir="${EPREFIX}"/usr/"$(get_libdir)"/${PN}/modules \
  61. --without-privatelibdir \
  62. --with-pidfile="${EPREFIX}"/run/${PN}/ircd.pid \
  63. --with-tmpdir="${EPREFIX}"/var/lib/${PN}/tmp \
  64. --with-nick-history=2000 \
  65. --with-sendq=3000000 \
  66. --with-permissions=0640 \
  67. --with-fd-setsize=1024 \
  68. --with-system-cares \
  69. --with-system-pcre2 \
  70. --with-system-tre \
  71. --enable-dynamic-linking \
  72. --enable-ssl="${EPREFIX}"/usr \
  73. $(use_enable curl libcurl "${EPREFIX}"/usr) \
  74. $(use_enable prefixaq) \
  75. $(use_with showlistmodes) \
  76. $(use_with topicisnuhost) \
  77. $(use_with shunnotices) \
  78. $(use_with !operoverride no-operoverride) \
  79. $(use_with operoverride-verify) \
  80. $(use_with !usermod disableusermod) \
  81. $(use_with !extban-stacking disable-extendedban-stacking)
  82. }
  83. src_install() {
  84. keepdir /var/log/${PN}
  85. keepdir /var/lib/${PN}/tmp
  86. newbin src/ircd ${PN}
  87. (
  88. cd src/modules || die
  89. for subdir in $(find . -type d -print); do
  90. if [[ -n $(shopt -s nullglob; echo ${subdir}/*.so) ]]; then
  91. exeinto /usr/$(get_libdir)/${PN}/modules/"${subdir}"
  92. doexe "${subdir}"/*.so
  93. fi
  94. done
  95. )
  96. insinto /etc/${PN}
  97. # Purposefully omitting the examples/ and ssl/ subdirectories. ssl
  98. # is redundant with app-misc/ca-certificates and examples will all
  99. # be in docs anyway.
  100. doins -r doc/conf/{aliases,help}
  101. doins doc/conf/*.conf
  102. newins doc/conf/examples/example.conf ${PN}.conf
  103. keepdir /etc/${PN}/ssl
  104. einstalldocs
  105. newinitd "${FILESDIR}"/${PN}.initd-r2 ${PN}
  106. newconfd "${FILESDIR}"/${PN}.confd-r3 ${PN}
  107. # config should be read-only
  108. fperms -R 0640 /etc/${PN}
  109. fperms 0750 /etc/${PN}{,/aliases,/help}
  110. fperms 0750 /etc/${PN}/ssl
  111. # state is editable but not owned by unrealircd directly
  112. fperms 0770 /var/log/${PN}
  113. fperms 0770 /var/lib/${PN}{,/tmp}
  114. fowners -R root:unrealircd /{etc,var/{lib,log}}/${PN}
  115. }
  116. pkg_postinst() {
  117. # Move docert call from src_install() to install_cert in pkg_postinst for
  118. # bug #201682
  119. if [[ ! -f "${EROOT}"etc/${PN}/ssl/server.cert.key ]]; then
  120. if [[ -f "${EROOT}"etc/${PN}/server.cert.key ]]; then
  121. ewarn "The location ${PN} looks for SSL certificates has changed"
  122. ewarn "from ${EROOT}etc/${PN} to ${EROOT}etc/${PN}/ssl."
  123. ewarn "Please move your existing certificates."
  124. else
  125. (
  126. umask 0037
  127. install_cert /etc/${PN}/ssl/server.cert
  128. chown unrealircd "${EROOT}"etc/${PN}/ssl/server.cert.*
  129. ln -snf server.cert.key "${EROOT}"etc/${PN}/ssl/server.key.pem
  130. )
  131. fi
  132. fi
  133. local unrealircd_conf="${EROOT}"etc/${PN}/${PN}.conf
  134. # Fix up the default cloak keys.
  135. if grep -qe '"and another one";$' "${unrealircd_conf}" && grep -qe '"aoAr1HnR6gl3sJ7hVz4Zb7x4YwpW";$' "${unrealircd_conf}"; then
  136. ebegin "Generating cloak-keys"
  137. local keys=(
  138. $(su ${PN} -s /bin/sh -c "${PN} -k 2>&1 | tail -n 3")
  139. )
  140. [[ -n ${keys[0]} || -n ${keys[1]} || -n ${keys[2]} ]]
  141. eend $?
  142. ebegin "Substituting cloak-keys into ${unrealircd_conf}"
  143. sed -i \
  144. -e '/cloak-keys/ {
  145. n
  146. s/"aoAr1HnR6gl3sJ7hVz4Zb7x4YwpW";/"'"${keys[0]}"'";/
  147. n
  148. s/"and another one";/"'"${keys[1]}"'";/
  149. n
  150. s/"and another one";/"'"${keys[2]}"'";/
  151. }' \
  152. "${unrealircd_conf}"
  153. eend $?
  154. fi
  155. elog "UnrealIRCd will not run until you've set up /etc/unrealircd/unrealircd.conf"
  156. elog
  157. elog "You can also configure ${PN} start at boot with rc-update(1)."
  158. elog "It is recommended to run unrealircd as an unprivileged user."
  159. elog "The provided init.d script does this for you."
  160. }