clamav-0.98.7-r1.ebuild 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit eutils flag-o-matic user systemd
  5. DESCRIPTION="Clam Anti-Virus Scanner"
  6. HOMEPAGE="http://www.clamav.net/"
  7. SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
  8. LICENSE="GPL-2"
  9. SLOT="0"
  10. KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~sparc-solaris ~x86-solaris"
  11. IUSE="bzip2 clamdtop iconv ipv6 libressl milter metadata-analysis-api selinux static-libs uclibc"
  12. CDEPEND="bzip2? ( app-arch/bzip2 )
  13. clamdtop? ( sys-libs/ncurses:0 )
  14. iconv? ( virtual/libiconv )
  15. metadata-analysis-api? ( dev-libs/json-c )
  16. milter? ( || ( mail-filter/libmilter mail-mta/sendmail ) )
  17. dev-libs/libtommath
  18. >=sys-libs/zlib-1.2.2
  19. !libressl? ( dev-libs/openssl:0= )
  20. libressl? ( dev-libs/libressl:0= )
  21. sys-devel/libtool"
  22. # openssl is now *required* see this link as to why
  23. # http://blog.clamav.net/2014/02/introducing-openssl-as-dependency-to.html
  24. DEPEND="${CDEPEND}
  25. virtual/pkgconfig"
  26. RDEPEND="${CDEPEND}
  27. selinux? ( sec-policy/selinux-clamav )"
  28. DOCS=( AUTHORS BUGS ChangeLog FAQ INSTALL NEWS README UPGRADE )
  29. pkg_setup() {
  30. enewgroup clamav
  31. enewuser clamav -1 -1 /dev/null clamav
  32. }
  33. src_prepare() {
  34. use ppc64 && append-flags -mminimal-toc
  35. use uclibc && export ac_cv_type_error_t=yes
  36. }
  37. src_configure() {
  38. econf \
  39. --disable-experimental \
  40. --disable-fanotify \
  41. --enable-id-check \
  42. --with-dbdir="${EPREFIX}"/var/lib/clamav \
  43. --with-system-tommath \
  44. --with-zlib="${EPREFIX}"/usr \
  45. $(use_enable bzip2) \
  46. $(use_enable clamdtop) \
  47. $(use_enable ipv6) \
  48. $(use_enable milter) \
  49. $(use_enable static-libs static) \
  50. $(use_with iconv) \
  51. $(use_with metadata-analysis-api libjson /usr)
  52. }
  53. src_install() {
  54. default
  55. rm -rf "${ED}"/var/lib/clamav
  56. newinitd "${FILESDIR}"/clamd.initd-r6 clamd
  57. newconfd "${FILESDIR}"/clamd.conf-r1 clamd
  58. systemd_dotmpfilesd "${FILESDIR}/tmpfiles.d/clamav.conf"
  59. systemd_newunit "${FILESDIR}/clamd_at.service" "clamd@.service"
  60. systemd_dounit "${FILESDIR}/clamd.service"
  61. systemd_dounit "${FILESDIR}/freshclamd.service"
  62. keepdir /var/lib/clamav
  63. fowners clamav:clamav /var/lib/clamav
  64. keepdir /var/log/clamav
  65. fowners clamav:clamav /var/log/clamav
  66. dodir /etc/logrotate.d
  67. insinto /etc/logrotate.d
  68. newins "${FILESDIR}"/clamav.logrotate clamav
  69. # Modify /etc/{clamd,freshclam}.conf to be usable out of the box
  70. sed -i -e "s:^\(Example\):\# \1:" \
  71. -e "s:.*\(PidFile\) .*:\1 ${EPREFIX}/var/run/clamav/clamd.pid:" \
  72. -e "s:.*\(LocalSocket\) .*:\1 ${EPREFIX}/var/run/clamav/clamd.sock:" \
  73. -e "s:.*\(User\) .*:\1 clamav:" \
  74. -e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamd.log:" \
  75. -e "s:^\#\(LogTime\).*:\1 yes:" \
  76. -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
  77. "${ED}"/etc/clamd.conf.sample || die
  78. sed -i -e "s:^\(Example\):\# \1:" \
  79. -e "s:.*\(PidFile\) .*:\1 ${EPREFIX}/var/run/clamav/freshclam.pid:" \
  80. -e "s:.*\(DatabaseOwner\) .*:\1 clamav:" \
  81. -e "s:^\#\(UpdateLogFile\) .*:\1 ${EPREFIX}/var/log/clamav/freshclam.log:" \
  82. -e "s:^\#\(NotifyClamd\).*:\1 ${EPREFIX}/etc/clamd.conf:" \
  83. -e "s:^\#\(ScriptedUpdates\).*:\1 yes:" \
  84. -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
  85. "${ED}"/etc/freshclam.conf.sample || die
  86. if use milter ; then
  87. # MilterSocket one to include ' /' because there is a 2nd line for
  88. # inet: which we want to leave
  89. dodoc "${FILESDIR}"/clamav-milter.README.gentoo
  90. sed -i -e "s:^\(Example\):\# \1:" \
  91. -e "s:.*\(PidFile\) .*:\1 ${EPREFIX}/var/run/clamav/clamav-milter.pid:" \
  92. -e "s+^\#\(ClamdSocket\) .*+\1 unix:${EPREFIX}/var/run/clamav/clamd.sock+" \
  93. -e "s:.*\(User\) .*:\1 clamav:" \
  94. -e "s+^\#\(MilterSocket\) /.*+\1 unix:${EPREFIX}/var/run/clamav/clamav-milter.sock+" \
  95. -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
  96. -e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamav-milter.log:" \
  97. "${ED}"/etc/clamav-milter.conf.sample || die
  98. cat >> "${ED}"/etc/conf.d/clamd <<-EOF
  99. MILTER_NICELEVEL=19
  100. START_MILTER=no
  101. EOF
  102. systemd_newunit "${FILESDIR}/clamav-milter.service-r1" clamav-milter.service
  103. fi
  104. for i in clamd freshclam clamav-milter
  105. do
  106. [[ -f "${D}"/etc/"${i}".conf.sample ]] && mv "${D}"/etc/"${i}".conf{.sample,}
  107. done
  108. prune_libtool_files --all
  109. }
  110. pkg_postinst() {
  111. if use milter ; then
  112. elog "For simple instructions how to setup the clamav-milter read the"
  113. elog "clamav-milter.README.gentoo in /usr/share/doc/${PF}"
  114. fi
  115. if test -z $(find "${ROOT}"var/lib/clamav -maxdepth 1 -name 'main.c*' -print -quit) ; then
  116. ewarn "You must run freshclam manually to populate the virus database files"
  117. ewarn "before starting clamav for the first time.\n"
  118. fi
  119. }