net-dns/dnsmasq: cleanup vulnerable wrt bug #632692
[gentoo.git] / app-antivirus / clamav / clamav-0.99.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 inherit autotools eutils flag-o-matic user systemd
7
8 DESCRIPTION="Clam Anti-Virus Scanner"
9 HOMEPAGE="http://www.clamav.net/"
10 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
11
12 LICENSE="GPL-2"
13 SLOT="0"
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"
16
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 ) )
22         dev-libs/libtommath
23         >=sys-libs/zlib-1.2.2
24         !libressl? ( dev-libs/openssl:0= )
25         libressl? ( dev-libs/libressl:0= )
26         sys-devel/libtool
27         >dev-libs/libpcre-6
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
32 DEPEND="${CDEPEND}
33         virtual/pkgconfig"
34 RDEPEND="${CDEPEND}
35         selinux? ( sec-policy/selinux-clamav )"
36
37 DOCS=( AUTHORS BUGS ChangeLog FAQ INSTALL NEWS README UPGRADE )
38
39 pkg_setup() {
40         enewgroup clamav
41         enewuser clamav -1 -1 /dev/null clamav
42 }
43
44 src_prepare() {
45         use ppc64 && append-flags -mminimal-toc
46         use uclibc && export ac_cv_type_error_t=yes
47
48         epatch "${FILESDIR}"/${P}-zlib.patch # 604650, fixed in upstream HEAD
49         eautoconf
50 }
51
52 src_configure() {
53         econf \
54                 --disable-experimental \
55                 --disable-fanotify \
56                 --disable-zlib-vcheck \
57                 --enable-id-check \
58                 --with-dbdir="${EPREFIX}"/var/lib/clamav \
59                 --with-system-tommath \
60                 --with-zlib="${EPREFIX}"/usr \
61                 $(use_enable bzip2) \
62                 $(use_enable clamdtop) \
63                 $(use_enable ipv6) \
64                 $(use_enable milter) \
65                 $(use_enable static-libs static) \
66                 $(use_with iconv) \
67                 $(use_with metadata-analysis-api libjson /usr)
68 }
69
70 src_install() {
71         default
72
73         rm -rf "${ED}"/var/lib/clamav
74         newinitd "${FILESDIR}"/clamd.initd-r6 clamd
75         newconfd "${FILESDIR}"/clamd.conf-r1 clamd
76
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"
81
82         keepdir /var/lib/clamav
83         fowners clamav:clamav /var/lib/clamav
84         keepdir /var/log/clamav
85         fowners clamav:clamav /var/log/clamav
86
87         dodir /etc/logrotate.d
88         insinto /etc/logrotate.d
89         newins "${FILESDIR}"/clamav.logrotate clamav
90
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
108
109         if use milter ; then
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
122                         MILTER_NICELEVEL=19
123                         START_MILTER=no
124                 EOF
125
126                 systemd_newunit "${FILESDIR}/clamav-milter.service-r1" clamav-milter.service
127         fi
128
129         for i in clamd freshclam clamav-milter
130         do
131                 [[ -f "${D}"/etc/"${i}".conf.sample ]] && mv "${D}"/etc/"${i}".conf{.sample,}
132         done
133
134         prune_libtool_files --all
135 }
136
137 pkg_postinst() {
138         if use milter ; then
139                 elog "For simple instructions how to setup the clamav-milter read the"
140                 elog "clamav-milter.README.gentoo in /usr/share/doc/${PF}"
141         fi
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"
145         fi
146 }