clamav-0.99.1.ebuild 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit autotools 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. >dev-libs/libpcre-6
  23. !!<app-antivirus/clamav-0.99"
  24. # hard block clamav < 0.99 due to linking problems Bug #567680
  25. # openssl is now *required* see this link as to why
  26. # http://blog.clamav.net/2014/02/introducing-openssl-as-dependency-to.html
  27. DEPEND="${CDEPEND}
  28. virtual/pkgconfig"
  29. RDEPEND="${CDEPEND}
  30. selinux? ( sec-policy/selinux-clamav )"
  31. DOCS=( AUTHORS BUGS ChangeLog FAQ INSTALL NEWS README UPGRADE )
  32. pkg_setup() {
  33. enewgroup clamav
  34. enewuser clamav -1 -1 /dev/null clamav
  35. }
  36. src_prepare() {
  37. use ppc64 && append-flags -mminimal-toc
  38. use uclibc && export ac_cv_type_error_t=yes
  39. epatch "${FILESDIR}"/${PN}-configure-zlib.patch # 604650, fixed in upstream HEAD
  40. eautoconf
  41. }
  42. src_configure() {
  43. econf \
  44. --disable-experimental \
  45. --disable-fanotify \
  46. --enable-id-check \
  47. --with-dbdir="${EPREFIX}"/var/lib/clamav \
  48. --with-system-tommath \
  49. --with-zlib="${EPREFIX}"/usr \
  50. $(use_enable bzip2) \
  51. $(use_enable clamdtop) \
  52. $(use_enable ipv6) \
  53. $(use_enable milter) \
  54. $(use_enable static-libs static) \
  55. $(use_with iconv) \
  56. $(use_with metadata-analysis-api libjson /usr)
  57. }
  58. src_install() {
  59. default
  60. rm -rf "${ED}"/var/lib/clamav
  61. newinitd "${FILESDIR}"/clamd.initd-r6 clamd
  62. newconfd "${FILESDIR}"/clamd.conf-r1 clamd
  63. systemd_dotmpfilesd "${FILESDIR}/tmpfiles.d/clamav.conf"
  64. systemd_newunit "${FILESDIR}/clamd_at.service" "clamd@.service"
  65. systemd_dounit "${FILESDIR}/clamd.service"
  66. systemd_dounit "${FILESDIR}/freshclamd.service"
  67. keepdir /var/lib/clamav
  68. fowners clamav:clamav /var/lib/clamav
  69. keepdir /var/log/clamav
  70. fowners clamav:clamav /var/log/clamav
  71. dodir /etc/logrotate.d
  72. insinto /etc/logrotate.d
  73. newins "${FILESDIR}"/clamav.logrotate clamav
  74. # Modify /etc/{clamd,freshclam}.conf to be usable out of the box
  75. sed -i -e "s:^\(Example\):\# \1:" \
  76. -e "s:.*\(PidFile\) .*:\1 ${EPREFIX}/var/run/clamav/clamd.pid:" \
  77. -e "s:.*\(LocalSocket\) .*:\1 ${EPREFIX}/var/run/clamav/clamd.sock:" \
  78. -e "s:.*\(User\) .*:\1 clamav:" \
  79. -e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamd.log:" \
  80. -e "s:^\#\(LogTime\).*:\1 yes:" \
  81. -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
  82. "${ED}"/etc/clamd.conf.sample || die
  83. sed -i -e "s:^\(Example\):\# \1:" \
  84. -e "s:.*\(PidFile\) .*:\1 ${EPREFIX}/var/run/clamav/freshclam.pid:" \
  85. -e "s:.*\(DatabaseOwner\) .*:\1 clamav:" \
  86. -e "s:^\#\(UpdateLogFile\) .*:\1 ${EPREFIX}/var/log/clamav/freshclam.log:" \
  87. -e "s:^\#\(NotifyClamd\).*:\1 ${EPREFIX}/etc/clamd.conf:" \
  88. -e "s:^\#\(ScriptedUpdates\).*:\1 yes:" \
  89. -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
  90. "${ED}"/etc/freshclam.conf.sample || die
  91. if use milter ; then
  92. # MilterSocket one to include ' /' because there is a 2nd line for
  93. # inet: which we want to leave
  94. dodoc "${FILESDIR}"/clamav-milter.README.gentoo
  95. sed -i -e "s:^\(Example\):\# \1:" \
  96. -e "s:.*\(PidFile\) .*:\1 ${EPREFIX}/var/run/clamav/clamav-milter.pid:" \
  97. -e "s+^\#\(ClamdSocket\) .*+\1 unix:${EPREFIX}/var/run/clamav/clamd.sock+" \
  98. -e "s:.*\(User\) .*:\1 clamav:" \
  99. -e "s+^\#\(MilterSocket\) /.*+\1 unix:${EPREFIX}/var/run/clamav/clamav-milter.sock+" \
  100. -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
  101. -e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamav-milter.log:" \
  102. "${ED}"/etc/clamav-milter.conf.sample || die
  103. cat >> "${ED}"/etc/conf.d/clamd <<-EOF
  104. MILTER_NICELEVEL=19
  105. START_MILTER=no
  106. EOF
  107. systemd_newunit "${FILESDIR}/clamav-milter.service-r1" clamav-milter.service
  108. fi
  109. for i in clamd freshclam clamav-milter
  110. do
  111. [[ -f "${D}"/etc/"${i}".conf.sample ]] && mv "${D}"/etc/"${i}".conf{.sample,}
  112. done
  113. prune_libtool_files --all
  114. }
  115. pkg_postinst() {
  116. if use milter ; then
  117. elog "For simple instructions how to setup the clamav-milter read the"
  118. elog "clamav-milter.README.gentoo in /usr/share/doc/${PF}"
  119. fi
  120. if test -z $(find "${ROOT}"var/lib/clamav -maxdepth 1 -name 'main.c*' -print -quit) ; then
  121. ewarn "You must run freshclam manually to populate the virus database files"
  122. ewarn "before starting clamav for the first time.\n"
  123. fi
  124. }