rsyslog-8.25.0-r2.ebuild 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="6"
  4. inherit autotools eutils linux-info systemd
  5. DESCRIPTION="An enhanced multi-threaded syslogd with database support and more"
  6. HOMEPAGE="http://www.rsyslog.com/"
  7. BRANCH="8-stable"
  8. if [[ ${PV} == "9999" ]]; then
  9. EGIT_REPO_URI="
  10. git://github.com/rsyslog/${PN}.git
  11. https://github.com/rsyslog/${PN}.git
  12. "
  13. DOC_REPO_URI="
  14. git://github.com/rsyslog/${PN}-doc.git
  15. https://github.com/rsyslog/${PN}-doc.git
  16. "
  17. inherit git-r3
  18. else
  19. MY_PV=${PV%_rc*}
  20. MY_FILENAME="${PN}-${PV}.tar.gz"
  21. MY_FILENAME_DOCS="${PN}-docs-${PV}.tar.gz"
  22. S="${WORKDIR}/${PN}-${MY_PV}"
  23. # Upstream URL schema:
  24. # RC: http://www.rsyslog.com/files/download/rsyslog/rc/rsyslog-8.18.0.tar.gz
  25. # http://www.rsyslog.com/files/download/rsyslog/rc2/rsyslog-8.18.0.tar.gz
  26. # Release: http://www.rsyslog.com/files/download/rsyslog/rsyslog-8.18.0.tar.gz
  27. MY_URL_PREFIX=
  28. if [[ ${PV} = *_rc* ]]; then
  29. _tmp_last_index=$(($(get_last_version_component_index ${PV})+1))
  30. _tmp_suffix=$(get_version_component_range ${_tmp_last_index} ${PV})
  31. if [[ ${_tmp_suffix} = *rc* ]]; then
  32. MY_URL_PREFIX="${_tmp_suffix}/"
  33. fi
  34. # Cleaning up temporary variables
  35. unset _tmp_last_index
  36. unset _tmp_suffix
  37. else
  38. KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~x86"
  39. fi
  40. SRC_URI="
  41. http://www.rsyslog.com/files/download/${PN}/${MY_URL_PREFIX}${PN}-${MY_PV}.tar.gz -> ${MY_FILENAME}
  42. doc? ( http://www.rsyslog.com/files/download/${PN}/${MY_URL_PREFIX}${PN}-doc-${MY_PV}.tar.gz -> ${MY_FILENAME_DOCS} )
  43. "
  44. PATCHES=( "${FILESDIR}"/8-stable/${PN}-8.24.0-fix-tcpflood-without-librelp-r1.patch )
  45. fi
  46. LICENSE="GPL-3 LGPL-3 Apache-2.0"
  47. SLOT="0"
  48. IUSE="dbi debug doc elasticsearch +gcrypt grok jemalloc kafka kerberos libressl mdblookup mongodb mysql normalize omhttpfs"
  49. IUSE+=" omudpspoof postgres rabbitmq redis relp rfc3195 rfc5424hmac snmp ssl systemd test usertools +uuid zeromq"
  50. RDEPEND="
  51. >=dev-libs/libfastjson-0.99.3:=
  52. >=dev-libs/libestr-0.1.9
  53. >=dev-libs/liblogging-1.0.1:=[stdlog]
  54. >=sys-libs/zlib-1.2.5
  55. dbi? ( >=dev-db/libdbi-0.8.3 )
  56. elasticsearch? ( >=net-misc/curl-7.35.0 )
  57. gcrypt? ( >=dev-libs/libgcrypt-1.5.3:= )
  58. grok? ( >=dev-libs/grok-0.9.2 )
  59. jemalloc? ( >=dev-libs/jemalloc-3.3.1:= )
  60. kafka? ( >=dev-libs/librdkafka-0.9.0.99:= )
  61. kerberos? ( virtual/krb5 )
  62. mdblookup? ( dev-libs/libmaxminddb:= )
  63. mongodb? ( >=dev-libs/libmongo-client-0.1.4 )
  64. mysql? ( virtual/mysql )
  65. normalize? (
  66. >=dev-libs/libee-0.4.0
  67. >=dev-libs/liblognorm-2.0.1:=
  68. )
  69. omhttpfs? ( >=net-misc/curl-7.35.0 )
  70. omudpspoof? ( >=net-libs/libnet-1.1.6 )
  71. postgres? ( >=dev-db/postgresql-8.4.20:= )
  72. rabbitmq? ( >=net-libs/rabbitmq-c-0.3.0:= )
  73. redis? ( >=dev-libs/hiredis-0.11.0:= )
  74. relp? ( >=dev-libs/librelp-1.2.12:= )
  75. rfc3195? ( >=dev-libs/liblogging-1.0.1:=[rfc3195] )
  76. rfc5424hmac? (
  77. !libressl? ( >=dev-libs/openssl-0.9.8y:0= )
  78. libressl? ( dev-libs/libressl:= )
  79. )
  80. snmp? ( >=net-analyzer/net-snmp-5.7.2 )
  81. ssl? ( >=net-libs/gnutls-2.12.23:0= )
  82. systemd? ( >=sys-apps/systemd-208 )
  83. uuid? ( sys-apps/util-linux:0= )
  84. zeromq? (
  85. >=net-libs/zeromq-4.1.1:=
  86. >=net-libs/czmq-3.0.0
  87. )"
  88. DEPEND="${RDEPEND}
  89. >=sys-devel/autoconf-archive-2015.02.24
  90. virtual/pkgconfig
  91. test? ( sys-libs/libfaketime )"
  92. if [[ ${PV} == "9999" ]]; then
  93. DEPEND+=" doc? ( >=dev-python/sphinx-1.1.3-r7 )"
  94. DEPEND+=" >=sys-devel/flex-2.5.39-r1"
  95. DEPEND+=" >=sys-devel/bison-2.4.3"
  96. DEPEND+=" >=dev-python/docutils-0.12"
  97. fi
  98. CONFIG_CHECK="~INOTIFY_USER"
  99. WARNING_INOTIFY_USER="CONFIG_INOTIFY_USER isn't set. Imfile module on this system will only support polling mode!"
  100. src_unpack() {
  101. if [[ ${PV} == "9999" ]]; then
  102. git-r3_fetch
  103. git-r3_checkout
  104. else
  105. unpack ${P}.tar.gz
  106. fi
  107. if use doc; then
  108. if [[ ${PV} == "9999" ]]; then
  109. local _EGIT_BRANCH=
  110. if [[ -n "${EGIT_BRANCH}" ]]; then
  111. # Cannot use rsyslog commits/branches for documentation repository
  112. _EGIT_BRANCH=${EGIT_BRANCH}
  113. unset EGIT_BRANCH
  114. fi
  115. git-r3_fetch "${DOC_REPO_URI}"
  116. git-r3_checkout "${DOC_REPO_URI}" "${S}"/docs
  117. if [[ -n "${_EGIT_BRANCH}" ]]; then
  118. # Restore previous EGIT_BRANCH information
  119. EGIT_BRANCH=${_EGIT_BRANCH}
  120. fi
  121. else
  122. cd "${S}" || die "Cannot change dir into '${S}'"
  123. mkdir docs || die "Failed to create docs directory"
  124. cd docs || die "Failed to change dir into '${S}/docs'"
  125. unpack ${MY_FILENAME_DOCS}
  126. fi
  127. fi
  128. }
  129. src_prepare() {
  130. default
  131. eautoreconf
  132. }
  133. src_configure() {
  134. # Maintainer notes:
  135. # * Guardtime support is missing because libgt isn't yet available
  136. # in portage.
  137. # * Hadoop's HDFS file system output module is currently not
  138. # supported in Gentoo because nobody is able to test it
  139. # (JAVA dependency).
  140. # * dev-libs/hiredis doesn't provide pkg-config (see #504614,
  141. # upstream PR 129 and 136) so we need to export HIREDIS_*
  142. # variables because rsyslog's build system depends on pkg-config.
  143. if use redis; then
  144. export HIREDIS_LIBS="-L${EPREFIX}/usr/$(get_libdir) -lhiredis"
  145. export HIREDIS_CFLAGS="-I${EPREFIX}/usr/include"
  146. fi
  147. local myeconfargs=(
  148. --disable-debug-symbols
  149. --disable-generate-man-pages
  150. --without-valgrind-testbench
  151. $(use_enable test testbench)
  152. # Input Plugins without depedencies
  153. --enable-imdiag
  154. --enable-imfile
  155. --enable-impstats
  156. --enable-imptcp
  157. # Message Modificiation Plugins without depedencies
  158. --enable-mmanon
  159. --enable-mmaudit
  160. --enable-mmcount
  161. --enable-mmfields
  162. --enable-mmjsonparse
  163. --enable-mmpstrucdata
  164. --enable-mmrm1stspace
  165. --enable-mmsequence
  166. --enable-mmutf8fix
  167. # Output Modification Plugins without dependencies
  168. --enable-mail
  169. --enable-omprog
  170. --enable-omruleset
  171. --enable-omstdout
  172. --enable-omuxsock
  173. # Misc
  174. --enable-pmaixforwardedfrom
  175. --enable-pmciscoios
  176. --enable-pmcisconames
  177. --enable-pmlastmsg
  178. --enable-pmsnare
  179. # DB
  180. $(use_enable dbi libdbi)
  181. $(use_enable mongodb ommongodb)
  182. $(use_enable mysql)
  183. $(use_enable postgres pgsql)
  184. $(use_enable redis omhiredis)
  185. # Debug
  186. $(use_enable debug)
  187. $(use_enable debug diagtools)
  188. $(use_enable debug memcheck)
  189. $(use_enable debug rtinst)
  190. $(use_enable debug valgrind)
  191. # Misc
  192. $(use_enable elasticsearch)
  193. $(use_enable gcrypt libgcrypt)
  194. $(use_enable jemalloc)
  195. $(use_enable kafka omkafka)
  196. $(use_enable kerberos gssapi-krb5)
  197. $(use_enable normalize mmnormalize)
  198. $(use_enable mdblookup mmdblookup)
  199. $(use_enable grok mmgrok)
  200. $(use_enable omhttpfs)
  201. $(use_enable omudpspoof)
  202. $(use_enable rabbitmq omrabbitmq)
  203. $(use_enable relp)
  204. $(use_enable rfc3195)
  205. $(use_enable rfc5424hmac mmrfc5424addhmac)
  206. $(use_enable snmp)
  207. $(use_enable snmp mmsnmptrapd)
  208. $(use_enable ssl gnutls)
  209. $(use_enable systemd imjournal)
  210. $(use_enable systemd omjournal)
  211. $(use_enable usertools)
  212. $(use_enable uuid)
  213. $(use_enable zeromq imczmq)
  214. $(use_enable zeromq imzmq3)
  215. $(use_enable zeromq omczmq)
  216. $(use_enable zeromq omzmq3)
  217. --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
  218. )
  219. econf "${myeconfargs[@]}"
  220. }
  221. src_compile() {
  222. default
  223. if use doc && [[ "${PV}" == "9999" ]]; then
  224. einfo "Building documentation ..."
  225. local doc_dir="${S}/docs"
  226. cd "${doc_dir}" || die "Cannot chdir into \"${doc_dir}\"!"
  227. sphinx-build -b html source build || die "Building documentation failed!"
  228. fi
  229. }
  230. src_test() {
  231. local _has_increased_ulimit=
  232. # Sometimes tests aren't executable (i.e. when added via patch)
  233. einfo "Adjusting permissions of test scripts ..."
  234. find "${S}"/tests -type f -name '*.sh' \! -perm -111 -exec chmod a+x '{}' \; || \
  235. die "Failed to adjust test scripts permission"
  236. if ulimit -n 3072; then
  237. _has_increased_ulimit="true"
  238. fi
  239. if ! emake --jobs 1 check; then
  240. eerror "Test suite failed! :("
  241. if [[ -z "${_has_increased_ulimit}" ]]; then
  242. eerror "Probably because open file limit couldn't be set to 3072."
  243. fi
  244. if has userpriv ${FEATURES}; then
  245. eerror "Please try to reproduce the test suite failure with FEATURES=-userpriv " \
  246. "before you submit a bug report."
  247. fi
  248. fi
  249. }
  250. src_install() {
  251. local DOCS=(
  252. AUTHORS
  253. ChangeLog
  254. "${FILESDIR}"/${BRANCH}/README.gentoo
  255. )
  256. use doc && local HTML_DOCS=( "${S}/docs/build/." )
  257. default
  258. newconfd "${FILESDIR}/${BRANCH}/${PN}.confd-r1" ${PN}
  259. newinitd "${FILESDIR}/${BRANCH}/${PN}.initd-r1" ${PN}
  260. keepdir /var/empty/dev
  261. keepdir /var/spool/${PN}
  262. keepdir /etc/ssl/${PN}
  263. keepdir /etc/${PN}.d
  264. insinto /etc
  265. newins "${FILESDIR}/${BRANCH}/${PN}.conf" ${PN}.conf
  266. insinto /etc/rsyslog.d/
  267. doins "${FILESDIR}/${BRANCH}/50-default.conf"
  268. insinto /etc/logrotate.d/
  269. newins "${FILESDIR}/${BRANCH}/${PN}.logrotate" ${PN}
  270. if use mysql; then
  271. insinto /usr/share/doc/${PF}/scripts/mysql
  272. doins plugins/ommysql/createDB.sql
  273. fi
  274. if use postgres; then
  275. insinto /usr/share/doc/${PF}/scripts/pgsql
  276. doins plugins/ompgsql/createDB.sql
  277. fi
  278. prune_libtool_files --modules
  279. }
  280. pkg_postinst() {
  281. local advertise_readme=0
  282. if [[ -z "${REPLACING_VERSIONS}" ]]; then
  283. # This is a new installation
  284. advertise_readme=1
  285. if use mysql || use postgres; then
  286. echo
  287. elog "Sample SQL scripts for MySQL & PostgreSQL have been installed to:"
  288. elog " /usr/share/doc/${PF}/scripts"
  289. fi
  290. if use ssl; then
  291. echo
  292. elog "To create a default CA and certificates for your server and clients, run:"
  293. elog " emerge --config =${PF}"
  294. elog "on your logging server. You can run it several times,"
  295. elog "once for each logging client. The client certificates will be signed"
  296. elog "using the CA certificate generated during the first run."
  297. fi
  298. fi
  299. if [[ ${advertise_readme} -gt 0 ]]; then
  300. # We need to show the README file location
  301. echo ""
  302. elog "Please read"
  303. elog ""
  304. elog " ${EPREFIX}/usr/share/doc/${PF}/README.gentoo*"
  305. elog ""
  306. elog "for more details."
  307. fi
  308. }
  309. pkg_config() {
  310. if ! use ssl ; then
  311. einfo "There is nothing to configure for rsyslog unless you"
  312. einfo "used USE=ssl to build it."
  313. return 0
  314. fi
  315. # Make sure the certificates directory exists
  316. local CERTDIR="${EROOT}/etc/ssl/${PN}"
  317. if [[ ! -d "${CERTDIR}" ]]; then
  318. mkdir "${CERTDIR}" || die
  319. fi
  320. einfo "Your certificates will be stored in ${CERTDIR}"
  321. # Create a default CA if needed
  322. if [[ ! -f "${CERTDIR}/${PN}_ca.cert.pem" ]]; then
  323. einfo "No CA key and certificate found in ${CERTDIR}, creating them for you..."
  324. certtool --generate-privkey \
  325. --outfile "${CERTDIR}/${PN}_ca.privkey.pem" &>/dev/null
  326. chmod 400 "${CERTDIR}/${PN}_ca.privkey.pem"
  327. cat > "${T}/${PF}.$$" <<- _EOF
  328. cn = Portage automated CA
  329. ca
  330. cert_signing_key
  331. expiration_days = 3650
  332. _EOF
  333. certtool --generate-self-signed \
  334. --load-privkey "${CERTDIR}/${PN}_ca.privkey.pem" \
  335. --outfile "${CERTDIR}/${PN}_ca.cert.pem" \
  336. --template "${T}/${PF}.$$" &>/dev/null
  337. chmod 400 "${CERTDIR}/${PN}_ca.privkey.pem"
  338. # Create the server certificate
  339. echo
  340. einfon "Please type the Common Name of the SERVER you wish to create a certificate for: "
  341. read -r CN
  342. einfo "Creating private key and certificate for server ${CN}..."
  343. certtool --generate-privkey \
  344. --outfile "${CERTDIR}/${PN}_${CN}.key.pem" &>/dev/null
  345. chmod 400 "${CERTDIR}/${PN}_${CN}.key.pem"
  346. cat > "${T}/${PF}.$$" <<- _EOF
  347. cn = ${CN}
  348. tls_www_server
  349. dns_name = ${CN}
  350. expiration_days = 3650
  351. _EOF
  352. certtool --generate-certificate \
  353. --outfile "${CERTDIR}/${PN}_${CN}.cert.pem" \
  354. --load-privkey "${CERTDIR}/${PN}_${CN}.key.pem" \
  355. --load-ca-certificate "${CERTDIR}/${PN}_ca.cert.pem" \
  356. --load-ca-privkey "${CERTDIR}/${PN}_ca.privkey.pem" \
  357. --template "${T}/${PF}.$$" &>/dev/null
  358. chmod 400 "${CERTDIR}/${PN}_${CN}.cert.pem"
  359. else
  360. einfo "Found existing ${CERTDIR}/${PN}_ca.cert.pem, skipping CA and SERVER creation."
  361. fi
  362. # Create a client certificate
  363. echo
  364. einfon "Please type the Common Name of the CLIENT you wish to create a certificate for: "
  365. read -r CN
  366. einfo "Creating private key and certificate for client ${CN}..."
  367. certtool --generate-privkey \
  368. --outfile "${CERTDIR}/${PN}_${CN}.key.pem" &>/dev/null
  369. chmod 400 "${CERTDIR}/${PN}_${CN}.key.pem"
  370. cat > "${T}/${PF}.$$" <<- _EOF
  371. cn = ${CN}
  372. tls_www_client
  373. dns_name = ${CN}
  374. expiration_days = 3650
  375. _EOF
  376. certtool --generate-certificate \
  377. --outfile "${CERTDIR}/${PN}_${CN}.cert.pem" \
  378. --load-privkey "${CERTDIR}/${PN}_${CN}.key.pem" \
  379. --load-ca-certificate "${CERTDIR}/${PN}_ca.cert.pem" \
  380. --load-ca-privkey "${CERTDIR}/${PN}_ca.privkey.pem" \
  381. --template "${T}/${PF}.$$" &>/dev/null
  382. chmod 400 "${CERTDIR}/${PN}_${CN}.cert.pem"
  383. rm -f "${T}/${PF}.$$"
  384. echo
  385. einfo "Here is the documentation on how to encrypt your log traffic:"
  386. einfo " http://www.rsyslog.com/doc/rsyslog_tls.html"
  387. }