rsyslog-8.19.0.ebuild 12 KB

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