1 # Copyright 1999-2019 Gentoo Authors
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="https://www.clamav.net/"
10 SRC_URI="https://www.clamav.net/downloads/production/${P}.tar.gz"
14 KEYWORDS="~alpha amd64 arm arm64 hppa ia64 ppc ppc64 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~sparc-solaris ~x86-solaris"
15 IUSE="bzip2 doc clamdtop iconv ipv6 libressl milter metadata-analysis-api selinux static-libs test uclibc xml"
16 RESTRICT="!test? ( test )"
18 CDEPEND="bzip2? ( app-arch/bzip2 )
19 clamdtop? ( sys-libs/ncurses:0 )
20 iconv? ( virtual/libiconv )
21 metadata-analysis-api? ( dev-libs/json-c:= )
22 milter? ( || ( mail-filter/libmilter mail-mta/sendmail ) )
23 >=sys-libs/zlib-1.2.2:=
24 !libressl? ( dev-libs/openssl:0= )
25 libressl? ( dev-libs/libressl:0= )
27 || ( dev-libs/libpcre2 >dev-libs/libpcre-6 )
29 xml? ( dev-libs/libxml2 )
30 elibc_musl? ( sys-libs/fts-standalone )
31 !!<app-antivirus/clamav-0.99"
32 # hard block clamav < 0.99 due to linking problems Bug #567680
33 # openssl is now *required* see this link as to why
34 # https://blog.clamav.net/2014/02/introducing-openssl-as-dependency-to.html
37 test? ( dev-libs/check )"
39 selinux? ( sec-policy/selinux-clamav )"
41 DOCS=( docs/UserManual.md docs/UserManual )
42 HTML_DOCS=( docs/html )
45 "${FILESDIR}/${PN}-0.101.2-libxml2_pkgconfig.patch" #661328
46 "${FILESDIR}/${PN}-0.101.2-tinfo.patch" #670729
51 enewuser clamav -1 -1 /dev/null clamav
60 use elibc_musl && append-ldflags -lfts
61 use ppc64 && append-flags -mminimal-toc
62 use uclibc && export ac_cv_type_error_t=yes
64 # according to configure help it should be
66 # but that does not work
67 # do not add this, since --disable-xml seems to override
72 $(use_enable clamdtop) \
74 $(use_enable milter) \
75 $(use_enable static-libs static) \
76 $(use_enable test check) \
79 $(use_with metadata-analysis-api libjson /usr) \
80 --with-system-libmspack \
81 --cache-file="${S}"/config.cache \
82 --disable-experimental \
83 --disable-gcc-vcheck \
84 --disable-zlib-vcheck \
86 --with-dbdir="${EPREFIX}"/var/lib/clamav \
87 --with-zlib="${EPREFIX}"/usr \
94 rm -rf "${ED}"/var/lib/clamav
95 newinitd "${FILESDIR}"/clamd.initd-r6 clamd
96 newconfd "${FILESDIR}"/clamd.conf-r1 clamd
98 systemd_dotmpfilesd "${FILESDIR}/tmpfiles.d/clamav.conf"
99 systemd_newunit "${FILESDIR}/clamd_at.service" "clamd@.service"
100 systemd_dounit "${FILESDIR}/clamd.service"
101 systemd_dounit "${FILESDIR}/freshclamd.service"
103 keepdir /var/lib/clamav
104 fowners clamav:clamav /var/lib/clamav
105 keepdir /var/log/clamav
106 fowners clamav:clamav /var/log/clamav
108 dodir /etc/logrotate.d
109 insinto /etc/logrotate.d
110 newins "${FILESDIR}"/clamav.logrotate clamav
112 # Modify /etc/{clamd,freshclam}.conf to be usable out of the box
113 sed -i -e "s:^\(Example\):\# \1:" \
114 -e "s:.*\(PidFile\) .*:\1 ${EPREFIX}/var/run/clamav/clamd.pid:" \
115 -e "s:.*\(LocalSocket\) .*:\1 ${EPREFIX}/var/run/clamav/clamd.sock:" \
116 -e "s:.*\(User\) .*:\1 clamav:" \
117 -e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamd.log:" \
118 -e "s:^\#\(LogTime\).*:\1 yes:" \
119 -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
120 "${ED}"/etc/clamd.conf.sample || die
121 sed -i -e "s:^\(Example\):\# \1:" \
122 -e "s:.*\(PidFile\) .*:\1 ${EPREFIX}/var/run/clamav/freshclam.pid:" \
123 -e "s:.*\(DatabaseOwner\) .*:\1 clamav:" \
124 -e "s:^\#\(UpdateLogFile\) .*:\1 ${EPREFIX}/var/log/clamav/freshclam.log:" \
125 -e "s:^\#\(NotifyClamd\).*:\1 ${EPREFIX}/etc/clamd.conf:" \
126 -e "s:^\#\(ScriptedUpdates\).*:\1 yes:" \
127 -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
128 "${ED}"/etc/freshclam.conf.sample || die
131 # MilterSocket one to include ' /' because there is a 2nd line for
132 # inet: which we want to leave
133 ##dodoc "${FILESDIR}"/clamav-milter.README.gentoo
134 sed -i -e "s:^\(Example\):\# \1:" \
135 -e "s:.*\(PidFile\) .*:\1 ${EPREFIX}/var/run/clamav/clamav-milter.pid:" \
136 -e "s+^\#\(ClamdSocket\) .*+\1 unix:${EPREFIX}/var/run/clamav/clamd.sock+" \
137 -e "s:.*\(User\) .*:\1 clamav:" \
138 -e "s+^\#\(MilterSocket\) /.*+\1 unix:${EPREFIX}/var/run/clamav/clamav-milter.sock+" \
139 -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
140 -e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamav-milter.log:" \
141 "${ED}"/etc/clamav-milter.conf.sample || die
142 cat >> "${ED}"/etc/conf.d/clamd <<-EOF
147 systemd_newunit "${FILESDIR}/clamav-milter.service-r1" clamav-milter.service
152 doman docs/man/*.[1-8]
155 for i in clamd freshclam clamav-milter
157 [[ -f "${D}"/etc/"${i}".conf.sample ]] && mv "${D}"/etc/"${i}".conf{.sample,}
160 prune_libtool_files --all
169 elog "For simple instructions how to setup the clamav-milter read the"
170 elog "clamav-milter.README.gentoo in /usr/share/doc/${PF}"
172 if test -z $(find "${ROOT}"var/lib/clamav -maxdepth 1 -name 'main.c*' -print -quit) ; then
173 ewarn "You must run freshclam manually to populate the virus database files"
174 ewarn "before starting clamav for the first time.\n"