commit:     43ffce837b38f6dcded86950884b9e2b55d01357
Author:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 27 11:26:36 2024 +0000
Commit:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
CommitDate: Sun Oct 27 11:32:00 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=43ffce83

app-antivirus/clamav: revert "drop 0.103.11-r1, 0.103.12"

I'm sure this looks like old junk, but it's the last version in the tree
that doesn't require rust / bundle a bunch of libraries, and it's still
supported.

Reverts: b8921c8cca743d458262c1d112decc3339826bf6
Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org>

 app-antivirus/clamav/Manifest                      |   2 +
 app-antivirus/clamav/clamav-0.103.11-r1.ebuild     | 236 ++++++++++
 app-antivirus/clamav/clamav-0.103.12.ebuild        | 237 +++++++++++
 .../files/clamav-0.102.1-libxml2_pkgconfig.patch   | 120 ++++++
 .../files/clamav-0.102.2-fix-curl-detection.patch  |  26 ++
 .../files/clamav-0.103.0-system-tomsfastmath.patch | 115 +++++
 .../files/clamav-0.103.1-upstream-openrc.patch     | 474 +++++++++++++++++++++
 .../files/clamav-0.103.12-missing-const.patch      |  13 +
 8 files changed, 1223 insertions(+)

diff --git a/app-antivirus/clamav/Manifest b/app-antivirus/clamav/Manifest
index 2687a67509c8..d5636a04acd1 100644
--- a/app-antivirus/clamav/Manifest
+++ b/app-antivirus/clamav/Manifest
@@ -33,6 +33,8 @@ DIST cc-1.0.97.crate 76951 BLAKE2B 
ec2e65797dfe13223b64f28bf6d143e00362f8bdd14e4
 DIST cexpr-0.6.0.crate 17966 BLAKE2B 
cb46f066eb1f4dbac00ec86dc3e562db7ee8ea5ff17d16a60004fa020405e455b8aeb3d001f669cb33d1b62525bfd04ec657ffca4ed44a83af4a5e75b2c820e3
 SHA512 
766bff7ca7f9bf0885aee6f014bcfc084e7fdfcd567a49443d5340acfe8f257db109de17b24588504fc35c53f2d4303e2d22da21f73669125cfca984950cf886
 DIST cfg-if-1.0.0.crate 7934 BLAKE2B 
e99a5589c11d79d77a4537b34ce0a45d37b981c123b79b807cea836c89fc3926d693458893baca2882448d3d44e3f64e06141f6d916b748daa10b8cc1ae16d1b
 SHA512 
0fb16a8882fd30e86b62c5143b1cb18ab564e84e75bd1f28fd12f24ffdc4a42e0d2e012a99abb606c12efe3c11061ff5bf8e24ab053e550ae083f7d90f6576ff
 DIST chrono-0.4.38.crate 220559 BLAKE2B 
ab828bfeed56eb737a1797d5e1132cafe87a1e14bf7a1fe4a5098f50e6ceead50ca2e7f041cc2ff63d5f4e41e2853322f6c345bb31ff12a5b412e3e5202f5fea
 SHA512 
858e47e3facebd5383e71898f26b27d92fe4a69027e2cc47da2af59975ead7767355e0b699f4228eabe76a3eff8b2519c7cecf8b60dc3fc60fbf9b28e2f3d4d9
+DIST clamav-0.103.11.tar.gz 16550978 BLAKE2B 
9fba6d5b41ef07b017be26b7ebd832ca03146a68545f794924332c67429ba27603745e2ad7fc0f58c341c6d9267e5b5265c37525dba9cbb15ab616915ec2d605
 SHA512 
86241ee8058d9a3ccc13b89bb41aa16cfbeb65717fbcfeea6117b7885e8854f5673c22475e7d33ee4210a15d583e806f252657c07933f072455027f1531427b8
+DIST clamav-0.103.12.tar.gz 16507685 BLAKE2B 
bc31787625f85867bf21c4555aa2fd2998514986fb571fa4e6cb9fa3fedf61b493c517291b662054edc0bbe8d45649d9c244d943df01950e204baa9e537e3e32
 SHA512 
0e870a5fd035fbf090359ef7634b1b36e346ff3066b896ff17c2c6ace04f4c17e16181a21fead8b8b2f397de9ea47b928515b717a41996bac4c8efed4d16ec4e
 DIST clamav-1.0.5.tar.gz 10344955 BLAKE2B 
1deceff859c9eec6185f6c83833333d1a030edd1c9dcc6788f669259b4922f332b564a7c6f3fa7f03ebe2051524132becb35cbd67526aac43e95ca3978793517
 SHA512 
7d46cf5555107d2856430a5f09f5dfd011b597d3dc7e691db3c956867b1314b50fd23008bf45b377d31493a12716c527159d163748d6ae759e97a041780da0d9
 DIST clamav-1.0.7.tar.gz 10348714 BLAKE2B 
cd57fd9eb7ca5a4ea980cdedcf5977c1d11b28afccaa5807ada7315659dfdbd2d122af4a7cf5c0849df25b41a85b2186c5bbfe0621582955b82b2cc8dced759f
 SHA512 
31b04c795d5a25b6b66f8dc6bb53193e969119f8682c1b5d5194629b7a075e60d2ac9e88e2ababde149e906b0c2e45a3869a0071cef4c1a6f9d5a165a7fa5c67
 DIST clamav-1.2.2.tar.gz 10372690 BLAKE2B 
47940236e38296ac908be4c5d1c5ce8bbc9ec5c69fa87b2472c941d2de9642e0ab6a59c63038aa706079e8efeb161083db69ad03eaaf27a6d05f4f1a5bb70aff
 SHA512 
32562230f367a230f70dfca5ed5000ee8829a0da7452b0113e9dbaa47ef6b21901001f741b0e52ce52c02fe8f834bd559bcbdf1ea20495bead9c4976c3a4cc92

diff --git a/app-antivirus/clamav/clamav-0.103.11-r1.ebuild 
b/app-antivirus/clamav/clamav-0.103.11-r1.ebuild
new file mode 100644
index 000000000000..c78491725f72
--- /dev/null
+++ b/app-antivirus/clamav/clamav-0.103.11-r1.ebuild
@@ -0,0 +1,236 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools 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 unRAR"
+SLOT="0/lts"
+KEYWORDS="~alpha amd64 arm arm64 ~hppa ppc ppc64 ~riscv ~sparc x86 
~amd64-linux ~x86-linux ~ppc-macos"
+IUSE="bzip2 doc clamonacc clamdtop clamsubmit iconv ipv6 libclamav-only milter 
metadata-analysis-api selinux systemd test xml"
+
+REQUIRED_USE="libclamav-only? ( !clamonacc !clamdtop !clamsubmit !milter 
!metadata-analysis-api )"
+
+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 >dev-libs/libpcre-6 )
+       dev-libs/tomsfastmath
+       >=sys-libs/zlib-1.2.2:=
+       bzip2? ( app-arch/bzip2 )
+       clamdtop? ( sys-libs/ncurses:0 )
+       clamsubmit? ( net-misc/curl dev-libs/json-c:= )
+       elibc_musl? ( sys-libs/fts-standalone )
+       iconv? ( virtual/libiconv )
+       !libclamav-only? ( net-misc/curl )
+       dev-libs/openssl:0=
+       milter? ( mail-filter/libmilter:= )
+       xml? ( dev-libs/libxml2 )"
+
+# We need at least autoconf-2.69-r5 because that's the first (patched)
+# version of it in Gentoo that supports ./configure --runstatedir.
+BDEPEND=">=dev-build/autoconf-2.69-r5
+       virtual/pkgconfig"
+
+DEPEND="${CDEPEND}
+       metadata-analysis-api? ( dev-libs/json-c:* )
+       test? ( dev-libs/check )"
+RDEPEND="${CDEPEND}
+       selinux? ( sec-policy/selinux-clamav )"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-0.102.1-libxml2_pkgconfig.patch" #661328
+       "${FILESDIR}/${PN}-0.102.2-fix-curl-detection.patch" #709616
+       "${FILESDIR}/${PN}-0.103.0-system-tomsfastmath.patch" # 649394
+       "${FILESDIR}/${PN}-0.103.1-upstream-openrc.patch"
+)
+
+src_prepare() {
+       default
+
+       # Be extra sure that we're using the system copy of tomsfastmath
+       einfo "removing bundled copy of dev-libs/tomsfastmath"
+       rm -r libclamav/tomsfastmath || \
+               die "failed to remove bundled tomsfastmath"
+
+       AT_NO_RECURSIVE="yes" eautoreconf
+}
+
+src_configure() {
+       use elibc_musl && append-ldflags -lfts
+       use ppc64 && append-flags -mminimal-toc
+
+       # according to configure help it should be
+       # $(use_enable xml)
+       # but that does not work
+       # do not add this, since --disable-xml seems to override
+       # --without-xml
+       JSONUSE="--without-libjson"
+
+       if use clamsubmit || use metadata-analysis-api; then
+               # either of those 2 requires libjson.
+               # clamsubmit will be built as soon as libjson and curl are found
+               # but we only install the binary if requested
+               JSONUSE="--with-libjson=${EPREFIX}/usr"
+       fi
+
+       local myeconfargs=(
+               $(use_enable bzip2)
+               $(use_enable clamonacc)
+               $(use_enable clamdtop)
+               $(use_enable ipv6)
+               $(use_enable milter)
+               $(use_enable test check)
+               $(use_with xml)
+               $(use_with iconv)
+               ${JSONUSE}
+               $(use_enable libclamav-only)
+               $(use_with !libclamav-only libcurl)
+               --with-system-libmspack
+               --cache-file="${S}"/config.cache
+               --disable-experimental
+               --disable-static
+               --disable-zlib-vcheck
+               --enable-id-check
+               --with-dbdir="${EPREFIX}"/var/lib/clamav
+               # Don't call --with-zlib=/usr (see bug #699296)
+               --with-zlib
+               --disable-llvm
+               --enable-openrc
+               --runstatedir=/run
+       )
+       econf "${myeconfargs[@]}"
+}
+
+src_install() {
+       default
+
+       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
+                       # OpenRC service scripts should (and do) ensure that the
+                       # directories they need exist and have the correct
+                       # permissions without the help of tmpfiles.
+                       newtmpfiles "${FILESDIR}/tmpfiles.d/clamav-r1.conf" 
clamav.conf
+                       systemd_newunit "${FILESDIR}/clamd_at.service" 
"[email protected]"
+                       systemd_dounit "${FILESDIR}/clamd.service"
+                       systemd_newunit "${FILESDIR}/freshclamd.service-r1" \
+                                                       "freshclamd.service"
+               fi
+
+               insinto /etc/logrotate.d
+               newins "${FILESDIR}/clamd.logrotate" clamd
+               newins "${FILESDIR}/freshclam.logrotate" freshclam
+               use milter && \
+                       newins "${FILESDIR}/clamav-milter.logrotate-r1" 
clamav-milter
+
+               # Modify /etc/{clamd,freshclam}.conf to be usable out of the box
+               sed -i -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/clamd.conf.sample || die
+
+               sed -i -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/freshclam.conf.sample || die
+
+               if use milter ; then
+                       # Note: only keep the "unix" ClamdSocket and 
MilterSocket!
+                       sed -i -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-milter.conf.sample || die
+
+                       cat >> "${ED}"/etc/conf.d/clamd <<-EOF
+                               MILTER_NICELEVEL=19
+                               START_MILTER=no
+                       EOF
+
+                       systemd_newunit "${FILESDIR}/clamav-milter.service-r1" 
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/clamav-0.103.12.ebuild 
b/app-antivirus/clamav/clamav-0.103.12.ebuild
new file mode 100644
index 000000000000..403147a45936
--- /dev/null
+++ b/app-antivirus/clamav/clamav-0.103.12.ebuild
@@ -0,0 +1,237 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools 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 unRAR"
+SLOT="0/lts"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~riscv ~sparc ~x86 
~amd64-linux ~x86-linux ~ppc-macos"
+IUSE="bzip2 doc clamonacc clamdtop clamsubmit iconv libclamav-only milter 
metadata-analysis-api selinux systemd test xml"
+
+REQUIRED_USE="libclamav-only? ( !clamonacc !clamdtop !clamsubmit !milter 
!metadata-analysis-api )"
+
+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 >dev-libs/libpcre-6 )
+       dev-libs/tomsfastmath
+       >=sys-libs/zlib-1.2.2:=
+       bzip2? ( app-arch/bzip2 )
+       clamdtop? ( sys-libs/ncurses:0 )
+       clamsubmit? ( net-misc/curl dev-libs/json-c:= )
+       elibc_musl? ( sys-libs/fts-standalone )
+       iconv? ( virtual/libiconv )
+       !libclamav-only? ( net-misc/curl )
+       dev-libs/openssl:0=
+       milter? ( mail-filter/libmilter:= )
+       xml? ( dev-libs/libxml2 )"
+
+# We need at least autoconf-2.69-r5 because that's the first (patched)
+# version of it in Gentoo that supports ./configure --runstatedir.
+BDEPEND=">=dev-build/autoconf-2.69-r5
+       virtual/pkgconfig"
+
+DEPEND="${CDEPEND}
+       metadata-analysis-api? ( dev-libs/json-c:* )
+       test? ( dev-libs/check )"
+RDEPEND="${CDEPEND}
+       selinux? ( sec-policy/selinux-clamav )"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-0.102.1-libxml2_pkgconfig.patch" #661328
+       "${FILESDIR}/${PN}-0.102.2-fix-curl-detection.patch" #709616
+       "${FILESDIR}/${PN}-0.103.0-system-tomsfastmath.patch" # 649394
+       "${FILESDIR}/${PN}-0.103.1-upstream-openrc.patch"
+       "${FILESDIR}/${PN}-0.103.12-missing-const.patch"
+)
+
+src_prepare() {
+       default
+
+       # Be extra sure that we're using the system copy of tomsfastmath
+       einfo "removing bundled copy of dev-libs/tomsfastmath"
+       rm -r libclamav/tomsfastmath || \
+               die "failed to remove bundled tomsfastmath"
+
+       AT_NO_RECURSIVE="yes" eautoreconf
+}
+
+src_configure() {
+       use elibc_musl && append-ldflags -lfts
+       use ppc64 && append-flags -mminimal-toc
+
+       # according to configure help it should be
+       # $(use_enable xml)
+       # but that does not work
+       # do not add this, since --disable-xml seems to override
+       # --without-xml
+       JSONUSE="--without-libjson"
+
+       if use clamsubmit || use metadata-analysis-api; then
+               # either of those 2 requires libjson.
+               # clamsubmit will be built as soon as libjson and curl are found
+               # but we only install the binary if requested
+               JSONUSE="--with-libjson=${EPREFIX}/usr"
+       fi
+
+       local myeconfargs=(
+               $(use_enable bzip2)
+               $(use_enable clamonacc)
+               $(use_enable clamdtop)
+               $(use_enable milter)
+               $(use_enable test check)
+               $(use_with xml)
+               $(use_with iconv)
+               ${JSONUSE}
+               $(use_enable libclamav-only)
+               $(use_with !libclamav-only libcurl)
+               --enable-ipv6
+               --with-system-libmspack
+               --cache-file="${S}"/config.cache
+               --disable-experimental
+               --disable-static
+               --disable-zlib-vcheck
+               --enable-id-check
+               --with-dbdir="${EPREFIX}"/var/lib/clamav
+               # Don't call --with-zlib=/usr (see bug #699296)
+               --with-zlib
+               --disable-llvm
+               --enable-openrc
+               --runstatedir=/run
+       )
+       econf "${myeconfargs[@]}"
+}
+
+src_install() {
+       default
+
+       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
+                       # OpenRC service scripts should (and do) ensure that the
+                       # directories they need exist and have the correct
+                       # permissions without the help of tmpfiles.
+                       newtmpfiles "${FILESDIR}/tmpfiles.d/clamav-r1.conf" 
clamav.conf
+                       systemd_newunit "${FILESDIR}/clamd_at.service" 
"[email protected]"
+                       systemd_dounit "${FILESDIR}/clamd.service"
+                       systemd_newunit "${FILESDIR}/freshclamd.service-r1" \
+                                                       "freshclamd.service"
+               fi
+
+               insinto /etc/logrotate.d
+               newins "${FILESDIR}/clamd.logrotate" clamd
+               newins "${FILESDIR}/freshclam.logrotate" freshclam
+               use milter && \
+                       newins "${FILESDIR}/clamav-milter.logrotate-r1" 
clamav-milter
+
+               # Modify /etc/{clamd,freshclam}.conf to be usable out of the box
+               sed -i -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/clamd.conf.sample || die
+
+               sed -i -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/freshclam.conf.sample || die
+
+               if use milter ; then
+                       # Note: only keep the "unix" ClamdSocket and 
MilterSocket!
+                       sed -i -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-milter.conf.sample || die
+
+                       cat >> "${ED}"/etc/conf.d/clamd <<-EOF
+                               MILTER_NICELEVEL=19
+                               START_MILTER=no
+                       EOF
+
+                       systemd_newunit "${FILESDIR}/clamav-milter.service-r1" 
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.102.1-libxml2_pkgconfig.patch 
b/app-antivirus/clamav/files/clamav-0.102.1-libxml2_pkgconfig.patch
new file mode 100644
index 000000000000..ea39173c8ba1
--- /dev/null
+++ b/app-antivirus/clamav/files/clamav-0.102.1-libxml2_pkgconfig.patch
@@ -0,0 +1,120 @@
+From 25b9fccdae3a05561b6b7c9c82018a9a3dfec819 Mon Sep 17 00:00:00 2001
+From: Lars Wendler <[email protected]>
+Date: Mon, 25 Nov 2019 15:54:09 +0100
+Subject: [PATCH] build: Use pkg-config to find libxml2
+
+Otherwise we get unneccesary linkage to icu and other unwanted stuff
+
+Bug: https://bugzilla.clamav.net/show_bug.cgi?id=12202
+Gentoo-bug: https://bugs.gentoo.org/661328
+Signed-off-by: Lars Wendler <[email protected]>
+---
+ m4/reorganization/libs/xml.m4 | 82 ++++++-----------------------------
+ 1 file changed, 13 insertions(+), 69 deletions(-)
+
+diff --git a/m4/reorganization/libs/xml.m4 b/m4/reorganization/libs/xml.m4
+index 24f0cfa92..d143e3a47 100644
+--- a/m4/reorganization/libs/xml.m4
++++ b/m4/reorganization/libs/xml.m4
+@@ -4,85 +4,29 @@ AC_ARG_ENABLE([xml],
+ [AS_HELP_STRING([--disable-xml], [do not include DMG and XAR support])],
+ want_xml=$enableval, want_xml="auto")
+ 
+-XML_HOME=""
+-xmlconfig=""
+ if test "X$want_xml" != "Xno"; then
+-  AC_MSG_CHECKING([for libxml2 installation])
+-  AC_ARG_WITH([xml],
+-    AS_HELP_STRING([--with-xml@<:@=DIR@:>@], [path to directory containing 
libxml2 library
+-                    @<:@default=/usr/local or /usr if not found in 
/usr/local@:>@]),
+-    [with_xml_val=$withval]
+-  )
+-
+-  AS_IF([test "x$with_xml_val" = "xno"], [XML_HOME=""],
+-    [test "x$with_xml_val" = "xyes"], [XML_HOME="/usr/local"],
+-    [XML_HOME="$with_xml_val"])
+-
+-  AS_IF([test "x$XML_HOME" != "x"], [
+-     AS_IF([test ! -x "$XML_HOME/bin/xml2-config"], [XML_HOME=""])
+-     ])
+-
+-  AS_IF([test "x$XML_HOME" = "x" -a "x$with_xml_val" = "xyes"], [
+-     AS_IF([test -x "/usr/bin/xml2-config"], [XML_HOME="/usr"])
+-     ])
+-
+-  if test "x$XML_HOME" != "x"; then
+-    AC_MSG_RESULT([$XML_HOME])
+-    with_xml="yes"
+-  else
+-    AC_MSG_RESULT([not found])
+-  fi
+-
+-  found_xml="no"
+-  XMLCONF_VERSION=""
+-  XML_CPPFLAGS=""
+-  XML_LIBS=""
+-  case "$with_xml" in
+-    yes) AC_PATH_PROG([xmlconfig], [xml2-config])
+-        if test "x$xmlconfig" = x ; then
+-            AC_MSG_NOTICE([can not locate xml2-config in PATH, will search 
default XML_HOME variants])
+-            
+-            if test "x$XML_HOME" != "x"; then
+-                AC_MSG_CHECKING([xml2-config version])
+-                XMLCONF_VERSION="`$XML_HOME/bin/xml2-config --version`"
+-
+-                if test "x%XMLCONF_VERSION" != "x"; then
+-                    AC_MSG_RESULT([$XMLCONF_VERSION])
+-                    found_xml="yes"
+-                    XML_CPPFLAGS="`$XML_HOME/bin/xml2-config --cflags`"
+-                    XML_LIBS="`$XML_HOME/bin/xml2-config --libs`"
+-                    AS_ECHO("$XML_CPPFLAGS")
+-                    AS_ECHO("$XML_LIBS")
+-                else
+-                    AC_MSG_ERROR([xml2-config failed])
+-                fi
+-            fi
+-        else
+-            found_xml="yes"
+-            XMLCONF_VERSION="`$xmlconfig --version`"
+-            XML_CPPFLAGS="`$xmlconfig --cflags`"
+-            XML_LIBS="`$xmlconfig --libs`"
+-        fi
+-  esac
++    PKG_CHECK_MODULES([XML], [libxml-2.0],
++      [found_xml=yes],
++      [
++          found_xml=no
++          AS_IF([test "x$want_xml" = xyes],
++              [AC_MSG_ERROR([--enable-xml set but cannot find libxml2])]
++          )
++      ]
++    )
+ 
+   working_xml="no"
+   if test "X$found_xml" != "Xno"; then
+-
+-    readerresult=""
+-    if test "x$xmlconfig" = x ; then
+-        readerresult="$XML_HOME/include/libxml2/libxml/xmlreader.h"
+-    else
+-        readerresult="`$xmlconfig 
--prefix`/include/libxml2/libxml/xmlreader.h"
+-    fi
+-    
++    XML_HOME=$(${PKG_CONFIG} --variable prefix libxml-2.0)
+     AC_MSG_CHECKING([for xmlreader.h in $readerresult])
+-    
+-    if test ! -f "$readerresult"; then
++
++    if test ! -f "$XML_HOME/include/libxml2/libxml/xmlreader.h"; then
+       AC_MSG_RESULT([not found])
+     else
+       AC_MSG_RESULT([found])
+       save_LIBS="$LIBS"
+       save_CPPFLAGS="$CPPFLAGS"
++      XML_CPPFLAGS="$XML_CFLAGS"
+       CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
+       save_LDFLAGS="$LDFLAGS"
+       LDFLAGS="$LDFLAGS $XML_LIBS"
+-- 
+2.24.0
+

diff --git a/app-antivirus/clamav/files/clamav-0.102.2-fix-curl-detection.patch 
b/app-antivirus/clamav/files/clamav-0.102.2-fix-curl-detection.patch
new file mode 100644
index 000000000000..f89a704ea3e0
--- /dev/null
+++ b/app-antivirus/clamav/files/clamav-0.102.2-fix-curl-detection.patch
@@ -0,0 +1,26 @@
+https://bugs.gentoo.org/709616
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -197,6 +197,10 @@ AC_CONFIG_FILES([
+                  clamav-types.h
+                  clamav-version.h])
+ if test "x$enable_libclamav_only" != "xyes"; then
++    if test "$have_curl" = "no"; then
++        AC_MSG_ERROR([libcurl not found. libcurl (e.g. libcurl-devel) is 
required in order to build freshclam and clamsubmit.])
++    fi
++
+     AC_CONFIG_FILES([
+                      clamscan/Makefile
+                      database/Makefile
+--- a/m4/reorganization/libs/curl.m4
++++ b/m4/reorganization/libs/curl.m4
+@@ -92,8 +92,6 @@ if test "X$have_curl" = "Xyes"; then
+     )
+ 
+     LDFLAGS="$save_LDFLAGS"
+-else
+-    AC_MSG_ERROR([libcurl not found. libcurl (e.g. libcurl-devel) is required 
in order to build freshclam and clamsubmit.])
+ fi
+ 
+ AC_SUBST([CLAMSUBMIT_LIBS])

diff --git 
a/app-antivirus/clamav/files/clamav-0.103.0-system-tomsfastmath.patch 
b/app-antivirus/clamav/files/clamav-0.103.0-system-tomsfastmath.patch
new file mode 100644
index 000000000000..ad9276c1ad01
--- /dev/null
+++ b/app-antivirus/clamav/files/clamav-0.103.0-system-tomsfastmath.patch
@@ -0,0 +1,115 @@
+From 70cc96407302cf0fd4eee2b6a401253ed50fe4df Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <[email protected]>
+Date: Sun, 20 Sep 2020 11:16:06 -0400
+Subject: [PATCH 1/1] autotools: use system tomsfastmath if possible.
+
+---
+ configure.ac                           |  2 ++
+ libclamav/Makefile.am                  | 10 ++++++++--
+ libclamav/bignum.h                     |  6 +++++-
+ libclamav/xdp.c                        |  2 +-
+ m4/reorganization/libs/tomsfastmath.m4 | 12 ++++++++++++
+ 5 files changed, 28 insertions(+), 4 deletions(-)
+ create mode 100644 m4/reorganization/libs/tomsfastmath.m4
+
+diff --git a/configure.ac b/configure.ac
+index 8e0e810f8..773787e49 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -104,6 +104,7 @@ m4_include([m4/reorganization/libs/libmspack.m4])
+ if test "x$use_internal_mspack" = "xno"; then
+     mspack_msg="External, $LIBMSPACK_CFLAGS $LIBMSPACK_LIBS"
+ fi
++m4_include([m4/reorganization/libs/tomsfastmath.m4])
+ 
+ AM_MAINTAINER_MODE
+ m4_include([m4/reorganization/libs/libz.m4])
+@@ -376,6 +377,7 @@ fi
+ CL_MSG_STATUS([yara        ],[$enable_yara],[$enable_yara])
+ CL_MSG_STATUS([fts         ],[yes],[$lfs_fts_msg])
+ 
++CL_MSG_STATUS([tomsfastmath],[yes],[$tomsfastmath_msg])
+ 
+ # Yep, downgrading the compiler avoids the bug too:
+ # 4.0.x, and 4.1.0 are the known buggy versions
+diff --git a/libclamav/Makefile.am b/libclamav/Makefile.am
+index ae655cfec..240fa23f8 100644
+--- a/libclamav/Makefile.am
++++ b/libclamav/Makefile.am
+@@ -588,8 +588,10 @@ libclamav_la_SOURCES += yara_arena.c \
+       yara_clam.h
+ endif
+ 
+-libclamav_la_SOURCES += bignum.h\
+-      bignum_fast.h\
++libclamav_la_SOURCES += bignum.h
++
++if !SYSTEM_TOMSFASTMATH
++libclamav_la_SOURCES += bignum_fast.h\
+       tomsfastmath/addsub/fp_add.c\
+       tomsfastmath/addsub/fp_add_d.c\
+       tomsfastmath/addsub/fp_addmod.c\
+@@ -671,6 +673,10 @@ libclamav_la_SOURCES += bignum.h\
+       tomsfastmath/sqr/fp_sqr_comba_generic.c\
+       tomsfastmath/sqr/fp_sqr_comba_small_set.c\
+       tomsfastmath/sqr/fp_sqrmod.c
++else
++libclamav_la_CFLAGS += $(TOMSFASTMATH_CFLAGS)
++libclamav_la_LIBADD += $(TOMSFASTMATH_LIBS)
++endif
+ 
+ .PHONY2: version.h.tmp
+ version.c: version.h
+diff --git a/libclamav/bignum.h b/libclamav/bignum.h
+index 8fdc956bb..56dfa957e 100644
+--- a/libclamav/bignum.h
++++ b/libclamav/bignum.h
+@@ -1,9 +1,13 @@
+ #ifndef BIGNUM_H_
+ #define BIGNUM_H_
+ 
++#if HAVE_SYSTEM_TOMSFASTMATH
++#include <tfm.h>
++#else
+ #define TFM_CHECK
+-
+ #include "bignum_fast.h"
++#endif
++
+ typedef fp_int mp_int;
+ #define mp_cmp fp_cmp
+ #define mp_toradix_n(a, b, c, d) fp_toradix_n(a, b, c, d)
+diff --git a/libclamav/xdp.c b/libclamav/xdp.c
+index 87423421d..6370221ff 100644
+--- a/libclamav/xdp.c
++++ b/libclamav/xdp.c
+@@ -52,7 +52,7 @@
+ #include "scanners.h"
+ #include "conv.h"
+ #include "xdp.h"
+-#include "bignum_fast.h"
++#include "bignum.h"
+ #include "filetypes.h"
+ 
+ static char *dump_xdp(cli_ctx *ctx, const char *start, size_t sz);
+diff --git a/m4/reorganization/libs/tomsfastmath.m4 
b/m4/reorganization/libs/tomsfastmath.m4
+new file mode 100644
+index 000000000..2a821a14d
+--- /dev/null
++++ b/m4/reorganization/libs/tomsfastmath.m4
+@@ -0,0 +1,12 @@
++dnl Check for system tomsfastmath
++PKG_CHECK_MODULES([TOMSFASTMATH], [tomsfastmath], 
[have_system_tomsfastmath=yes], [have_system_tomsfastmath=no])
++
++AM_CONDITIONAL([SYSTEM_TOMSFASTMATH], [test "x$have_system_tomsfastmath" = 
"xyes"])
++
++if test "x$have_system_tomsfastmath" = "xyes"; then
++    AC_DEFINE([HAVE_SYSTEM_TOMSFASTMATH], [1], [link against system-wide 
tomsfastmath library])
++    tomsfastmath_msg="External, $TOMSFASTMATH_CFLAGS $TOMSFASTMATH_LIBS"
++else
++    AC_DEFINE([HAVE_SYSTEM_TOMSFASTMATH], [0], [don't link against 
system-wide tomsfastmath library])
++    tomsfastmath_msg="Internal"
++fi
+-- 
+2.26.2
+

diff --git a/app-antivirus/clamav/files/clamav-0.103.1-upstream-openrc.patch 
b/app-antivirus/clamav/files/clamav-0.103.1-upstream-openrc.patch
new file mode 100644
index 000000000000..a37d44fa934d
--- /dev/null
+++ b/app-antivirus/clamav/files/clamav-0.103.1-upstream-openrc.patch
@@ -0,0 +1,474 @@
+From 7d7ca4f425909368cd78cd587120703754bcd608 Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <[email protected]>
+Date: Tue, 9 Feb 2021 14:24:09 -0500
+Subject: [PATCH 1/1] Add OpenRC service scripts integrated with the build
+ system.
+
+---
+ Makefile.am                                   | 11 ++++++
+ clamav-milter/Makefile.am                     | 21 ++++++++++++
+ clamav-milter/openrc/clamav-milter.in.in      | 34 +++++++++++++++++++
+ clamd/Makefile.am                             | 19 +++++++++++
+ clamd/openrc/clamd.in.in                      | 33 ++++++++++++++++++
+ clamonacc/Makefile.am                         | 19 +++++++++++
+ clamonacc/openrc/clamonacc.in.in              | 18 ++++++++++
+ configure.ac                                  | 16 ++++++++-
+ etc/Makefile.am                               | 22 +++++++++++-
+ ...sample => clamav-milter.conf.sample.in.in} |  5 +--
+ ...md.conf.sample => clamd.conf.sample.in.in} |  4 +--
+ ...onf.sample => freshclam.conf.sample.in.in} |  2 +-
+ freshclam/Makefile.am                         | 20 +++++++++++
+ freshclam/openrc/freshclam.in.in              |  8 +++++
+ m4/reorganization/libs/openrc.m4              |  8 +++++
+ 15 files changed, 233 insertions(+), 7 deletions(-)
+ create mode 100644 clamav-milter/openrc/clamav-milter.in.in
+ create mode 100644 clamd/openrc/clamd.in.in
+ create mode 100644 clamonacc/openrc/clamonacc.in.in
+ rename etc/{clamav-milter.conf.sample => clamav-milter.conf.sample.in.in} 
(98%)
+ rename etc/{clamd.conf.sample => clamd.conf.sample.in.in} (99%)
+ rename etc/{freshclam.conf.sample => freshclam.conf.sample.in.in} (99%)
+ create mode 100644 freshclam/openrc/freshclam.in.in
+ create mode 100644 m4/reorganization/libs/openrc.m4
+
+diff --git a/Makefile.am b/Makefile.am
+index 42a58e7..c4d82ad 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -52,6 +52,17 @@ nodist_include_HEADERS = clamav-types.h clamav-version.h
+ distuninstallcheck_listfiles = find . -type f ! -name clamd.conf ! -name 
freshclam.conf ! -name daily.cvd ! -name main.cvd -print
+ DISTCLEANFILES = target.h
+ DISTCHECK_CONFIGURE_FLAGS=--enable-milter --disable-clamav 
--enable-all-jit-targets --enable-llvm=yes --with-system-llvm=no 
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) 
CC="$(CC)" CXX="$(CXX)" YACC="$(YACC)" LEX="$(LEX)" AR="$(AR)" AS="$(AS)"
++
++
++# This command allows us to replace bindir, libdir, etc.
++# within our script and conf file. The example is taken
++# from the autoconf documentation and can be found in the
++# "Installation Directory Variables" section.
++editgnudirs = sed -e 's|@BINDIR[@]|$(bindir)|g' \
++                  -e 's|@SBINDIR[@]|$(sbindir)|g' \
++                  -e 's|@RUNSTATEDIR[@]|$(runstatedir)|g'
++export editgnudirs
++
+ lcov:
+       ($(MAKE); cd unit_tests; $(MAKE) lcov)
+ quick-check:
+diff --git a/clamav-milter/Makefile.am b/clamav-milter/Makefile.am
+index 38d9b94..46885a7 100644
+--- a/clamav-milter/Makefile.am
++++ b/clamav-milter/Makefile.am
+@@ -35,6 +35,27 @@ clamav_milter_SOURCES = \
+ man_MANS = $(top_builddir)/docs/man/clamav-milter.8
+ AM_CFLAGS=@WERR_CFLAGS_MILTER@
+ 
++
++if INSTALL_OPENRC_SERVICES
++
++openrcdir = $(sysconfdir)/init.d
++
++# The next rule allows us to replace @RUNSTATEDIR@ and friends within
++# our OpenRC service scripts. This example is taken from the autoconf
++# documentation in the "Installation Directory Variables" section.
++openrc_SCRIPTS_src = openrc/clamav-milter.in.in
++openrc_SCRIPTS_intermediate = openrc/clamav-milter.in
++nodist_openrc_SCRIPTS = openrc/clamav-milter
++DISTCLEANFILES = $(nodist_openrc_SCRIPTS) $(openrc_SCRIPTS_intermediate)
++$(nodist_openrc_SCRIPTS): $(openrc_SCRIPTS_src) 
$(openrc_SCRIPTS_intermediate) Makefile
++      rm -f $@ [email protected]
++      $(editgnudirs) [email protected] > [email protected]
++      mv [email protected] $@
++
++endif
++EXTRA_DIST = $(openrc_SCRIPTS_src)
++
++
+ endif
+ 
+ LIBS = $(top_builddir)/libclamav/libclamav.la 
$(top_builddir)/shared/libshared.la @CLAMAV_MILTER_LIBS@ @THREAD_LIBS@
+diff --git a/clamav-milter/openrc/clamav-milter.in.in 
b/clamav-milter/openrc/clamav-milter.in.in
+new file mode 100644
+index 0000000..7105356
+--- /dev/null
++++ b/clamav-milter/openrc/clamav-milter.in.in
+@@ -0,0 +1,34 @@
++#!/sbin/openrc-run
++
++# Note: the "Foreground" option in clamav-milter.conf MUST
++# be set to "no".
++command="@SBINDIR@/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="@RUNSTATEDIR@/${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 \
++           "@RUNSTATEDIR@/clamav"
++}
+diff --git a/clamd/Makefile.am b/clamd/Makefile.am
+index c161586..b59d94c 100644
+--- a/clamd/Makefile.am
++++ b/clamd/Makefile.am
+@@ -44,6 +44,25 @@ if INSTALL_SYSTEMD_UNITS
+ systemdsystemunit_DATA = clamav-daemon.socket clamav-daemon.service
+ endif
+ 
++if INSTALL_OPENRC_SERVICES
++
++openrcdir = $(sysconfdir)/init.d
++
++# The next rule allows us to replace @RUNSTATEDIR@ and friends within
++# our OpenRC service scripts. This example is taken from the autoconf
++# documentation in the "Installation Directory Variables" section.
++openrc_SCRIPTS_src = openrc/clamd.in.in
++openrc_SCRIPTS_intermediate = openrc/clamd.in
++nodist_openrc_SCRIPTS = openrc/clamd
++DISTCLEANFILES = $(nodist_openrc_SCRIPTS) $(openrc_SCRIPTS_intermediate)
++$(nodist_openrc_SCRIPTS): $(openrc_SCRIPTS_src) 
$(openrc_SCRIPTS_intermediate) Makefile
++      rm -f $@ [email protected]
++      $(editgnudirs) [email protected] > [email protected]
++      mv [email protected] $@
++
++endif
++EXTRA_DIST = $(openrc_SCRIPTS_src)
++
+ LIBS = $(top_builddir)/libclamav/libclamav.la 
$(top_builddir)/shared/libshared.la @CLAMD_LIBS@ @THREAD_LIBS@
+ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared 
-I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav 
-I$(top_srcdir)/libclamunrar_iface @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ 
@PCRE_CPPFLAGS@
+ 
+diff --git a/clamd/openrc/clamd.in.in b/clamd/openrc/clamd.in.in
+new file mode 100644
+index 0000000..5d38f9a
+--- /dev/null
++++ b/clamd/openrc/clamd.in.in
+@@ -0,0 +1,33 @@
++#!/sbin/openrc-run
++
++# Note: the "Foreground" option in clamd.conf must be set to "no"
++command="@SBINDIR@/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="@RUNSTATEDIR@/${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 \
++           "@RUNSTATEDIR@/clamav"
++}
++
++reload() {
++  ebegin "Reloading ${RC_SVCNAME}"
++  "@BINDIR@/clamdscan" --reload
++  eend $?
++}
+diff --git a/clamonacc/Makefile.am b/clamonacc/Makefile.am
+index 4cb4886..39c2e5d 100644
+--- a/clamonacc/Makefile.am
++++ b/clamonacc/Makefile.am
+@@ -58,6 +58,25 @@ if INSTALL_SYSTEMD_UNITS
+ systemdsystemunit_DATA = clamav-clamonacc.service
+ endif
+ 
++if INSTALL_OPENRC_SERVICES
++
++openrcdir = $(sysconfdir)/init.d
++
++# The next rules allow us to replace @RUNSTATEDIR@ and friends within
++# our OpenRC service scripts. This example is taken from the autoconf
++# documentation in the "Installation Directory Variables" section.
++openrc_SCRIPTS_src = openrc/clamonacc.in.in
++openrc_SCRIPTS_intermediate = openrc/clamonacc.in
++nodist_openrc_SCRIPTS = openrc/clamonacc
++DISTCLEANFILES = $(nodist_openrc_SCRIPTS) $(openrc_SCRIPTS_intermediate)
++$(nodist_openrc_SCRIPTS): $(openrc_SCRIPTS_src) 
$(openrc_SCRIPTS_intermediate) Makefile
++      rm -f $@ [email protected]
++      $(editgnudirs) [email protected] > [email protected]
++      mv [email protected] $@
++
++endif
++EXTRA_DIST = $(openrc_SCRIPTS_src)
++
+ LIBS = $(top_builddir)/shared/libshared.la 
$(top_builddir)/libclamav/libclamav.la @CURL_LIBS@ @CLAMONACC_LIBS@ 
@THREAD_LIBS@
+ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamonacc 
-I$(top_srcdir)/shared -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav 
-I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface @CURL_CPPFLAGS@ 
@SSL_CPPFLAGS@ @CLAMONACC_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
+ 
+diff --git a/clamonacc/openrc/clamonacc.in.in 
b/clamonacc/openrc/clamonacc.in.in
+new file mode 100644
+index 0000000..844cd49
+--- /dev/null
++++ b/clamonacc/openrc/clamonacc.in.in
+@@ -0,0 +1,18 @@
++#!/sbin/openrc-run
++
++command="@SBINDIR@/clamonacc"
++pidfile="@RUNSTATEDIR@/${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/configure.ac b/configure.ac
+index 33e252e..c8cd60f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -79,6 +79,12 @@ if test "$enable_experimental" = "yes"; then
+   VERSION_SUFFIX="$VERSION_SUFFIX-exp"
+ fi
+ 
++# Autoconf 2.70 will support this, and many distros patch it in,
++# but Autoconf 2.70 hasn't actually been released yet (it's in beta).
++AS_IF([test -z "${runstatedir}"], [runstatedir='${localstatedir}/run'])
++AC_SUBST([runstatedir])
++
++
+ build_configure_args=`echo "$ac_configure_args" | sed -e 's/[\"]//g'`
+ AC_SUBST([BUILD_CONFIGURE_FLAGS], [$build_configure_args])
+ 
+@@ -105,6 +111,7 @@ m4_include([m4/reorganization/libs/libz.m4])
+ m4_include([m4/reorganization/libs/bzip.m4])
+ m4_include([m4/reorganization/libs/unrar.m4])
+ m4_include([m4/reorganization/libs/systemd.m4])
++m4_include([m4/reorganization/libs/openrc.m4])
+ m4_include([m4/reorganization/code_checks/ipv6.m4])
+ m4_include([m4/reorganization/code_checks/dns.m4])
+ m4_include([m4/reorganization/code_checks/fanotify.m4])
+@@ -193,7 +200,10 @@ AC_CONFIG_FILES([
+                  libclamav.pc
+                  platform.h
+                  clamav-types.h
+-                 clamav-version.h])
++                 clamav-version.h
++                 etc/clamd.conf.sample.in
++                 etc/clamav-milter.conf.sample.in
++                 etc/freshclam.conf.sample.in])
+ if test "x$enable_libclamav_only" != "xyes"; then
+     if test "$have_curl" = "no"; then
+         AC_MSG_ERROR([libcurl not found. libcurl (e.g. libcurl-devel) is 
required in order to build freshclam and clamsubmit.])
+@@ -207,10 +217,14 @@ if test "x$enable_libclamav_only" != "xyes"; then
+                      clamd/Makefile
+                      clamd/clamav-daemon.service
+                      clamd/clamav-daemon.socket
++                     clamd/openrc/clamd.in
+                      clamdscan/Makefile
+                      clamsubmit/Makefile
++                     clamonacc/openrc/clamonacc.in
+                      clamav-milter/Makefile
++                     clamav-milter/openrc/clamav-milter.in
+                      freshclam/clamav-freshclam.service
++                     freshclam/openrc/freshclam.in
+                      freshclam/Makefile
+                      sigtool/Makefile
+                      clamconf/Makefile
+diff --git a/etc/Makefile.am b/etc/Makefile.am
+index c694856..213a978 100644
+--- a/etc/Makefile.am
++++ b/etc/Makefile.am
+@@ -18,11 +18,31 @@
+ #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ #  MA 02110-1301, USA.
+ 
+-EXTRA_DIST = clamd.conf.sample freshclam.conf.sample clamav-milter.conf.sample
++EXTRA_DIST = clamd.conf.sample.in.in \
++             freshclam.conf.sample.in.in \
++             clamav-milter.conf.sample.in.in
+ CFGINST = @CFGDIR@
+ 
+ sysconf_DATA = clamd.conf.sample freshclam.conf.sample
+ 
++# Custom variable to simplify the "edit" rule below.
++sysconf_DATA_intermediate = clamd.conf.sample.in freshclam.conf.sample.in
++
+ if HAVE_MILTER
+ sysconf_DATA += clamav-milter.conf.sample
++sysconf_DATA_intermediate += clamav-milter.conf.sample.in
+ endif
++
++# Otherwise these don't get cleaned up by "make distclean",
++# even though they are auto-generated.
++DISTCLEANFILES = $(sysconf_DATA) $(sysconf_DATA_intermediate)
++
++# This rule includes EVERY source/intermediate file as a dependency of
++# EVERY output file, which is clearly wrong, but it may be the best we
++# can do without duplication. At least it's the right kind of wrong,
++# and rebuilds too often rather than not often enough.
++$(sysconf_DATA): $(sysconf_DATA_intermediate) $(EXTRA_DIST) Makefile
++      rm -f $@ [email protected]
++      $(editgnudirs) [email protected] > [email protected]
++      mv [email protected] $@
++
+diff --git a/etc/clamav-milter.conf.sample 
b/etc/clamav-milter.conf.sample.in.in
+similarity index 98%
+rename from etc/clamav-milter.conf.sample
+rename to etc/clamav-milter.conf.sample.in.in
+index bf46b4f..c3c5d20 100644
+--- a/etc/clamav-milter.conf.sample
++++ b/etc/clamav-milter.conf.sample.in.in
+@@ -17,7 +17,7 @@ Example
+ # inet6:port@[hostname|ip-address] - to specify an ipv6 socket
+ #
+ # Default: no default
+-#MilterSocket /tmp/clamav-milter.socket
++#MilterSocket unix:@RUNSTATEDIR@/clamav/clamav-milter.socket
+ #MilterSocket inet:7357
+ 
+ # Define the group ownership for the (unix) milter socket.
+@@ -64,7 +64,7 @@ Example
+ # also owned by root to keep other users from tampering with it.
+ #
+ # Default: disabled
+-#PidFile /var/run/clamav-milter.pid
++#PidFile @RUNSTATEDIR@/clamav-milter.pid
+ 
+ # Optional path to the global temporary directory.
+ # Default: system specific (usually /tmp or /var/tmp).
+@@ -91,6 +91,7 @@ Example
+ # fashion.
+ #
+ # Default: no default
++#ClamdSocket unix:@RUNSTATEDIR@/clamav/clamd.ctl
+ #ClamdSocket tcp:scanner.mydomain:7357
+ 
+ 
+diff --git a/etc/clamd.conf.sample b/etc/clamd.conf.sample.in.in
+similarity index 99%
+rename from etc/clamd.conf.sample
+rename to etc/clamd.conf.sample.in.in
+index a1ca9ec..82ef42c 100644
+--- a/etc/clamd.conf.sample
++++ b/etc/clamd.conf.sample.in.in
+@@ -74,7 +74,7 @@ Example
+ # It is recommended that the directory where this file is stored is
+ # also owned by root to keep other users from tampering with it.
+ # Default: disabled
+-#PidFile /var/run/clamd.pid
++#PidFile @RUNSTATEDIR@/clamd.pid
+ 
+ # Optional path to the global temporary directory.
+ # Default: system specific (usually /tmp or /var/tmp).
+@@ -93,7 +93,7 @@ Example
+ 
+ # Path to a local socket file the daemon will listen on.
+ # Default: disabled (must be specified by a user)
+-#LocalSocket /tmp/clamd.socket
++#LocalSocket @RUNSTATEDIR@/clamav/clamd.ctl
+ 
+ # Sets the group ownership on the unix socket.
+ # Default: disabled (the primary group of the user running clamd)
+diff --git a/etc/freshclam.conf.sample b/etc/freshclam.conf.sample.in.in
+similarity index 99%
+rename from etc/freshclam.conf.sample
+rename to etc/freshclam.conf.sample.in.in
+index 8f4dd49..5a5c42b 100644
+--- a/etc/freshclam.conf.sample
++++ b/etc/freshclam.conf.sample.in.in
+@@ -51,7 +51,7 @@ Example
+ # It is recommended that the directory where this file is stored is
+ # also owned by root to keep other users from tampering with it.
+ # Default: disabled
+-#PidFile /var/run/freshclam.pid
++#PidFile @RUNSTATEDIR@/freshclam.pid
+ 
+ # By default when started freshclam drops privileges and switches to the
+ # "clamav" user. This directive allows you to change the database owner.
+diff --git a/freshclam/Makefile.am b/freshclam/Makefile.am
+index 9e48119..46ef224 100644
+--- a/freshclam/Makefile.am
++++ b/freshclam/Makefile.am
+@@ -32,6 +32,26 @@ if INSTALL_SYSTEMD_UNITS
+ systemdsystemunit_DATA = clamav-freshclam.service
+ endif
+ 
++if INSTALL_OPENRC_SERVICES
++
++openrcdir = $(sysconfdir)/init.d
++
++# The next rule allows us to replace @RUNSTATEDIR@ and friends within
++# our OpenRC service scripts. This example is taken from the autoconf
++# documentation in the "Installation Directory Variables" section.
++openrc_SCRIPTS_src = openrc/freshclam.in.in
++openrc_SCRIPTS_intermediate = openrc/freshclam.in
++nodist_openrc_SCRIPTS = openrc/freshclam
++DISTCLEANFILES = $(nodist_openrc_SCRIPTS) $(openrc_SCRIPTS_intermediate)
++$(nodist_openrc_SCRIPTS): $(openrc_SCRIPTS_src) 
$(openrc_SCRIPTS_intermediate) Makefile
++      rm -f $@ [email protected]
++      $(editgnudirs) [email protected] > [email protected]
++      mv [email protected] $@
++
++endif
++EXTRA_DIST = $(openrc_SCRIPTS_src)
++
++
+ AM_CFLAGS=@WERR_CFLAGS@
+ DEFS = @DEFS@
+ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared 
-I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav 
-I$(top_srcdir)/libclamunrar_iface -I$(top_srcdir)/libfreshclam @CURL_CPPFLAGS@ 
@SSL_CPPFLAGS@ @FRESHCLAM_CPPFLAGS@ @ZLIB_CFLAGS@ @JSON_CPPFLAGS@ 
@PCRE_CPPFLAGS@
+diff --git a/freshclam/openrc/freshclam.in.in 
b/freshclam/openrc/freshclam.in.in
+new file mode 100644
+index 0000000..9feb737
+--- /dev/null
++++ b/freshclam/openrc/freshclam.in.in
+@@ -0,0 +1,8 @@
++#!/sbin/openrc-run
++
++command="@BINDIR@/freshclam"
++pidfile="@RUNSTATEDIR@/${RC_SVCNAME}.pid"
++
++# Ignore the value of "PidFile" set in freshclam.conf.
++command_args="-p ${pidfile}"
++command_args_background="--daemon"
+diff --git a/m4/reorganization/libs/openrc.m4 
b/m4/reorganization/libs/openrc.m4
+new file mode 100644
+index 0000000..1a73d15
+--- /dev/null
++++ b/m4/reorganization/libs/openrc.m4
+@@ -0,0 +1,8 @@
++dnl Should we install our OpenRC service files?
++AC_ARG_ENABLE([openrc],
++              AS_HELP_STRING([--enable-openrc],
++                             [Install OpenRC service files]),
++              [],
++              [enable_openrc=no])
++AM_CONDITIONAL(INSTALL_OPENRC_SERVICES,
++               [test "x$enable_openrc" = "xyes"])
+-- 
+2.26.2
+

diff --git a/app-antivirus/clamav/files/clamav-0.103.12-missing-const.patch 
b/app-antivirus/clamav/files/clamav-0.103.12-missing-const.patch
new file mode 100644
index 000000000000..39b98b7f4732
--- /dev/null
+++ b/app-antivirus/clamav/files/clamav-0.103.12-missing-const.patch
@@ -0,0 +1,13 @@
+diff --git a/libclamav/regex/engine.c b/libclamav/regex/engine.c
+index ed359c3..3c25398 100644
+--- a/libclamav/regex/engine.c
++++ b/libclamav/regex/engine.c
+@@ -223,7 +223,7 @@ matcher(struct re_guts *g, const char *string, size_t 
nmatch,
+                       dp = dissect(m, m->coldp, endp, gf, gl);
+               } else {
+                       if (g->nplus > 0 && m->lastpos == NULL)
+-                              m->lastpos = (char **)cli_malloc((g->nplus+1) *
++                              m->lastpos = (const char 
**)cli_malloc((g->nplus+1) *
+                                                       sizeof(char *));
+                       if (g->nplus > 0 && m->lastpos == NULL) {
+                               free(m->pmatch);


Reply via email to