rsyslog-8.26.0.ebuild 12 KB

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