summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Raschbacher <lordvan@gentoo.org>2021-10-16 14:24:19 +0200
committerThomas Raschbacher <lordvan@gentoo.org>2021-10-16 14:26:00 +0200
commit5d5f8b5e7069bae69c6158f83bf3f581f9244a84 (patch)
tree7855825addaa5cc0dcad53a33d3370239e6cc087 /app-antivirus
parentsci-libs/tensorflow: Fix system protobuf (diff)
downloadgentoo-5d5f8b5e7069bae69c6158f83bf3f581f9244a84.tar.gz
gentoo-5d5f8b5e7069bae69c6158f83bf3f581f9244a84.tar.bz2
gentoo-5d5f8b5e7069bae69c6158f83bf3f581f9244a84.zip
app-antivirus/clamav: new version (new build system and USE flags)
Closes: https://bugs.gentoo.org/811498 Package-Manager: Portage-3.0.28, Repoman-3.0.3 Signed-off-by: Thomas Raschbacher <lordvan@gentoo.org>
Diffstat (limited to 'app-antivirus')
-rw-r--r--app-antivirus/clamav/Manifest1
-rw-r--r--app-antivirus/clamav/clamav-0.104.0.ebuild210
-rw-r--r--app-antivirus/clamav/files/clamav-0.104.0-ncurses_detection.patch27
-rwxr-xr-xapp-antivirus/clamav/files/clamav-milter.initd34
-rw-r--r--app-antivirus/clamav/files/clamav-milter.service-0.104.013
-rwxr-xr-xapp-antivirus/clamav/files/clamd.initd33
-rw-r--r--app-antivirus/clamav/files/clamd_at.service-0.104.012
-rwxr-xr-xapp-antivirus/clamav/files/clamonacc.initd18
-rwxr-xr-xapp-antivirus/clamav/files/freshclam.initd8
-rw-r--r--app-antivirus/clamav/metadata.xml2
10 files changed, 358 insertions, 0 deletions
diff --git a/app-antivirus/clamav/Manifest b/app-antivirus/clamav/Manifest
index 8705b5f26684..48eb3537bacc 100644
--- a/app-antivirus/clamav/Manifest
+++ b/app-antivirus/clamav/Manifest
@@ -1 +1,2 @@
DIST clamav-0.103.3.tar.gz 13389239 BLAKE2B 1846cceed39fbd48fcf973d05a57901cf6f9ccdbb4d7eae501e712d84ab4d0a662e4477696aa6a1446116db85a89603428d7092a55e18f7acb805016d3cd5431 SHA512 c2ee24a6f63735c064140aa5baa347d51e8240b2f7eced3480d05435202aedd481fa7057fd40ecbc2e93a62fe8b0cefb574d8accdf9acede643ffbe0d396686f
+DIST clamav-0.104.0.tar.gz 11896747 BLAKE2B c3ca32c1277052301a8bff94fec66a2df8f589bc9a673a00d0f45aaf9d8fd23e8bb87dde787d4188a6318d6677c3364e377ccec16d8e44667430713ce7e2a78d SHA512 7a052e6310ef92068acc384d10a64eed6d54d2d408d203dab92defbb1a276e8a193a2096a8028c8982323ba0be83d25602f026aeffa056878ce36aa325c0046c
diff --git a/app-antivirus/clamav/clamav-0.104.0.ebuild b/app-antivirus/clamav/clamav-0.104.0.ebuild
new file mode 100644
index 000000000000..2869e22a6788
--- /dev/null
+++ b/app-antivirus/clamav/clamav-0.104.0.ebuild
@@ -0,0 +1,210 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+CMAKE_ECLASS=cmake
+inherit cmake flag-o-matic systemd tmpfiles
+
+DESCRIPTION="Clam Anti-Virus Scanner"
+HOMEPAGE="https://www.clamav.net/"
+SRC_URI="https://www.clamav.net/downloads/production/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~sparc-solaris ~x86-solaris"
+IUSE="doc clamonacc clamapp libclamav-only milter rar selinux systemd test uclibc"
+
+REQUIRED_USE="libclamav-only? ( !clamonacc !clamapp !milter )
+ clamonacc? ( clamapp )
+ milter? ( clamapp )"
+
+RESTRICT="!test? ( test )"
+
+# Require acct-{user,group}/clamav at build time so that we can set
+# the permissions on /var/lib/clamav in src_install rather than in
+# pkg_postinst; calling "chown" on the live filesystem scares me.
+CDEPEND="acct-group/clamav
+ acct-user/clamav
+ dev-libs/libltdl
+ dev-libs/libmspack
+ dev-libs/libpcre2
+ >=sys-libs/zlib-1.2.2:=
+ app-arch/bzip2
+ clamapp? ( sys-libs/ncurses:0 net-misc/curl dev-libs/json-c:= )
+ elibc_musl? ( sys-libs/fts-standalone )
+ virtual/libiconv
+ !libclamav-only? ( net-misc/curl )
+ dev-libs/openssl:0=
+ milter? ( || ( mail-filter/libmilter mail-mta/sendmail ) )
+ dev-libs/libxml2
+ rar? ( app-arch/unrar )
+ test? ( dev-python/pytest )"
+# TODO: there is no way to use this with the new build system instead of the bundled one
+# dev-libs/tomsfastmath
+
+BDEPEND=">=dev-util/cmake-3.14
+ virtual/pkgconfig"
+
+DEPEND="${CDEPEND}
+ clamapp? ( dev-libs/json-c:* )
+ test? ( dev-libs/check )"
+RDEPEND="${CDEPEND}
+ selinux? ( sec-policy/selinux-clamav )"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-0.104.0-ncurses_detection.patch"
+)
+
+src_configure() {
+ use elibc_musl && append-ldflags -lfts
+ use ppc64 && append-flags -mminimal-toc
+ use uclibc && export ac_cv_type_error_t=yes
+
+ local mycmakeargs=(
+ -DDATABASE_DIRECTORY="${EPREFIX}"/var/lib/clamav
+ -DAPP_CONFIG_DIRECTORY="${EPREFIX}"/etc/clamav
+ -DENABLE_EXPERIMENTAL=OFF
+ -DENABLE_JSON_SHARED=ON
+ -DENABLE_APP=$(usex clamapp ON OFF)
+ -DENABLE_MILTER=$(usex milter ON OFF)
+ -DENABLE_CLAMONACC=$(usex clamonacc ON OFF)
+ -DCLAMAV_USER="clamav"
+ -DCLAMAV_GROUP="clamav"
+ -DBYTECODE_RUNTIME=interpreter
+ -DOPTIMIZE=ON
+ -DENABLE_EXTERNAL_MSPACK=ON
+ -DENABLE_MAN_PAGES=ON
+ -DENABLE_UNRAR=$(usex rar ON OFF)
+ -DENABLE_TESTS=$(usex test ON OFF)
+ -DENABLE_STATIC_LIB=OFF
+ -DENABLE_SHARED_LIB=ON
+ -DENABLE_SYSTEMD=$(usex systemd ON OFF)
+ )
+ cmake_src_configure
+}
+
+src_install() {
+ cmake_src_install
+
+ # init scripts
+ newinitd "${FILESDIR}/clamd.initd" clamd
+ newinitd "${FILESDIR}/freshclam.initd" freshclam
+ use clamonacc && \
+ newinitd "${FILESDIR}/clamonacc.initd" clamonacc
+ use milter && \
+ newinitd "${FILESDIR}/clamav-milter.initd" clamav-milter
+
+ rm -rf "${ED}"/var/lib/clamav || die
+
+ if ! use libclamav-only ; then
+ if use systemd; then
+ # The tmpfiles entry is behind USE=systemd because the
+ # upstream OpenRC service files should (and do) ensure that
+ # the directories they need exist and have the correct
+ # permissions without the help of opentmpfiles. There are
+ # years-old root exploits in opentmpfiles, the design is
+ # fundamentally flawed, and the maintainer is not up to
+ # the task of fixing it.
+ dotmpfiles "${FILESDIR}/tmpfiles.d/clamav.conf"
+ systemd_newunit "${FILESDIR}/clamd_at.service-0.104.0" "clamd@.service"
+ systemd_dounit "${FILESDIR}/clamd.service"
+ systemd_newunit "${FILESDIR}/freshclamd.service-r1" \
+ "freshclamd.service"
+ fi
+
+ # Modify /etc/{clamd,freshclam}.conf to be usable out of the box
+ sed -e "s:^\(Example\):\# \1:" \
+ -e "s/^#\(PidFile .*\)/\1/" \
+ -e "s/^#\(LocalSocket .*\)/\1/" \
+ -e "s/^#\(User .*\)/\1/" \
+ -e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamd.log:" \
+ -e "s:^\#\(LogTime\).*:\1 yes:" \
+ -e "s/^#\(DatabaseDirectory .*\)/\1/" \
+ "${ED}"/etc/clamav/clamd.conf.sample > \
+ "${ED}"/etc/clamav/clamd.conf || die
+
+ sed -e "s:^\(Example\):\# \1:" \
+ -e "s/^#\(PidFile .*\)/\1/" \
+ -e "s/^#\(DatabaseOwner .*\)/\1/" \
+ -e "s:^\#\(UpdateLogFile\) .*:\1 ${EPREFIX}/var/log/clamav/freshclam.log:" \
+ -e "s:^\#\(NotifyClamd\).*:\1 ${EPREFIX}/etc/clamd.conf:" \
+ -e "s:^\#\(ScriptedUpdates\).*:\1 yes:" \
+ -e "s/^#\(DatabaseDirectory .*\)/\1/" \
+ "${ED}"/etc/clamav/freshclam.conf.sample > \
+ "${ED}"/etc/clamav/freshclam.conf || die
+
+ if use milter ; then
+ # Note: only keep the "unix" ClamdSocket and MilterSocket!
+ sed -e "s:^\(Example\):\# \1:" \
+ -e "s/^#\(PidFile .*\)/\1/" \
+ -e "s/^#\(ClamdSocket unix:.*\)/\1/" \
+ -e "s/^#\(User .*\)/\1/" \
+ -e "s/^#\(MilterSocket unix:.*\)/\1/" \
+ -e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamav-milter.log:" \
+ "${ED}"/etc/clamav/clamav-milter.conf.sample > \
+ "${ED}"/etc/clamav/clamav-milter.conf || die
+
+ systemd_newunit "${FILESDIR}/clamav-milter.service-0.104.0" clamav-milter.service
+ fi
+
+ local i
+ for i in clamd freshclam clamav-milter
+ do
+ if [[ -f "${ED}"/etc/"${i}".conf.sample ]]; then
+ mv "${ED}"/etc/"${i}".conf{.sample,} || die
+ fi
+ done
+
+ # These both need to be writable by the clamav user.
+ # TODO: use syslog by default; that's what it's for.
+ diropts -o clamav -g clamav
+ keepdir /var/lib/clamav
+ keepdir /var/log/clamav
+ fi
+
+ if use doc ; then
+ local HTML_DOCS=( docs/html/. )
+ einstalldocs
+
+ if ! use libclamav-only ; then
+ doman docs/man/*.[1-8]
+ fi
+ fi
+
+ find "${ED}" -name '*.la' -delete || die
+}
+
+src_test() {
+ if use libclamav-only ; then
+ ewarn "Test target not available when USE=libclamav-only is set, skipping tests ..."
+ return 0
+ fi
+
+ emake quick-check
+}
+
+pkg_postinst() {
+ if ! use libclamav-only ; then
+ if use systemd ; then
+ tmpfiles_process clamav.conf
+ fi
+ fi
+
+ if use milter ; then
+ elog "For simple instructions how to setup the clamav-milter read the"
+ elog "clamav-milter.README.gentoo in /usr/share/doc/${PF}"
+ fi
+
+ local databases=( "${EROOT}"/var/lib/clamav/main.c[lv]d )
+ if [[ ! -f "${databases}" ]] ; then
+ ewarn "You must run freshclam manually to populate the virus database"
+ ewarn "before starting clamav for the first time."
+ fi
+
+ ewarn "This version of ClamAV provides separate OpenRC services"
+ ewarn "for clamd, freshclam, clamav-milter, and clamonacc. The"
+ ewarn "clamd service now starts only the clamd daemon itself. You"
+ ewarn "should add freshclam (and perhaps clamav-milter) to any"
+ ewarn "runlevels that previously contained clamd."
+}
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
new file mode 100644
index 000000000000..aa403a90bab3
--- /dev/null
+++ b/app-antivirus/clamav/files/clamav-0.104.0-ncurses_detection.patch
@@ -0,0 +1,27 @@
+From cd99490efb82b66c75e92fab3ff97c480bfc9cf9 Mon Sep 17 00:00:00 2001
+From: Luca Barbato <lu_zero@gentoo.org>
+Date: Sat, 16 Oct 2021 10:56:22 +0200
+Subject: [PATCH] Use all the link line from ncurses pkg-config
+
+Otherwise it would fail at link time if ncurses has a stand alone tinfo library.
+---
+ cmake/FindCURSES.cmake | 6 +-----
+ 1 file changed, 1 insertion(+), 5 deletions(-)
+
+diff --git a/cmake/FindCURSES.cmake b/cmake/FindCURSES.cmake
+index 35d4a570f6..528211c45c 100644
+--- a/cmake/FindCURSES.cmake
++++ b/cmake/FindCURSES.cmake
+@@ -58,11 +58,7 @@ if(NCURSES_NOT_FOUND EQUAL -1)
+ set(HAVE_LIBNCURSES 1)
+ set(CURSES_INCLUDE "<ncurses.h>")
+
+- find_library(CURSES_LIBRARY
+- NAMES ncurses
+- PATHS ${PC_NCurses_LIBRARY_DIRS}
+- )
+-
++ set(CURSES_LIBRARY ${PC_NCurses_LINK_LIBRARIES})
+ set(CURSES_VERSION ${PC_NCurses_VERSION})
+
+ include(FindPackageHandleStandardArgs)
diff --git a/app-antivirus/clamav/files/clamav-milter.initd b/app-antivirus/clamav/files/clamav-milter.initd
new file mode 100755
index 000000000000..049d908155d3
--- /dev/null
+++ b/app-antivirus/clamav/files/clamav-milter.initd
@@ -0,0 +1,34 @@
+#!/sbin/openrc-run
+
+# Note: the "Foreground" option in clamav-milter.conf MUST
+# be set to "no".
+command="/usr/sbin/clamav-milter"
+
+# For now, must be manually synchronized with the PidFile
+# variable in clamav-milter.conf.
+#
+# https://bugzilla.clamav.net/show_bug.cgi?id=12595
+#
+pidfile="/run/${RC_SVCNAME}.pid"
+
+depend() {
+ # The milter can successfully launch without clamd, but it's not a
+ # great user experience to have the milter start accepting requests
+ # that it can't process. The "use" dependency below will start clamd
+ # before clamav-milter, so long as clamd is also present this runlevel.
+ use clamd
+}
+
+start_pre() {
+ # This exists to support the (disabled) default MilterSocket setting
+ # within clamav-milter.conf. The "clamav" user and group agree with
+ # the (disabled) default "User" and "MilterSocketGroup" settings.
+ #
+ # Creating this directory is harmless even when a local socket is
+ # not used. In fact, the clamd service that we depend on should
+ # create it as well, to hold its own local socket (if enabled).
+ checkpath --directory \
+ --mode 0755 \
+ --owner clamav:clamav \
+ "/run/clamav"
+}
diff --git a/app-antivirus/clamav/files/clamav-milter.service-0.104.0 b/app-antivirus/clamav/files/clamav-milter.service-0.104.0
new file mode 100644
index 000000000000..68acf0695ceb
--- /dev/null
+++ b/app-antivirus/clamav/files/clamav-milter.service-0.104.0
@@ -0,0 +1,13 @@
+[Unit]
+Description=Milter module for the ClamAV scanner
+After=nss-lookup.target network.target
+Before=sendmail.service
+Before=postfix.service
+
+[Service]
+Type=forking
+PIDFile=/run/clamav/clamav-milter.pid
+ExecStart=/usr/sbin/clamav-milter -c /etc/clamav/clamav-milter.conf
+
+[Install]
+WantedBy=multi-user.target
diff --git a/app-antivirus/clamav/files/clamd.initd b/app-antivirus/clamav/files/clamd.initd
new file mode 100755
index 000000000000..efc01efc41b0
--- /dev/null
+++ b/app-antivirus/clamav/files/clamd.initd
@@ -0,0 +1,33 @@
+#!/sbin/openrc-run
+
+# Note: the "Foreground" option in clamd.conf must be set to "no"
+command="/usr/sbin/clamd"
+extra_started_commands="reload"
+
+# For now, must be manually synchronized with the PidFile variable
+# in clamd.conf.
+#
+# https://bugzilla.clamav.net/show_bug.cgi?id=12595
+#
+pidfile="/run/${RC_SVCNAME}.pid"
+
+start_pre() {
+ # This exists to support the (disabled) default LocalSocket setting
+ # within clamd.conf. The "clamav" user and group agree with the
+ # (disabled) default "User" and "LocalSocketGroup" settings in
+ # clamd.conf. And everything here agrees with the
+ # clamav-daemon.socket systemd service.
+ #
+ # Creating this directory is harmless even when a local socket is
+ # not used.
+ checkpath --directory \
+ --mode 0755 \
+ --owner clamav:clamav \
+ "/run/clamav"
+}
+
+reload() {
+ ebegin "Reloading ${RC_SVCNAME}"
+ "/usr/bin/clamdscan" --reload
+ eend $?
+}
diff --git a/app-antivirus/clamav/files/clamd_at.service-0.104.0 b/app-antivirus/clamav/files/clamd_at.service-0.104.0
new file mode 100644
index 000000000000..5ab51e7fccf7
--- /dev/null
+++ b/app-antivirus/clamav/files/clamd_at.service-0.104.0
@@ -0,0 +1,12 @@
+[Unit]
+Description=clamd scanner (%i) daemon
+After=nss-lookup.target network.target
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/clamd -c /etc/clamav/clamd%i.conf
+Restart=on-failure
+PrivateTmp=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/app-antivirus/clamav/files/clamonacc.initd b/app-antivirus/clamav/files/clamonacc.initd
new file mode 100755
index 000000000000..f625707b171a
--- /dev/null
+++ b/app-antivirus/clamav/files/clamonacc.initd
@@ -0,0 +1,18 @@
+#!/sbin/openrc-run
+
+command="/usr/sbin/clamonacc"
+pidfile="/run/${RC_SVCNAME}.pid"
+
+# clamonacc doesn't support a PID file at the moment, so we
+# run it in the foreground and let OpenRC background it.
+#
+# https://bugzilla.clamav.net/show_bug.cgi?id=12595
+#
+command_args="--foreground"
+command_background=true
+
+depend() {
+ # Unlike the milter, the on-access scanner will simply fail to start
+ # until clamd is available.
+ need clamd
+}
diff --git a/app-antivirus/clamav/files/freshclam.initd b/app-antivirus/clamav/files/freshclam.initd
new file mode 100755
index 000000000000..415d94a87668
--- /dev/null
+++ b/app-antivirus/clamav/files/freshclam.initd
@@ -0,0 +1,8 @@
+#!/sbin/openrc-run
+
+command="/usr/bin/freshclam"
+pidfile="/run/${RC_SVCNAME}.pid"
+
+# Ignore the value of "PidFile" set in freshclam.conf.
+command_args="-p ${pidfile}"
+command_args_background="--daemon"
diff --git a/app-antivirus/clamav/metadata.xml b/app-antivirus/clamav/metadata.xml
index 799ee7cad29d..4c41e164aee7 100644
--- a/app-antivirus/clamav/metadata.xml
+++ b/app-antivirus/clamav/metadata.xml
@@ -12,12 +12,14 @@
</maintainer>
<use>
+ <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>
<flag name="clamonacc">Build the clamonacc on-access scanner</flag>
<flag name="clamdtop">A Top like tool which shows what clamd is currently scanning amongst other things</flag>
<flag name="clamsubmit">A tool to submit false positives / negatives</flag>
<flag name="libclamav-only">Bypass building of libfreshclam and the ClamAV CLI applications.</flag>
<flag name="metadata-analysis-api">Enables collection of file property metadata using ClamAV API for analysis by ClamAV bytecode programs.</flag>
<flag name="xml">DMG and XAR support</flag>
+ <flag name="rar">RAR support</flag>
</use>
<upstream>
<remote-id type="sourceforge">clamav</remote-id>