Gentoo Archives: gentoo-commits

From: Thomas Raschbacher <lordvan@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-antivirus/clamav/files/, app-antivirus/clamav/
Date: Sat, 16 Oct 2021 12:26:14
Message-Id: 1634387160.5d5f8b5e7069bae69c6158f83bf3f581f9244a84.lordvan@gentoo
1 commit: 5d5f8b5e7069bae69c6158f83bf3f581f9244a84
2 Author: Thomas Raschbacher <lordvan <AT> gentoo <DOT> org>
3 AuthorDate: Sat Oct 16 12:24:19 2021 +0000
4 Commit: Thomas Raschbacher <lordvan <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 16 12:26:00 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5d5f8b5e
7
8 app-antivirus/clamav: new version (new build system and USE flags)
9
10 Closes: https://bugs.gentoo.org/811498
11 Package-Manager: Portage-3.0.28, Repoman-3.0.3
12 Signed-off-by: Thomas Raschbacher <lordvan <AT> gentoo.org>
13
14 app-antivirus/clamav/Manifest | 1 +
15 app-antivirus/clamav/clamav-0.104.0.ebuild | 210 +++++++++++++++++++++
16 .../files/clamav-0.104.0-ncurses_detection.patch | 27 +++
17 app-antivirus/clamav/files/clamav-milter.initd | 34 ++++
18 .../clamav/files/clamav-milter.service-0.104.0 | 13 ++
19 app-antivirus/clamav/files/clamd.initd | 33 ++++
20 .../clamav/files/clamd_at.service-0.104.0 | 12 ++
21 app-antivirus/clamav/files/clamonacc.initd | 18 ++
22 app-antivirus/clamav/files/freshclam.initd | 8 +
23 app-antivirus/clamav/metadata.xml | 2 +
24 10 files changed, 358 insertions(+)
25
26 diff --git a/app-antivirus/clamav/Manifest b/app-antivirus/clamav/Manifest
27 index 8705b5f2668..48eb3537bac 100644
28 --- a/app-antivirus/clamav/Manifest
29 +++ b/app-antivirus/clamav/Manifest
30 @@ -1 +1,2 @@
31 DIST clamav-0.103.3.tar.gz 13389239 BLAKE2B 1846cceed39fbd48fcf973d05a57901cf6f9ccdbb4d7eae501e712d84ab4d0a662e4477696aa6a1446116db85a89603428d7092a55e18f7acb805016d3cd5431 SHA512 c2ee24a6f63735c064140aa5baa347d51e8240b2f7eced3480d05435202aedd481fa7057fd40ecbc2e93a62fe8b0cefb574d8accdf9acede643ffbe0d396686f
32 +DIST clamav-0.104.0.tar.gz 11896747 BLAKE2B c3ca32c1277052301a8bff94fec66a2df8f589bc9a673a00d0f45aaf9d8fd23e8bb87dde787d4188a6318d6677c3364e377ccec16d8e44667430713ce7e2a78d SHA512 7a052e6310ef92068acc384d10a64eed6d54d2d408d203dab92defbb1a276e8a193a2096a8028c8982323ba0be83d25602f026aeffa056878ce36aa325c0046c
33
34 diff --git a/app-antivirus/clamav/clamav-0.104.0.ebuild b/app-antivirus/clamav/clamav-0.104.0.ebuild
35 new file mode 100644
36 index 00000000000..2869e22a678
37 --- /dev/null
38 +++ b/app-antivirus/clamav/clamav-0.104.0.ebuild
39 @@ -0,0 +1,210 @@
40 +# Copyright 1999-2021 Gentoo Authors
41 +# Distributed under the terms of the GNU General Public License v2
42 +
43 +EAPI=7
44 +
45 +CMAKE_ECLASS=cmake
46 +inherit cmake flag-o-matic systemd tmpfiles
47 +
48 +DESCRIPTION="Clam Anti-Virus Scanner"
49 +HOMEPAGE="https://www.clamav.net/"
50 +SRC_URI="https://www.clamav.net/downloads/production/${P}.tar.gz"
51 +
52 +LICENSE="GPL-2"
53 +SLOT="0"
54 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~sparc-solaris ~x86-solaris"
55 +IUSE="doc clamonacc clamapp libclamav-only milter rar selinux systemd test uclibc"
56 +
57 +REQUIRED_USE="libclamav-only? ( !clamonacc !clamapp !milter )
58 + clamonacc? ( clamapp )
59 + milter? ( clamapp )"
60 +
61 +RESTRICT="!test? ( test )"
62 +
63 +# Require acct-{user,group}/clamav at build time so that we can set
64 +# the permissions on /var/lib/clamav in src_install rather than in
65 +# pkg_postinst; calling "chown" on the live filesystem scares me.
66 +CDEPEND="acct-group/clamav
67 + acct-user/clamav
68 + dev-libs/libltdl
69 + dev-libs/libmspack
70 + dev-libs/libpcre2
71 + >=sys-libs/zlib-1.2.2:=
72 + app-arch/bzip2
73 + clamapp? ( sys-libs/ncurses:0 net-misc/curl dev-libs/json-c:= )
74 + elibc_musl? ( sys-libs/fts-standalone )
75 + virtual/libiconv
76 + !libclamav-only? ( net-misc/curl )
77 + dev-libs/openssl:0=
78 + milter? ( || ( mail-filter/libmilter mail-mta/sendmail ) )
79 + dev-libs/libxml2
80 + rar? ( app-arch/unrar )
81 + test? ( dev-python/pytest )"
82 +# TODO: there is no way to use this with the new build system instead of the bundled one
83 +# dev-libs/tomsfastmath
84 +
85 +BDEPEND=">=dev-util/cmake-3.14
86 + virtual/pkgconfig"
87 +
88 +DEPEND="${CDEPEND}
89 + clamapp? ( dev-libs/json-c:* )
90 + test? ( dev-libs/check )"
91 +RDEPEND="${CDEPEND}
92 + selinux? ( sec-policy/selinux-clamav )"
93 +
94 +PATCHES=(
95 + "${FILESDIR}/${PN}-0.104.0-ncurses_detection.patch"
96 +)
97 +
98 +src_configure() {
99 + use elibc_musl && append-ldflags -lfts
100 + use ppc64 && append-flags -mminimal-toc
101 + use uclibc && export ac_cv_type_error_t=yes
102 +
103 + local mycmakeargs=(
104 + -DDATABASE_DIRECTORY="${EPREFIX}"/var/lib/clamav
105 + -DAPP_CONFIG_DIRECTORY="${EPREFIX}"/etc/clamav
106 + -DENABLE_EXPERIMENTAL=OFF
107 + -DENABLE_JSON_SHARED=ON
108 + -DENABLE_APP=$(usex clamapp ON OFF)
109 + -DENABLE_MILTER=$(usex milter ON OFF)
110 + -DENABLE_CLAMONACC=$(usex clamonacc ON OFF)
111 + -DCLAMAV_USER="clamav"
112 + -DCLAMAV_GROUP="clamav"
113 + -DBYTECODE_RUNTIME=interpreter
114 + -DOPTIMIZE=ON
115 + -DENABLE_EXTERNAL_MSPACK=ON
116 + -DENABLE_MAN_PAGES=ON
117 + -DENABLE_UNRAR=$(usex rar ON OFF)
118 + -DENABLE_TESTS=$(usex test ON OFF)
119 + -DENABLE_STATIC_LIB=OFF
120 + -DENABLE_SHARED_LIB=ON
121 + -DENABLE_SYSTEMD=$(usex systemd ON OFF)
122 + )
123 + cmake_src_configure
124 +}
125 +
126 +src_install() {
127 + cmake_src_install
128 +
129 + # init scripts
130 + newinitd "${FILESDIR}/clamd.initd" clamd
131 + newinitd "${FILESDIR}/freshclam.initd" freshclam
132 + use clamonacc && \
133 + newinitd "${FILESDIR}/clamonacc.initd" clamonacc
134 + use milter && \
135 + newinitd "${FILESDIR}/clamav-milter.initd" clamav-milter
136 +
137 + rm -rf "${ED}"/var/lib/clamav || die
138 +
139 + if ! use libclamav-only ; then
140 + if use systemd; then
141 + # The tmpfiles entry is behind USE=systemd because the
142 + # upstream OpenRC service files should (and do) ensure that
143 + # the directories they need exist and have the correct
144 + # permissions without the help of opentmpfiles. There are
145 + # years-old root exploits in opentmpfiles, the design is
146 + # fundamentally flawed, and the maintainer is not up to
147 + # the task of fixing it.
148 + dotmpfiles "${FILESDIR}/tmpfiles.d/clamav.conf"
149 + systemd_newunit "${FILESDIR}/clamd_at.service-0.104.0" "clamd@.service"
150 + systemd_dounit "${FILESDIR}/clamd.service"
151 + systemd_newunit "${FILESDIR}/freshclamd.service-r1" \
152 + "freshclamd.service"
153 + fi
154 +
155 + # Modify /etc/{clamd,freshclam}.conf to be usable out of the box
156 + sed -e "s:^\(Example\):\# \1:" \
157 + -e "s/^#\(PidFile .*\)/\1/" \
158 + -e "s/^#\(LocalSocket .*\)/\1/" \
159 + -e "s/^#\(User .*\)/\1/" \
160 + -e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamd.log:" \
161 + -e "s:^\#\(LogTime\).*:\1 yes:" \
162 + -e "s/^#\(DatabaseDirectory .*\)/\1/" \
163 + "${ED}"/etc/clamav/clamd.conf.sample > \
164 + "${ED}"/etc/clamav/clamd.conf || die
165 +
166 + sed -e "s:^\(Example\):\# \1:" \
167 + -e "s/^#\(PidFile .*\)/\1/" \
168 + -e "s/^#\(DatabaseOwner .*\)/\1/" \
169 + -e "s:^\#\(UpdateLogFile\) .*:\1 ${EPREFIX}/var/log/clamav/freshclam.log:" \
170 + -e "s:^\#\(NotifyClamd\).*:\1 ${EPREFIX}/etc/clamd.conf:" \
171 + -e "s:^\#\(ScriptedUpdates\).*:\1 yes:" \
172 + -e "s/^#\(DatabaseDirectory .*\)/\1/" \
173 + "${ED}"/etc/clamav/freshclam.conf.sample > \
174 + "${ED}"/etc/clamav/freshclam.conf || die
175 +
176 + if use milter ; then
177 + # Note: only keep the "unix" ClamdSocket and MilterSocket!
178 + sed -e "s:^\(Example\):\# \1:" \
179 + -e "s/^#\(PidFile .*\)/\1/" \
180 + -e "s/^#\(ClamdSocket unix:.*\)/\1/" \
181 + -e "s/^#\(User .*\)/\1/" \
182 + -e "s/^#\(MilterSocket unix:.*\)/\1/" \
183 + -e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamav-milter.log:" \
184 + "${ED}"/etc/clamav/clamav-milter.conf.sample > \
185 + "${ED}"/etc/clamav/clamav-milter.conf || die
186 +
187 + systemd_newunit "${FILESDIR}/clamav-milter.service-0.104.0" clamav-milter.service
188 + fi
189 +
190 + local i
191 + for i in clamd freshclam clamav-milter
192 + do
193 + if [[ -f "${ED}"/etc/"${i}".conf.sample ]]; then
194 + mv "${ED}"/etc/"${i}".conf{.sample,} || die
195 + fi
196 + done
197 +
198 + # These both need to be writable by the clamav user.
199 + # TODO: use syslog by default; that's what it's for.
200 + diropts -o clamav -g clamav
201 + keepdir /var/lib/clamav
202 + keepdir /var/log/clamav
203 + fi
204 +
205 + if use doc ; then
206 + local HTML_DOCS=( docs/html/. )
207 + einstalldocs
208 +
209 + if ! use libclamav-only ; then
210 + doman docs/man/*.[1-8]
211 + fi
212 + fi
213 +
214 + find "${ED}" -name '*.la' -delete || die
215 +}
216 +
217 +src_test() {
218 + if use libclamav-only ; then
219 + ewarn "Test target not available when USE=libclamav-only is set, skipping tests ..."
220 + return 0
221 + fi
222 +
223 + emake quick-check
224 +}
225 +
226 +pkg_postinst() {
227 + if ! use libclamav-only ; then
228 + if use systemd ; then
229 + tmpfiles_process clamav.conf
230 + fi
231 + fi
232 +
233 + if use milter ; then
234 + elog "For simple instructions how to setup the clamav-milter read the"
235 + elog "clamav-milter.README.gentoo in /usr/share/doc/${PF}"
236 + fi
237 +
238 + local databases=( "${EROOT}"/var/lib/clamav/main.c[lv]d )
239 + if [[ ! -f "${databases}" ]] ; then
240 + ewarn "You must run freshclam manually to populate the virus database"
241 + ewarn "before starting clamav for the first time."
242 + fi
243 +
244 + ewarn "This version of ClamAV provides separate OpenRC services"
245 + ewarn "for clamd, freshclam, clamav-milter, and clamonacc. The"
246 + ewarn "clamd service now starts only the clamd daemon itself. You"
247 + ewarn "should add freshclam (and perhaps clamav-milter) to any"
248 + ewarn "runlevels that previously contained clamd."
249 +}
250
251 diff --git a/app-antivirus/clamav/files/clamav-0.104.0-ncurses_detection.patch b/app-antivirus/clamav/files/clamav-0.104.0-ncurses_detection.patch
252 new file mode 100644
253 index 00000000000..aa403a90bab
254 --- /dev/null
255 +++ b/app-antivirus/clamav/files/clamav-0.104.0-ncurses_detection.patch
256 @@ -0,0 +1,27 @@
257 +From cd99490efb82b66c75e92fab3ff97c480bfc9cf9 Mon Sep 17 00:00:00 2001
258 +From: Luca Barbato <lu_zero@g.o>
259 +Date: Sat, 16 Oct 2021 10:56:22 +0200
260 +Subject: [PATCH] Use all the link line from ncurses pkg-config
261 +
262 +Otherwise it would fail at link time if ncurses has a stand alone tinfo library.
263 +---
264 + cmake/FindCURSES.cmake | 6 +-----
265 + 1 file changed, 1 insertion(+), 5 deletions(-)
266 +
267 +diff --git a/cmake/FindCURSES.cmake b/cmake/FindCURSES.cmake
268 +index 35d4a570f6..528211c45c 100644
269 +--- a/cmake/FindCURSES.cmake
270 ++++ b/cmake/FindCURSES.cmake
271 +@@ -58,11 +58,7 @@ if(NCURSES_NOT_FOUND EQUAL -1)
272 + set(HAVE_LIBNCURSES 1)
273 + set(CURSES_INCLUDE "<ncurses.h>")
274 +
275 +- find_library(CURSES_LIBRARY
276 +- NAMES ncurses
277 +- PATHS ${PC_NCurses_LIBRARY_DIRS}
278 +- )
279 +-
280 ++ set(CURSES_LIBRARY ${PC_NCurses_LINK_LIBRARIES})
281 + set(CURSES_VERSION ${PC_NCurses_VERSION})
282 +
283 + include(FindPackageHandleStandardArgs)
284
285 diff --git a/app-antivirus/clamav/files/clamav-milter.initd b/app-antivirus/clamav/files/clamav-milter.initd
286 new file mode 100755
287 index 00000000000..049d908155d
288 --- /dev/null
289 +++ b/app-antivirus/clamav/files/clamav-milter.initd
290 @@ -0,0 +1,34 @@
291 +#!/sbin/openrc-run
292 +
293 +# Note: the "Foreground" option in clamav-milter.conf MUST
294 +# be set to "no".
295 +command="/usr/sbin/clamav-milter"
296 +
297 +# For now, must be manually synchronized with the PidFile
298 +# variable in clamav-milter.conf.
299 +#
300 +# https://bugzilla.clamav.net/show_bug.cgi?id=12595
301 +#
302 +pidfile="/run/${RC_SVCNAME}.pid"
303 +
304 +depend() {
305 + # The milter can successfully launch without clamd, but it's not a
306 + # great user experience to have the milter start accepting requests
307 + # that it can't process. The "use" dependency below will start clamd
308 + # before clamav-milter, so long as clamd is also present this runlevel.
309 + use clamd
310 +}
311 +
312 +start_pre() {
313 + # This exists to support the (disabled) default MilterSocket setting
314 + # within clamav-milter.conf. The "clamav" user and group agree with
315 + # the (disabled) default "User" and "MilterSocketGroup" settings.
316 + #
317 + # Creating this directory is harmless even when a local socket is
318 + # not used. In fact, the clamd service that we depend on should
319 + # create it as well, to hold its own local socket (if enabled).
320 + checkpath --directory \
321 + --mode 0755 \
322 + --owner clamav:clamav \
323 + "/run/clamav"
324 +}
325
326 diff --git a/app-antivirus/clamav/files/clamav-milter.service-0.104.0 b/app-antivirus/clamav/files/clamav-milter.service-0.104.0
327 new file mode 100644
328 index 00000000000..68acf0695ce
329 --- /dev/null
330 +++ b/app-antivirus/clamav/files/clamav-milter.service-0.104.0
331 @@ -0,0 +1,13 @@
332 +[Unit]
333 +Description=Milter module for the ClamAV scanner
334 +After=nss-lookup.target network.target
335 +Before=sendmail.service
336 +Before=postfix.service
337 +
338 +[Service]
339 +Type=forking
340 +PIDFile=/run/clamav/clamav-milter.pid
341 +ExecStart=/usr/sbin/clamav-milter -c /etc/clamav/clamav-milter.conf
342 +
343 +[Install]
344 +WantedBy=multi-user.target
345
346 diff --git a/app-antivirus/clamav/files/clamd.initd b/app-antivirus/clamav/files/clamd.initd
347 new file mode 100755
348 index 00000000000..efc01efc41b
349 --- /dev/null
350 +++ b/app-antivirus/clamav/files/clamd.initd
351 @@ -0,0 +1,33 @@
352 +#!/sbin/openrc-run
353 +
354 +# Note: the "Foreground" option in clamd.conf must be set to "no"
355 +command="/usr/sbin/clamd"
356 +extra_started_commands="reload"
357 +
358 +# For now, must be manually synchronized with the PidFile variable
359 +# in clamd.conf.
360 +#
361 +# https://bugzilla.clamav.net/show_bug.cgi?id=12595
362 +#
363 +pidfile="/run/${RC_SVCNAME}.pid"
364 +
365 +start_pre() {
366 + # This exists to support the (disabled) default LocalSocket setting
367 + # within clamd.conf. The "clamav" user and group agree with the
368 + # (disabled) default "User" and "LocalSocketGroup" settings in
369 + # clamd.conf. And everything here agrees with the
370 + # clamav-daemon.socket systemd service.
371 + #
372 + # Creating this directory is harmless even when a local socket is
373 + # not used.
374 + checkpath --directory \
375 + --mode 0755 \
376 + --owner clamav:clamav \
377 + "/run/clamav"
378 +}
379 +
380 +reload() {
381 + ebegin "Reloading ${RC_SVCNAME}"
382 + "/usr/bin/clamdscan" --reload
383 + eend $?
384 +}
385
386 diff --git a/app-antivirus/clamav/files/clamd_at.service-0.104.0 b/app-antivirus/clamav/files/clamd_at.service-0.104.0
387 new file mode 100644
388 index 00000000000..5ab51e7fccf
389 --- /dev/null
390 +++ b/app-antivirus/clamav/files/clamd_at.service-0.104.0
391 @@ -0,0 +1,12 @@
392 +[Unit]
393 +Description=clamd scanner (%i) daemon
394 +After=nss-lookup.target network.target
395 +
396 +[Service]
397 +Type=forking
398 +ExecStart=/usr/sbin/clamd -c /etc/clamav/clamd%i.conf
399 +Restart=on-failure
400 +PrivateTmp=true
401 +
402 +[Install]
403 +WantedBy=multi-user.target
404
405 diff --git a/app-antivirus/clamav/files/clamonacc.initd b/app-antivirus/clamav/files/clamonacc.initd
406 new file mode 100755
407 index 00000000000..f625707b171
408 --- /dev/null
409 +++ b/app-antivirus/clamav/files/clamonacc.initd
410 @@ -0,0 +1,18 @@
411 +#!/sbin/openrc-run
412 +
413 +command="/usr/sbin/clamonacc"
414 +pidfile="/run/${RC_SVCNAME}.pid"
415 +
416 +# clamonacc doesn't support a PID file at the moment, so we
417 +# run it in the foreground and let OpenRC background it.
418 +#
419 +# https://bugzilla.clamav.net/show_bug.cgi?id=12595
420 +#
421 +command_args="--foreground"
422 +command_background=true
423 +
424 +depend() {
425 + # Unlike the milter, the on-access scanner will simply fail to start
426 + # until clamd is available.
427 + need clamd
428 +}
429
430 diff --git a/app-antivirus/clamav/files/freshclam.initd b/app-antivirus/clamav/files/freshclam.initd
431 new file mode 100755
432 index 00000000000..415d94a8766
433 --- /dev/null
434 +++ b/app-antivirus/clamav/files/freshclam.initd
435 @@ -0,0 +1,8 @@
436 +#!/sbin/openrc-run
437 +
438 +command="/usr/bin/freshclam"
439 +pidfile="/run/${RC_SVCNAME}.pid"
440 +
441 +# Ignore the value of "PidFile" set in freshclam.conf.
442 +command_args="-p ${pidfile}"
443 +command_args_background="--daemon"
444
445 diff --git a/app-antivirus/clamav/metadata.xml b/app-antivirus/clamav/metadata.xml
446 index 799ee7cad29..4c41e164aee 100644
447 --- a/app-antivirus/clamav/metadata.xml
448 +++ b/app-antivirus/clamav/metadata.xml
449 @@ -12,12 +12,14 @@
450 </maintainer>
451
452 <use>
453 + <flag name="clamapp">Build applications (clamscan, clamd, clamdscan, clamonacc(also has it's own USE flag), sigtool, clambc, clamav-milter(also requires milter USE flag), clamdtop, clamsubmit, clamconf).</flag>
454 <flag name="clamonacc">Build the clamonacc on-access scanner</flag>
455 <flag name="clamdtop">A Top like tool which shows what clamd is currently scanning amongst other things</flag>
456 <flag name="clamsubmit">A tool to submit false positives / negatives</flag>
457 <flag name="libclamav-only">Bypass building of libfreshclam and the ClamAV CLI applications.</flag>
458 <flag name="metadata-analysis-api">Enables collection of file property metadata using ClamAV API for analysis by ClamAV bytecode programs.</flag>
459 <flag name="xml">DMG and XAR support</flag>
460 + <flag name="rar">RAR support</flag>
461 </use>
462 <upstream>
463 <remote-id type="sourceforge">clamav</remote-id>