*/*: Drop stable alpha keywords
[gentoo.git] / app-antivirus / clamav / clamav-0.101.2-r1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit autotools eutils flag-o-matic user systemd
7
8 DESCRIPTION="Clam Anti-Virus Scanner"
9 HOMEPAGE="https://www.clamav.net/"
10 SRC_URI="https://www.clamav.net/downloads/production/${P}.tar.gz"
11
12 LICENSE="GPL-2"
13 SLOT="0"
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 )"
17
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= )
26         sys-devel/libtool
27         || ( dev-libs/libpcre2 >dev-libs/libpcre-6 )
28         dev-libs/libmspack
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
35 DEPEND="${CDEPEND}
36         virtual/pkgconfig
37         test? ( dev-libs/check )"
38 RDEPEND="${CDEPEND}
39         selinux? ( sec-policy/selinux-clamav )"
40
41 DOCS=( docs/UserManual.md docs/UserManual )
42 HTML_DOCS=( docs/html )
43
44 PATCHES=(
45         "${FILESDIR}/${PN}-0.101.2-libxml2_pkgconfig.patch" #661328
46         "${FILESDIR}/${PN}-0.101.2-tinfo.patch" #670729
47 )
48
49 pkg_setup() {
50         enewgroup clamav
51         enewuser clamav -1 -1 /dev/null clamav
52 }
53
54 src_prepare() {
55         default
56         eautoconf
57 }
58
59 src_configure() {
60         use elibc_musl && append-ldflags -lfts
61         use ppc64 && append-flags -mminimal-toc
62         use uclibc && export ac_cv_type_error_t=yes
63
64         # according to configure help it should be
65         # $(use_enable xml)
66         # but that does not work
67         # do not add this, since --disable-xml seems to override
68         # --without-xml
69
70         econf \
71                 $(use_enable bzip2) \
72                 $(use_enable clamdtop) \
73                 $(use_enable ipv6) \
74                 $(use_enable milter) \
75                 $(use_enable static-libs static) \
76                 $(use_enable test check) \
77                 $(use_with xml) \
78                 $(use_with iconv) \
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 \
85                 --enable-id-check \
86                 --with-dbdir="${EPREFIX}"/var/lib/clamav \
87                 --with-zlib="${EPREFIX}"/usr \
88                 --disable-llvm
89 }
90
91 src_install() {
92         default
93
94         rm -rf "${ED}"/var/lib/clamav
95         newinitd "${FILESDIR}"/clamd.initd-r6 clamd
96         newconfd "${FILESDIR}"/clamd.conf-r1 clamd
97
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"
102
103         keepdir /var/lib/clamav
104         fowners clamav:clamav /var/lib/clamav
105         keepdir /var/log/clamav
106         fowners clamav:clamav /var/log/clamav
107
108         dodir /etc/logrotate.d
109         insinto /etc/logrotate.d
110         newins "${FILESDIR}"/clamav.logrotate clamav
111
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
129
130         if use milter ; then
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
143                         MILTER_NICELEVEL=19
144                         START_MILTER=no
145                 EOF
146
147                 systemd_newunit "${FILESDIR}/clamav-milter.service-r1" clamav-milter.service
148         fi
149
150         if use doc; then
151            einstalldocs
152            doman docs/man/*.[1-8]
153         fi
154
155         for i in clamd freshclam clamav-milter
156         do
157                 [[ -f "${D}"/etc/"${i}".conf.sample ]] && mv "${D}"/etc/"${i}".conf{.sample,}
158         done
159
160         prune_libtool_files --all
161 }
162
163 src_test() {
164         emake quick-check
165 }
166
167 pkg_postinst() {
168         if use milter ; then
169                 elog "For simple instructions how to setup the clamav-milter read the"
170                 elog "clamav-milter.README.gentoo in /usr/share/doc/${PF}"
171         fi
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"
175         fi
176 }