1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools eutils flag-o-matic user systemd
8 DESCRIPTION="Clam Anti-Virus Scanner"
9 HOMEPAGE="http://www.clamav.net/"
10 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
14 KEYWORDS="alpha amd64 ~arm hppa ia64 ppc ppc64 sparc x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~sparc-solaris ~x86-solaris"
15 IUSE="bzip2 clamdtop iconv ipv6 libressl milter metadata-analysis-api selinux static-libs uclibc"
17 CDEPEND="bzip2? ( app-arch/bzip2 )
18 clamdtop? ( sys-libs/ncurses:0 )
19 iconv? ( virtual/libiconv )
20 metadata-analysis-api? ( dev-libs/json-c:= )
21 milter? ( || ( mail-filter/libmilter mail-mta/sendmail ) )
24 !libressl? ( dev-libs/openssl:0= )
25 libressl? ( dev-libs/libressl:0= )
28 !!<app-antivirus/clamav-0.99"
29 # hard block clamav < 0.99 due to linking problems Bug #567680
30 # openssl is now *required* see this link as to why
31 # http://blog.clamav.net/2014/02/introducing-openssl-as-dependency-to.html
35 selinux? ( sec-policy/selinux-clamav )"
37 DOCS=( AUTHORS BUGS ChangeLog FAQ INSTALL NEWS README UPGRADE )
41 enewuser clamav -1 -1 /dev/null clamav
45 use ppc64 && append-flags -mminimal-toc
46 use uclibc && export ac_cv_type_error_t=yes
48 epatch "${FILESDIR}"/${P}-zlib.patch # 604650, fixed in upstream HEAD
54 --disable-experimental \
56 --disable-zlib-vcheck \
58 --with-dbdir="${EPREFIX}"/var/lib/clamav \
59 --with-system-tommath \
60 --with-zlib="${EPREFIX}"/usr \
62 $(use_enable clamdtop) \
64 $(use_enable milter) \
65 $(use_enable static-libs static) \
67 $(use_with metadata-analysis-api libjson /usr)
73 rm -rf "${ED}"/var/lib/clamav
74 newinitd "${FILESDIR}"/clamd.initd-r6 clamd
75 newconfd "${FILESDIR}"/clamd.conf-r1 clamd
77 systemd_dotmpfilesd "${FILESDIR}/tmpfiles.d/clamav.conf"
78 systemd_newunit "${FILESDIR}/clamd_at.service" "clamd@.service"
79 systemd_dounit "${FILESDIR}/clamd.service"
80 systemd_dounit "${FILESDIR}/freshclamd.service"
82 keepdir /var/lib/clamav
83 fowners clamav:clamav /var/lib/clamav
84 keepdir /var/log/clamav
85 fowners clamav:clamav /var/log/clamav
87 dodir /etc/logrotate.d
88 insinto /etc/logrotate.d
89 newins "${FILESDIR}"/clamav.logrotate clamav
91 # Modify /etc/{clamd,freshclam}.conf to be usable out of the box
92 sed -i -e "s:^\(Example\):\# \1:" \
93 -e "s:.*\(PidFile\) .*:\1 ${EPREFIX}/var/run/clamav/clamd.pid:" \
94 -e "s:.*\(LocalSocket\) .*:\1 ${EPREFIX}/var/run/clamav/clamd.sock:" \
95 -e "s:.*\(User\) .*:\1 clamav:" \
96 -e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamd.log:" \
97 -e "s:^\#\(LogTime\).*:\1 yes:" \
98 -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
99 "${ED}"/etc/clamd.conf.sample || die
100 sed -i -e "s:^\(Example\):\# \1:" \
101 -e "s:.*\(PidFile\) .*:\1 ${EPREFIX}/var/run/clamav/freshclam.pid:" \
102 -e "s:.*\(DatabaseOwner\) .*:\1 clamav:" \
103 -e "s:^\#\(UpdateLogFile\) .*:\1 ${EPREFIX}/var/log/clamav/freshclam.log:" \
104 -e "s:^\#\(NotifyClamd\).*:\1 ${EPREFIX}/etc/clamd.conf:" \
105 -e "s:^\#\(ScriptedUpdates\).*:\1 yes:" \
106 -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
107 "${ED}"/etc/freshclam.conf.sample || die
110 # MilterSocket one to include ' /' because there is a 2nd line for
111 # inet: which we want to leave
112 dodoc "${FILESDIR}"/clamav-milter.README.gentoo
113 sed -i -e "s:^\(Example\):\# \1:" \
114 -e "s:.*\(PidFile\) .*:\1 ${EPREFIX}/var/run/clamav/clamav-milter.pid:" \
115 -e "s+^\#\(ClamdSocket\) .*+\1 unix:${EPREFIX}/var/run/clamav/clamd.sock+" \
116 -e "s:.*\(User\) .*:\1 clamav:" \
117 -e "s+^\#\(MilterSocket\) /.*+\1 unix:${EPREFIX}/var/run/clamav/clamav-milter.sock+" \
118 -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
119 -e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamav-milter.log:" \
120 "${ED}"/etc/clamav-milter.conf.sample || die
121 cat >> "${ED}"/etc/conf.d/clamd <<-EOF
126 systemd_newunit "${FILESDIR}/clamav-milter.service-r1" clamav-milter.service
129 for i in clamd freshclam clamav-milter
131 [[ -f "${D}"/etc/"${i}".conf.sample ]] && mv "${D}"/etc/"${i}".conf{.sample,}
134 prune_libtool_files --all
139 elog "For simple instructions how to setup the clamav-milter read the"
140 elog "clamav-milter.README.gentoo in /usr/share/doc/${PF}"
142 if test -z $(find "${ROOT}"var/lib/clamav -maxdepth 1 -name 'main.c*' -print -quit) ; then
143 ewarn "You must run freshclam manually to populate the virus database files"
144 ewarn "before starting clamav for the first time.\n"